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.

Data Assimilation — Ensemble Kalman Filtering with filterax

Authors
Affiliations
University of Valencia

Somax models are forward operators; on their own they only propagate a state. Data assimilation (DA) corrects that state against noisy, sparse observations of reality. This tutorial wires a somax Lorenz '96 model into filterax and runs an Ensemble Transform Kalman Filter (ETKF) twin experiment.

What you’ll learn:

  1. The somax.da adapters that bridge a somax model to a filterax filter

  2. How to set up a twin experiment (truth run + synthetic observations)

  3. How the analysis tracks the truth far better than a free forecast

The somax.da bridge

filterax filters operate on flat state vectors of shape (N_x,), vectorised over an ensemble (N_e, N_x). somax states are equinox pytrees. Three small adapters span that gap:

somax.da objectRole
SomaxDynamicswrap model.step as a filterax.AbstractDynamics
SubsampleObssparse observation operator H(x) = x[indices]
state_to_vectorflatten a state pytree to a vector (+ inverse)
make_ensemblebuild a perturbed flat ensemble around a state

Because the dynamics adapter only relies on model.step(state, dt, *, t0=...), any somax model drops in unchanged.

1. The truth run

We use a 40-variable Lorenz '96 system at F=8F = 8 (fully chaotic). The truth is spun up onto the attractor, then integrated forward in fixed windows of dt = 0.05. This trajectory is what the filter is trying to recover — in a real problem it is unknown.

truth spun up: (40,)

2. Synthetic observations

We observe every other grid point (a 50% sparse network) with additive Gaussian noise of variance obs_var. The observation operator is the linear SubsampleObs; its error covariance R is a diagonal lineax operator.

40 observation windows, 20 obs / window

3. Run the ETKF

The ensemble is seeded by perturbing the (known) initial truth — a stand-in for background uncertainty. ETKF.assimilate then loops forecast → analysis over every window. The forecast step is SomaxDynamics (i.e. the somax model) vectorised over the ensemble; the analysis is filterax’s ETKF update.

mean analysis RMSE: 0.315
mean forecast RMSE: 0.338
observation-noise floor (sqrt obs_var): 0.707

4. Does it work?

Two checks. (a) the per-window RMSE of the analysis sits below the forecast and well under the observation-noise floor — the filter extracts more signal than any single observation carries. (b) the analysis Hovmoller is visually indistinguishable from the truth.

<Figure size 700x400 with 1 Axes>
<Figure size 1200x400 with 4 Axes>

Summary

  • somax.da provides the thin adapter layer (SomaxDynamics, SubsampleObs, state_to_vector, make_ensemble) that lets any somax model be driven by a filterax ensemble filter.

  • In a Lorenz '96 twin experiment the ETKF analysis tracks the truth with RMSE below both the free forecast and the observation-noise floor, from sparse (50%) noisy observations.

  • The same pattern works for the shallow-water and QG models — swap the model and the template state; the bridge is unchanged.

Variational assimilation (vardax 4DVar) with structured gaussx background/observation covariances builds on the same somax.da surface.