diff --git a/packages/class/src/config.ts b/packages/class/src/config.ts index 5423eca..b8817a2 100644 --- a/packages/class/src/config.ts +++ b/packages/class/src/config.ts @@ -57,6 +57,12 @@ const untypedSchema = { title: "Mixed-layer switch", default: true, }, + sw_dc: { + type: "boolean", + "ui:group": "Diurnal cycle", + title: "Diurnal cycle switch", + default: false, + }, sw_wind: { type: "boolean", "ui:group": "Wind", @@ -263,6 +269,29 @@ const untypedSchema = { ], }, }, + { + if: { + properties: { + sw_dc: { + const: true, + }, + }, + }, + // biome-ignore lint/suspicious/noThenProperty: + then: { + properties: { + t_dc: { + symbol: "Tdiurnal", + type: "number", + unit: "h", + default: 13, + title: "Period of diurnal cycle", + "ui:group": "Diurnal cycle", + }, + }, + required: ["t_dc"], + }, + }, { if: { properties: { @@ -532,6 +561,14 @@ type NoMixedLayerConfig = { sw_ml?: false; }; +export type DiurnalCycleConfig = { + sw_dc: true; + t_dc: number; +}; +export type NoDiurnalCycleConfig = { + sw_dc?: false; +}; + export type FireConfig = { sw_fire: true; L: number; @@ -551,7 +588,8 @@ export type NoFireConfig = { export type Config = GeneralConfig & (MixedLayerConfig | NoMixedLayerConfig) & (WindConfig | NoWindConfig) & - (FireConfig | NoFireConfig); + (FireConfig | NoFireConfig) & + (DiurnalCycleConfig | NoDiurnalCycleConfig); export type JsonSchemaOfConfig = JSONSchemaType; export const jsonSchemaOfConfig = diff --git a/packages/class/src/config_utils.test.ts b/packages/class/src/config_utils.test.ts index 4495c0a..c96e0f0 100644 --- a/packages/class/src/config_utils.test.ts +++ b/packages/class/src/config_utils.test.ts @@ -1,74 +1,87 @@ import assert from "node:assert"; import test, { describe } from "node:test"; +import type { Config } from "./config.js"; import { pruneConfig } from "./config_utils.js"; describe("pruneConfig()", () => { test("given 3 real configs", () => { - const preset = { + const preset: Config = { name: "Default", description: "Default configuration", t0: "2025-09-08T14:30:00Z", - theta_0: 323, - h_0: 200, - dtheta_0: 1, - q_0: 0.008, - dq_0: -0.001, + theta: 323, + h: 200, + dtheta: 1, + qt: 0.008, + dqt: -0.001, dt: 60, runtime: 4320, - wtheta: 0.1, + wtheta: [0.1], advtheta: 0, - gamma_theta: 0.006, - wq: 0.0001, + gamma_theta: [0.006], + wq: [0.0001], advq: 0, - gamma_qt: 0, + gamma_qt: [0], divU: 0, beta: 0.2, + sw_ml: true, + p0: 101300, + z_theta: [5000], + z_qt: [5000], }; - const reference = { + const reference: Config = { name: "Higher and Hotter", description: "Higher h_0", t0: "2025-09-08T14:30:00Z", - h_0: 211, - theta_0: 323, - dtheta_0: 1, - q_0: 0.008, - dq_0: -0.001, + h: 211, + theta: 323, + dtheta: 1, + qt: 0.008, + dqt: -0.001, dt: 60, runtime: 4320, - wtheta: 0.1, + wtheta: [0.1], advtheta: 0, - gamma_theta: 0.006, - wq: 0.0001, + gamma_theta: [0.006], + wq: [0.0001], advq: 0, - gamma_qt: 0, + gamma_qt: [0], divU: 0, beta: 0.2, + sw_ml: true, + p0: 101300, + z_theta: [5000], + z_qt: [5000], }; - const permutation = { + const permutation: Config = { name: "Higher", description: "", t0: "2025-09-08T14:30:00Z", - h_0: 222, - theta_0: 323, - dtheta_0: 1, - q_0: 0.008, - dq_0: -0.001, + h: 222, + theta: 323, + dtheta: 1, + qt: 0.008, + dqt: -0.001, dt: 60, runtime: 4320, - wtheta: 0.1, + wtheta: [0.1], advtheta: 0, - gamma_theta: 0.006, - wq: 0.0001, + gamma_theta: [0.006], + wq: [0.0001], advq: 0, - gamma_qt: 0, + gamma_qt: [0], divU: 0, beta: 0.212, + sw_ml: true, + p0: 101300, + z_theta: [5000], + z_qt: [5000], }; const result = pruneConfig(permutation, reference, preset); const expected = { name: "Higher", description: "", - h_0: 222, + h: 222, beta: 0.212, }; assert.deepEqual(result, expected); diff --git a/packages/class/src/validate.test.ts b/packages/class/src/validate.test.ts index f9dc391..7043dc4 100644 --- a/packages/class/src/validate.test.ts +++ b/packages/class/src/validate.test.ts @@ -93,6 +93,8 @@ describe("parse", () => { sw_ml: true, sw_wind: false, sw_fire: false, + sw_dc: false, + t_dc: 13, }; assert.deepEqual(output, expected); });