diff --git a/packages/class/src/class.ts b/packages/class/src/class.ts index 5782516..f25a172 100644 --- a/packages/class/src/class.ts +++ b/packages/class/src/class.ts @@ -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 @@ -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 */ @@ -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 diff --git a/packages/class/src/output.ts b/packages/class/src/output.ts index 5182789..0bfbcf7 100644 --- a/packages/class/src/output.ts +++ b/packages/class/src/output.ts @@ -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", @@ -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; export type OutputVariableKey = keyof typeof outputVariables;