lmweather

lmweather is a self-contained atmospheric and oceanic shallow-water dynamics host for lmscript on the rotating sphere and beta-plane. It solves spectral transform spherical equations (including Williamson benchmarks) and staggered C-grid channel dynamics with zero external library dependencies.

Quick reference

npm i -g @lmctl-ai/lmctl
lmscript rh.lms
lmweather --version
lmweather --lmcode-schema --json
Method Signature Summary
wx.sphere wx.sphere(T: int) -> Sphere Create an Earth-scaled spectral shallow-water model at triangular truncation T (4..170)
wx.planet wx.planet(T: int, radius: float, omega: float, g: float) -> Sphere Create a spectral spherical model with custom planetary radius, rotation rate, and gravity
Sphere.williamson6 s.williamson6() -> Sphere Initialize Williamson test case 6 (Rossby-Haurwitz wave 4)
Sphere.run_dt s.run_dt(seconds: float, dt: float) -> Sphere Integrate the sphere with explicit RK4 using fixed time step dt (checked against CFL limit)
Sphere.save_csv s.save_csv(path: string) -> void Write space-separated Gaussian grid table (lon lat h u v zeta q hs) for gnuplot pm3d
wx.plane wx.plane(nx: int, ny: int, Lx: float, Ly: float) -> Plane Create a staggered C-grid beta-plane channel model (periodic in x, free-slip walls in y)
Plane.fields p.fields(h_anom: string, u: string, v: string) -> Plane Initialize height anomaly above H and velocity fields from expressions in x and y
wx.assert_close wx.assert_close(actual: float, expected: float, tol: float) -> void Assert that two finite numbers agree within absolute tolerance tol
p = _lmcode_ cli="lmweather" install="github:lmctl-ai/lmweather@latest";
let s = wx.sphere(42).williamson6();
let m0 = s.mean_height();
let e0 = s.energy();
s.run_dt(7.0 * 86400.0, 900.0);
wx.print("crest of wave 4 at 45N: " + str(s.wave_crest(4, 45.0)) + " deg");
wx.assert_close(s.mean_height(), m0, 0.000000001);
wx.assert_close(s.energy() / e0, 1.0, 0.0001);
s.save_csv("rh_day7.csv");
end _lmcode_
r = run_lmcode(p);
require(r.ok, "rh run failed");

Documentation pages

Source repository and releases