Skip to content

Commit 4e873b9

Browse files
authored
Bring back we factor in model code; fix issue with axis limits going to NaN; add initial time to output; add model internal vars to output
1 parent a938a87 commit 4e873b9

File tree

5 files changed

+21
-8
lines changed

5 files changed

+21
-8
lines changed

apps/class-solid/src/components/Analysis.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ export function VerticalProfilePlot({
176176

177177
// TODO: better to include jump at top in extent calculation rather than adding random margin.
178178
const xLim = () => getNiceAxisLimits(allValues(), 1);
179-
const yLim = () => getNiceAxisLimits(allHeights(), 0);
179+
const yLim = () =>
180+
[0, getNiceAxisLimits(allHeights(), 0)[1]] as [number, number];
180181
const profileData = () =>
181182
flatExperiments().map((e) => {
182183
const { config, output, ...formatting } = e;
@@ -248,8 +249,6 @@ function TimeSlider(
248249
const max = maxValue();
249250
if (time() > max && max !== -1) {
250251
setTime(maxValue());
251-
console.log(maxValue());
252-
console.log(time());
253252
}
254253
});
255254
return (

apps/class-solid/src/components/plots/Axes.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,10 @@ export function getNiceAxisLimits(
8787
const max = Math.max(...data);
8888
const min = Math.min(...data);
8989
const range = max - min;
90+
91+
// Avoid NaNs on axis for constant values
92+
if (range === 0) return [min - 1, max + 1];
93+
9094
const step = 10 ** Math.floor(Math.log10(range));
9195

9296
const niceMin = Math.floor(min / step) * step - extraMargin * step;

apps/class-solid/src/lib/profiles.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ export function getVerticalProfiles(
1818
const height = output.h.slice(t)[0];
1919
const dh = 1600; // how much free troposphere to display?
2020
const hProfile = [0, height, height, height + dh];
21-
2221
if (variable === "theta") {
2322
// Extract potential temperature profile
2423
const theta = output.theta.slice(t)[0];

packages/class/src/bmi.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,18 @@ interface BmiLight<Config> {
3434
get_grid_type(): string;
3535
}
3636

37-
const ouput_var_names: string[] = ["h", "theta", "dtheta", "q", "dq"] as const;
37+
const ouput_var_names: string[] = [
38+
"h",
39+
"theta",
40+
"dtheta",
41+
"q",
42+
"dq",
43+
"dthetav",
44+
"we",
45+
"ws",
46+
"wthetave",
47+
"wthetav",
48+
] as const;
3849

3950
/**
4051
* Class representing a BMI (Basic Model Interface) implementation for the CLASS model.
@@ -134,8 +145,7 @@ export class BmiClass implements BmiLight<Config> {
134145
}): { t: number[] } & { [K in T[number]]: number[] } {
135146
const output: { t: number[] } & { [K in T[number]]: number[] } =
136147
Object.fromEntries([["t", []], ...var_names.map((name) => [name, []])]);
137-
while (this.model.t < this.config.timeControl.runtime) {
138-
this.update();
148+
while (this.model.t <= this.config.timeControl.runtime) {
139149
if (this.model.t % freq === 0) {
140150
output.t.push(this.model.t);
141151
for (const name of var_names) {
@@ -145,6 +155,7 @@ export class BmiClass implements BmiLight<Config> {
145155
// TODO progress callback?
146156
// Initial attempt failed with "could not be cloned" error
147157
}
158+
this.update();
148159
}
149160
return output;
150161
}

packages/class/src/class.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ export class CLASS {
8181
/** Tendency of specific humidity jump at h[kg kg-1 s-1] */
8282
get dqtend(): number {
8383
const w_q_ft = 0; // TODO: add free troposphere switch
84-
return this._cfg.mixedLayer.gammaq - this.qtend + w_q_ft;
84+
return this._cfg.mixedLayer.gammaq * this.we - this.qtend + w_q_ft;
8585
}
8686

8787
/** Entrainment velocity [m s-1]. */

0 commit comments

Comments
 (0)