Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions packages/class/src/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
* @module
*/
import type { Config, MixedLayerConfig, WindConfig } from "./config.js";
import { qsatLiq } from "./thermodynamics.js";
import { findInsertIndex, interpolateHourly } from "./utils.js";

// Constants
Expand Down Expand Up @@ -209,6 +210,26 @@ export class CLASS {
return this.wtheta + 0.61 * this.ml.theta * this.wq;
}

/** RH at surface */
get RH(): number {
this.assertMixedLayer();
/** this is compatible with the inaccurate original CLASS method with rho = 1.2 */
const qsat_h = qsatLiq(this._cfg.p0, this.ml.theta);
return (100.0 * this.ml.qt) / qsat_h;
}
/** RH at h */
get RH_h(): number {
this.assertMixedLayer();
/** this is compatible with the inaccurate original CLASS method with rho = 1.2 */
const rho = 1.2;
const g = 9.81;
const cp = 1005.0;
const p_h = this._cfg.p0 - this.ml.h * rho * g;
const T_h = this.ml.theta - (g / cp) * this.ml.h;
const qsat_h = qsatLiq(p_h, T_h);
return (100.0 * this.ml.qt) / qsat_h;
}

// Lapse rates

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

get time_hour() {
return this.t / 3600.0;
}

get utcTime() {
// export time in milliseconds since epoch so bounds calculation and
// rendering can happen on app side
Expand Down
23 changes: 19 additions & 4 deletions packages/class/src/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,17 @@ export const outputVariables = {
t: {
title: "Time",
unit: "s",
symbol: "t",
symbol: "time (s)",
},
time_hour: {
title: "Time",
unit: "h",
symbol: "time (h)",
},
utcTime: {
title: "Time (UTC)",
unit: "-",
symbol: "UTC",
title: "Time UTC",
unit: "h",
symbol: "time (h UTC)",
},
h: {
title: "ABL height",
Expand Down Expand Up @@ -95,6 +100,16 @@ export const outputVariables = {
unit: "m s⁻¹",
symbol: "Δv",
},
RH: {
title: "Relative humidity at the surface",
unit: "%",
symbol: "RH",
},
RH_h: {
title: "Relative humidity at h",
unit: "%",
symbol: "RH_h",
},
} as const satisfies Record<string, VariableInfo>;

export type OutputVariableKey = keyof typeof outputVariables;
Expand Down