Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Variational Data Assimilation — Strong-Constraint 4DVar with vardax

Authors
Affiliations
University of Valencia

The ensemble-filtering tutorial corrected a somax state with filterax. This one takes the variational route: vardax strong-constraint 4DVar, which finds the initial state x0x_0 whose model trajectory best fits a whole window of observations, regularised toward a background xbx_b:

J(x0)=12 ∥x0−xb∥B−12+12∑t=0T∥yt−Ht Mt(x0)∥Rt−12.J(x_0) = \tfrac{1}{2}\,\|x_0 - x_b\|^2_{B^{-1}} + \tfrac{1}{2}\sum_{t=0}^{T} \|y_t - H_t\,M_t(x_0)\|^2_{R_t^{-1}}.

What you’ll learn:

  1. The somax.da.SomaxForwardModel adapter that exposes a somax model as a vardax ForwardModel

  2. How to build a structured background covariance BB with gaussx

  3. How the 4DVar analysis pulls a poor background toward the truth

The bridge: one adapter, two DA paradigms

vardax’s variational solvers consume a pipekit_cycle.ForwardModel — an object with dt and step(state, dt) — and roll it out over the window with jax.lax.scan on a flat state vector. somax.da.SomaxForwardModel wraps a somax model to that contract (ravel → model.step → unravel), exactly mirroring how SomaxDynamics adapted the same model for filterax’s ensemble filters. The forward model is shared; only the analysis paradigm differs.

1. Truth, model, and the forward adapter

We use a 12-variable Lorenz '96 system at F=8F = 8, spun onto its attractor. SomaxForwardModel wraps the model with a fixed window dt; the template state fixes the flat ↔ pytree layout.

forward model dt: 0.05

2. The observation window

Strong 4DVar fits a trajectory: we roll the truth forward n_steps times and observe every grid point at each time with Gaussian noise. vardax packs the window into a Batch1D of shape (batch, T+1, N) with a validity mask.

observation window: (1, 4, 12)

3. Structured background covariance with gaussx

The background term ∥x0−xb∥B−12\|x_0 - x_b\|^2_{B^{-1}} needs a covariance BB. Rather than a plain diagonal, we build a diagonal + low-rank structure with gaussx.LowRankUpdate — the kind of structured operator gaussx specialises in — then materialise it as a dense PSD operator for vardax’s solver. The low-rank term injects spatial correlations the analysis can exploit.

B condition number: 3.69

4. Run strong-constraint 4DVar

The background is the truth corrupted by a sizeable perturbation — this is what 4DVar has to correct. StrongFourDVar minimises J(x0)J(x_0) over the initial state; gradients flow through the SomaxForwardModel rollout by JAX autodiff.

background RMSE vs truth: 0.2460
analysis   RMSE vs truth: 0.1045
error reduction: 58%

5. Does it work?

The 4DVar analysis sits much closer to the truth than the background it started from — the observation window has pulled x0x_0 back toward reality.

<Figure size 700x400 with 1 Axes>

Summary

  • somax.da.SomaxForwardModel exposes any somax model as a vardax ForwardModel — the same model that drove filterax’s ensemble filters now drives variational 4DVar, no changes required.

  • gaussx supplies structured background/observation covariances (LowRankUpdate here; Kronecker, SVDLowRankUpdate, … are available) as lineax-compatible operators.

  • Strong-constraint 4DVar recovers the initial state from a windowed set of noisy observations, cutting the background error substantially.