lmweather reference
Complete reference for lmweather command-line flags, environment variables, Wx, Sphere, and Plane methods, and exit codes.
Command-line flags
| Flag or invocation | Purpose |
|---|---|
| lmweather --version | Print lmweather X.Y.Z to stdout and exit 0 |
| lmweather --notices | Print embedded license and numerical method notices to stdout and exit 0 |
| lmweather --lmcode-schema | Print human-readable registered context, type, and method signatures to stdout and exit 0 |
| lmweather --lmcode-schema --json | Print exact embedded lmweather.dsl.json schema bytes to stdout and exit 0 |
| lmweather --lmcode-signatures | Print canonical sorted registry signatures for parity checks with lmscript and exit 0 |
| lmweather --lmcode FILE [FILE ...] | Load and verify all bytecode files against the embedded schema, then run each slot in order |
| lmweather --dry-run --lmcode FILE [FILE ...] | Load and verify all bytecode files and schema contracts without running simulations or writing files |
Environment variables
| Variable | Default | Description |
|---|---|---|
| LMWEATHER_MAX_MEMORY_MB | 4096 | Total host memory ceiling in MiB; allocations beyond this limit stop execution with exit code 3 |
| LMCODE_INVOCATION_FILE | unset | Internal SDK invocation metadata path supplied automatically by run_lmcode |
Context objects
| Name | Type | Description |
|---|---|---|
| wx | Wx | Root weather and climate dynamics context shared across bytecode blocks in one invocation |
Wx methods
| Method signature | Description |
|---|---|
| Wx.sphere(T: int) -> Sphere | Create an Earth-scaled spectral shallow-water sphere at triangular truncation T in [4, 170] |
| Wx.planet(T: int, radius: float, omega: float, g: float) -> Sphere | Create a spectral shallow-water sphere at truncation T with custom radius (m), rotation omega (rad/s), and gravity g (m/s^2) |
| Wx.plane(nx: int, ny: int, Lx: float, Ly: float) -> Plane | Create a staggered C-grid beta-plane channel with nx by ny cells and physical dimensions Lx by Ly (m) |
| Wx.assert_close(actual: float, expected: float, tol: float) -> void | Assert that actual and expected are finite and differ by at most non-negative tol |
| Wx.assert_true(cond: bool) -> void | Assert that cond is true, raising a run error on false |
| Wx.print(msg: string) -> void | Write a diagnostic message line to stderr |
| Wx.save_text(path: string, text: string) -> void | Write arbitrary text content to path |
| Wx.version() -> string | Return the lmweather version string |
Sphere methods
| Method signature | Description |
|---|---|
| Sphere.williamson1(alpha: float) -> Sphere | Initialize Williamson TC1 cosine-bell passive tracer and solid-body winds at tilt alpha (radians) in advect_only mode |
| Sphere.williamson2(alpha: float) -> Sphere | Initialize Williamson TC2 steady global nonlinear geostrophic flow at rotation axis tilt alpha (radians) |
| Sphere.williamson5() -> Sphere | Initialize Williamson TC5 zonal flow over a 2000 m conical mid-latitude mountain |
| Sphere.williamson6() -> Sphere | Initialize Williamson TC6 Rossby-Haurwitz wave 4 |
| Sphere.fields(h: string, u: string, v: string) -> Sphere | Initialize fluid thickness h (m) and wind components u, v (m/s) from expressions in lon, lat (radians) |
| Sphere.orography(hs: string) -> Sphere | Set surface mountain height hs (m) from an expression in lon, lat (radians) |
| Sphere.tracer(q: string) -> Sphere | Initialize a passive scalar tracer field q from an expression in lon, lat (radians) |
| Sphere.advect_only() -> Sphere | Freeze dynamical winds and height so only the passive tracer q is advected |
| Sphere.mode(n: int, m: int, amp: float, depth: float) -> Sphere | Initialize a single spherical-harmonic height perturbation Y_n^m of amplitude amp (m) on resting depth (m) |
| Sphere.perturb(amp: float, seed: int, max_wave: int) -> Sphere | Add seeded deterministic spectral height perturbations up to degree max_wave with amplitude amp (m) |
| Sphere.tilt(alpha: float) -> Sphere | Tilt the planetary rotation axis in the Coriolis parameter by angle alpha (radians) |
| Sphere.diffusion(nu4: float) -> Sphere | Set del^4 hyperdiffusion coefficient nu4 (m^4/s); default 0 |
| Sphere.mark_reference() -> Sphere | Record the current height and tracer fields as the reference snapshot for error_l2/linf and tracer_error_l2/linf |
| Sphere.run(seconds: float) -> Sphere | Integrate forward by seconds using automatically selected stable_dt() steps |
| Sphere.run_dt(seconds: float, dt: float) -> Sphere | Integrate forward by seconds using explicit RK4 step dt (must satisfy the RK4 CFL stability limit) |
| Sphere.stable_dt() -> float | Return a safe RK4 time step (s) based on current maximum gravity-wave and advection speeds |
| Sphere.time() -> float | Return elapsed integration time in seconds since the last state initialization |
| Sphere.truncation() -> int | Return the triangular spectral truncation T |
| Sphere.nlat() -> int | Return the number of Gaussian latitude rings |
| Sphere.nlon() -> int | Return the number of longitude points per ring |
| Sphere.mean_height() -> float | Return global area-weighted mean fluid thickness (m) |
| Sphere.energy() -> float | Return global mean total mechanical energy (kinetic_energy + potential_energy, m^3/s^2) |
| Sphere.kinetic_energy() -> float | Return global area-weighted mean of h * |v|^2 / 2 (m^3/s^2) |
| Sphere.potential_energy() -> float | Return global area-weighted mean of g * h^2 / 2 + g * h * hs (m^3/s^2) |
| Sphere.enstrophy() -> float | Return global area-weighted mean potential enstrophy eta^2 / (2 * h) |
| Sphere.max_wind() -> float | Return maximum wind speed |v| (m/s) on the Gaussian grid |
| Sphere.error_l2() -> float | Return normalized Williamson L2 height error against the reference state |
| Sphere.error_linf() -> float | Return normalized Williamson L-infinity height error against the reference state |
| Sphere.height_at(lat: float, lon: float) -> float | Synthesize exact spectral fluid thickness h (m) at (lat, lon) in degrees |
| Sphere.u_at(lat: float, lon: float) -> float | Synthesize exact zonal wind u (m/s) at (lat, lon) in degrees |
| Sphere.v_at(lat: float, lon: float) -> float | Synthesize exact meridional wind v (m/s) at (lat, lon) in degrees |
| Sphere.vorticity_at(lat: float, lon: float) -> float | Synthesize exact relative vorticity zeta (1/s) at (lat, lon) in degrees |
| Sphere.mode_coefficient(n: int, m: int, part: string) -> float | Return the real ("re") or imaginary ("im") spectral height coefficient for degree n, order m |
| Sphere.wave_crest(m: int, lat: float) -> float | Return the longitude crest (degrees, modulo wavelength) of zonal wavenumber m at latitude lat (degrees) |
| Sphere.tracer_at(lat: float, lon: float) -> float | Synthesize passive tracer value q at (lat, lon) in degrees |
| Sphere.tracer_mean() -> float | Return global area-weighted mean of passive tracer q |
| Sphere.tracer_mass() -> float | Return global area-weighted mean of thickness-weighted tracer h * q |
| Sphere.tracer_min() -> float | Return minimum grid value of passive tracer q |
| Sphere.tracer_max() -> float | Return maximum grid value of passive tracer q |
| Sphere.tracer_error_l2() -> float | Return normalized Williamson L2 tracer error against the reference tracer state |
| Sphere.tracer_error_linf() -> float | Return normalized Williamson L-infinity tracer error against the reference tracer state |
| Sphere.save_csv(path: string) -> void | Write Gaussian grid table (lon lat h u v zeta q hs) grouped by latitude for gnuplot pm3d |
| Sphere.save_zonal_mean(path: string) -> void | Write zonal-mean table (lat h_mean u_mean) across Gaussian latitudes |
| Sphere.save_spectrum(path: string) -> void | Write spherical harmonic energy spectrum (n ke pe) for total wavenumbers n = 1..T |
Plane methods
| Method signature | Description |
|---|---|
| Plane.depth(H: float) -> Plane | Set resting fluid depth H (m); must be called before fields, perturb, or run |
| Plane.gravity(g: float) -> Plane | Set gravitational acceleration g (m/s^2); default 9.80616 |
| Plane.coriolis(f0: float, beta: float) -> Plane | Set reference Coriolis parameter f0 (1/s) and meridional gradient beta (1/(m*s)) |
| Plane.linear() -> Plane | Use equations linearized about resting depth H |
| Plane.nonlinear() -> Plane | Use full nonlinear vector-invariant shallow-water equations (default) |
| Plane.viscosity(nu: float) -> Plane | Set Laplacian kinematic viscosity nu (m^2/s); default 0 |
| Plane.drag(r: float) -> Plane | Set linear Rayleigh bottom drag coefficient r (1/s); default 0 |
| Plane.fields(h_anom: string, u: string, v: string) -> Plane | Initialize height anomaly above H (m) and velocities u, v (m/s) from expressions in x, y (m) |
| Plane.perturb(amp: float, seed: int) -> Plane | Add seeded deterministic smoothed height noise of amplitude amp (m) |
| Plane.run(seconds: float) -> Plane | Integrate forward by seconds using automatically selected stable_dt() steps |
| Plane.run_dt(seconds: float, dt: float) -> Plane | Integrate forward by seconds using explicit RK4 step dt (checked against CFL stability limit) |
| Plane.stable_dt() -> float | Return a safe RK4 time step (s) for the current grid spacing and wave/flow speed |
| Plane.time() -> float | Return elapsed integration time in seconds |
| Plane.wave_speed() -> float | Return linear shallow-water gravity wave speed sqrt(g * H) (m/s) |
| Plane.rossby_radius() -> float | Return Rossby radius of deformation sqrt(g * H) / |f0| (m) |
| Plane.mean_depth() -> float | Return domain-averaged total fluid depth (m) |
| Plane.energy() -> float | Return domain-averaged mechanical energy (kinetic plus available potential, m^3/s^2) |
| Plane.max_speed() -> float | Return maximum flow speed |v| (m/s) across the channel |
| Plane.pv_anomaly_rms() -> float | Return RMS discrete linear potential vorticity anomaly zeta - f0 * (h - H) / H across interior corners |
| Plane.h_at(x: float, y: float) -> float | Return total fluid depth h (m) bilinearly interpolated at (x, y) in meters |
| Plane.u_at(x: float, y: float) -> float | Return zonal velocity u (m/s) interpolated at (x, y) in meters |
| Plane.v_at(x: float, y: float) -> float | Return meridional velocity v (m/s) interpolated at (x, y) in meters |
| Plane.zonal_amplitude(m: int, row: int) -> float | Return Fourier height amplitude (m) of zonal harmonic m along grid row |
| Plane.zonal_crest(m: int, row: int) -> float | Return x position (m, modulo wavelength) of the height crest of zonal harmonic m along grid row |
| Plane.v_zonal_crest(m: int, row: int) -> float | Return x position (m, modulo wavelength) of the meridional velocity crest of zonal harmonic m along grid row |
| Plane.harmonic_energy(m: int) -> float | Return channel-averaged kinetic energy per unit mass (m^2/s^2) in zonal harmonic m |
| Plane.save_csv(path: string) -> void | Write channel grid table (x y h u v zeta) grouped by y for gnuplot pm3d |
| Plane.save_row(j: int, path: string) -> void | Write 1D zonal slice (x h) along 0-based grid row j |
| Plane.save_column(i: int, path: string) -> void | Write 1D meridional slice (y h) along 0-based grid column i |
Exit codes
| Exit code | Phase | Meaning |
|---|---|---|
| 0 | ok | Command or all bytecode slots completed without error |
| 2 | cli | Invalid command-line arguments, contradictory --dry-run flag, or invalid LMWEATHER_MAX_MEMORY_MB value |
| 3 | load / run | Bytecode load failure, schema mismatch, expression syntax error, RK4 CFL stability limit exceeded, non-finite instability, assertion failure, or memory budget exceeded |
| 4 | app | Application error raised with code APP_FAIL |