Skip to content

Commit 0ef7b95

Browse files
authored
Merge pull request #166 from classmodel/updated_time_series
Added RH following identical calculation as CLASS and renamed t to time
2 parents eaeb2d7 + 2ea3d04 commit 0ef7b95

File tree

2 files changed

+44
-4
lines changed

2 files changed

+44
-4
lines changed

packages/class/src/class.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
* @module
44
*/
55
import type { Config, MixedLayerConfig, WindConfig } from "./config.js";
6+
import { qsatLiq } from "./thermodynamics.js";
67
import { findInsertIndex, interpolateHourly } from "./utils.js";
78

89
// Constants
@@ -209,6 +210,26 @@ export class CLASS {
209210
return this.wtheta + 0.61 * this.ml.theta * this.wq;
210211
}
211212

213+
/** RH at surface */
214+
get RH(): number {
215+
this.assertMixedLayer();
216+
/** this is compatible with the inaccurate original CLASS method with rho = 1.2 */
217+
const qsat_h = qsatLiq(this._cfg.p0, this.ml.theta);
218+
return (100.0 * this.ml.qt) / qsat_h;
219+
}
220+
/** RH at h */
221+
get RH_h(): number {
222+
this.assertMixedLayer();
223+
/** this is compatible with the inaccurate original CLASS method with rho = 1.2 */
224+
const rho = 1.2;
225+
const g = 9.81;
226+
const cp = 1005.0;
227+
const p_h = this._cfg.p0 - this.ml.h * rho * g;
228+
const T_h = this.ml.theta - (g / cp) * this.ml.h;
229+
const qsat_h = qsatLiq(p_h, T_h);
230+
return (100.0 * this.ml.qt) / qsat_h;
231+
}
232+
212233
// Lapse rates
213234

214235
/** Free atmosphere potential temperature lapse rate */
@@ -270,6 +291,10 @@ export class CLASS {
270291
return this.ml?.qt || 999;
271292
}
272293

294+
get time_hour() {
295+
return this.t / 3600.0;
296+
}
297+
273298
get utcTime() {
274299
// export time in milliseconds since epoch so bounds calculation and
275300
// rendering can happen on app side

packages/class/src/output.ts

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,17 @@ export const outputVariables = {
88
t: {
99
title: "Time",
1010
unit: "s",
11-
symbol: "t",
11+
symbol: "time (s)",
12+
},
13+
time_hour: {
14+
title: "Time",
15+
unit: "h",
16+
symbol: "time (h)",
1217
},
1318
utcTime: {
14-
title: "Time (UTC)",
15-
unit: "-",
16-
symbol: "UTC",
19+
title: "Time UTC",
20+
unit: "h",
21+
symbol: "time (h UTC)",
1722
},
1823
h: {
1924
title: "ABL height",
@@ -95,6 +100,16 @@ export const outputVariables = {
95100
unit: "m s⁻¹",
96101
symbol: "Δv",
97102
},
103+
RH: {
104+
title: "Relative humidity at the surface",
105+
unit: "%",
106+
symbol: "RH",
107+
},
108+
RH_h: {
109+
title: "Relative humidity at h",
110+
unit: "%",
111+
symbol: "RH_h",
112+
},
98113
} as const satisfies Record<string, VariableInfo>;
99114

100115
export type OutputVariableKey = keyof typeof outputVariables;

0 commit comments

Comments
 (0)