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.

One data-assimilation window, rung by rung

GeoStack · background · the role ladder · worked example: ocean

Abstract

The role ladder climbed on one job: a 10-day local ETKF analysis of sea-surface height and currents over the North Atlantic. Each rung gets one diagram and the window’s pieces on it, from the ensemble at the bottom to the assimilation cycle at the top, with the observation plan built once beside the ladder and a nightly run over every window above it. The trace-gas example climbs the same ladder on a different science, with the same sections in the same order.

Keywords:role ladderdata assimilationlocal ETKFlocalisationobservation operatorocean

The running example

The problem: a script with no address

The first version of the window is one script: read the GLORYS background and regrid it, read the altimetry and SWOT passes, build the interpolation weights, split the domain into patches, loop over patches doing the analysis with a hard-coded Gaspari–Cohn taper, stitch the patches back, write the result. It runs. Then the three ordinary requests arrive:

  1. Reuse. The forecast step needs the same interpolation weights to compare the model with the observations. The weights live inside the loop.

  2. Swap. Someone wants a Gaussian taper, or a different patch decomposition. The taper is a formula in the middle of the loop.

  3. Save. Last month’s run used a 300 km cutoff and 32 members, or was it 24? The settings are variables in the script, and the script has changed since.

The rest of the page gives every piece of that script a rung.

The ladder at a glance

Each rung with its grammar, one piece from the window, and the parallel tool that attaches there. The dashed line is the jit boundary.

rung · grammar · running example

parallel tool

orchestration · not a rungrun the DA cycle over every window, nightly

Airflow, daskover windows

⑥ recipe · paragraphDACycle: read | split | analyse | combine | write

the stage chain

⑤ step · sentence + settingsLocalETKF(cutoff_km=300), Reproject(…)

map_blocksone step per chunk

carriers above · arrays belowjit boundary: unwrap π\pi, compute, rewrap ι\iota

④ algorithm · sentencelocal_etkf(patch, obs_plan, y)

vmap , shardingover patches

③ model · noun phraseobs plan (WH,VH)(\mat{W}_H, \mat{V}_H), Background

state built once, shipped

② strategy · adverbGaspariCohn(c)(c), CGSolver, OverlapAdd

settings only: swappable

① primitive · verbgather, eigh, solve, segment_sum

fused by XLA

⓪ structure · nounensemble (member, field, y, x), a PSD operator

the batched axis

apply context

setup · beside the ladderinterp_plan(grid, obs), Background.fit (…)builds ③’s state once, NumPy, float64

ProcessMap(spawn)

Colour is the execution context: blue outside the trace, teal inside, amber built once. The dashed arrow is setup building the model’s state.

⓪ Structure: the noun

What the verbs act on: the data (a plain array, a named array, a carrier) and the library’s own objects. It does nothing on its own; it records what something is. Explain it by its shape, its unit, and the one fact it remembers that a plain array would lose.

ensemble(member, field, y, x)m, ∘C, psu\mathrm{m},\ {}^{\circ}\mathrm{C},\ \mathrm{psu}

ρ⊙Σx\gmat{\rho} \odot \gmat{\Sigma}_xremembers: banded, PSD, never dense

crs transform fillGeoArrayremembers: where on Earth, what is nodata

Three nouns of the window, each with the one fact it remembers.

Kinda Module, or a third-party array
How to tellit is passed to things and does nothing on its own
In the windowXt∣t−1\mat{X}_{t \mid t-1} (57 600 × 32), the localised covariance as a structured operator, the analysis GeoArray, the observation table
Goes wrong whenit computes a result on construction (a model in disguise), or is built from data by expensive work with no setup step

① Primitive: the verb

One call on a noun, dispatched on its structure, with no state and no knowledge of the method that calls it. Explain it with one equation and one line: what goes in, what comes out, what it costs, and which structures give it a fast path.

x\vect{x}(field, y, x)

gather(x,WH,VH)(\vect{x}, \mat{W}_H, \mat{V}_H)∑j=18wijxVij\sum_{j=1}^{8} w_{ij} x_{V_{ij}}

Hx\mat{H}\vect{x}(obs,)

no state · O(obs⋅8)\mathcal{O}(\text{obs} \cdot 8) · same call for every member under vmap

gather is the observation operator as a verb: Hx=∑j=18wijxVij\mat{H}\vect{x} = \sum_{j=1}^{8} w_{ij} x_{V_{ij}}, where jj indexes the eight taps of an observation.

Kinda function: pure, arrays in and out, parameters on every call
How to tellit knows its noun and nothing about the method; gather knows weights and indices, not ensembles
In the windowgather (H\mat{H}), segment_sum (H⊤\mat{H}^\top), eigh, solve, great-circle distance; on the host, geocatalog.query and write_cog
Goes wrong whena flag changes its numerics: it has swallowed an adverb, so pass a strategy instead

② Strategy: the adverb

How a verb is done: settings only, no data, chosen by the caller. Swap it for another of its family and the mathematical statement of the result is unchanged; only cost, accuracy or stability moves. Explain it as a family and a trade.

local_etkf(…, taper=?)Σε,loc−1=diag(ρy)Σε−1\gmat{\Sigma}_{\varepsilon,\text{loc}}^{-1} = \op{diag}(\gvect{\rho}_y) \gmat{\Sigma}_\varepsilon^{-1}

Gaspari–Cohn

Gaussian

box-car

Same algorithm, same statement of the analysis; the taper changes how smoothly far observations fade, not what is computed.

Kinda Module whose fields are settings
How to tellit holds no data from the problem, and a sibling can replace it
In the windowthe taper ρ\rho with cutoff 300 km; the eigen-solve (eigh or a Cholesky); SphericalCap for split; OverlapAdd for combine; LocalCache for stage
Goes wrong whenit stores fitted values (now a model), or is filed with the algorithms so nobody knows it is swappable

③ Model: the noun phrase

A noun with meaning and state: it holds fields θ\gvect{\theta} and a state ψ\gvect{\psi} that a setup step built once. It exists so that two algorithms can share the state. Explain it by what it represents, what its state is, and what builds it.

setupinterp_plan(grid, obs)

obs planθ\gvect{\theta}: method = bilinearψ\gvect{\psi}: WH\mat{W}_H (obs, 8)ψ\gvect{\psi}: VH\mat{V}_H (obs, 8)

Hx\mat{H}\vect{x} (gather)

H⊤r\mat{H}^\top \vect{r} (scatter)

built once in float64, read by the forward map and its adjoint

The plan is built once in float64 and read by the forward map and its adjoint.

Kinda Module: setup may do untraceable work; the call afterwards is pure and jittable
How to tellit means something (“this observation network on this grid”) and it remembers something between calls
In the windowthe obs plan WH,VH\mat{W}_H, \mat{V}_H; the GLORYS → model plan; a Background with xˉt∣t−1\bar{\vect{x}}_{t \mid t-1} and anomalies; the land mask
Goes wrong whenit also runs the method (split it, and the second user of the state appears), or it holds a carrier

④ Algorithm: the sentence

A method over models, as a function: do this, to that, this way. It takes models, data and strategies and holds nothing itself; it is where general machinery becomes someone’s method. Write it last, using only the pieces already named. The local ETKF analysis in one patch Hunt et al., 2007, with ensemble mean xˉt∣t−1\bar{\vect{x}}_{t \mid t-1}, anomalies X~t∣t−1\tilde{\mat{X}}_{t \mid t-1}, observation anomalies Y~=HX~t∣t−1\tilde{\mat{Y}} = \mat{H}\tilde{\mat{X}}_{t \mid t-1}, observations y\vect{y}, observation error Σε\gmat{\Sigma}_\varepsilon, taper weights ρy\gvect{\rho}_y and NEN_{\mathcal{E}} members, at assimilation step tt:

Σε,loc−1=diag(ρy)Σε−1\gmat{\Sigma}_{\varepsilon,\text{loc}}^{-1} = \op{diag}(\gvect{\rho}_y) \gmat{\Sigma}_\varepsilon^{-1}
Σa=((NE−1)I+Y~⊤Σε,loc−1Y~)−1\gmat{\Sigma}_a = ((N_{\mathcal{E}} - 1) \mat{I} + \tilde{\mat{Y}}^\top \gmat{\Sigma}_{\varepsilon,\text{loc}}^{-1} \tilde{\mat{Y}})^{-1}
aˉ=ΣaY~⊤Σε,loc−1(y−Hxˉt∣t−1)\bar{\vect{a}} = \gmat{\Sigma}_a \tilde{\mat{Y}}^\top \gmat{\Sigma}_{\varepsilon,\text{loc}}^{-1} (\vect{y} - \mat{H}\bar{\vect{x}}_{t \mid t-1})
A=((NE−1)Σa)1/2\mat{A} = ((N_{\mathcal{E}} - 1) \gmat{\Sigma}_a)^{1/2}
Xt∣t=xˉt∣t−11NE⊤+X~t∣t−1(aˉ1NE⊤+A)\mat{X}_{t \mid t} = \bar{\vect{x}}_{t \mid t-1} \vect{1}_{N_{\mathcal{E}}}^\top + \tilde{\mat{X}}_{t \mid t-1} (\bar{\vect{a}} \vect{1}_{N_{\mathcal{E}}}^\top + \mat{A})

Where

SymbolMeaningShapeUnit
xˉt∣t−1,X~t∣t−1\bar{\vect{x}}_{t \mid t-1}, \tilde{\mat{X}}_{t \mid t-1}background mean and anomalies in the patch(state,), (state, member)m, m s⁻¹
Y~,y\tilde{\mat{Y}}, \vect{y}observation anomalies and observations in the halo(obs, member), (obs,)m
H\mat{H}observation operator (gather)(obs, state)—
Σε,ρy\gmat{\Sigma}_\varepsilon, \gvect{\rho}_yobservation-error covariance (diagonal) and taper weight per observation(obs, obs), (obs,)m², —
Σa,aˉ,A\gmat{\Sigma}_a, \bar{\vect{a}}, \mat{A}analysis covariance and weights in ensemble space(member, member), (member,), (member, member)—
Xt∣t,1NE\mat{X}_{t \mid t}, \vect{1}_{N_{\mathcal{E}}}analysis ensemble; a vector of ones(state, member), (member,)m, m s⁻¹; —

This page stores the members as columns, shape (state, member), which is the transpose of the standard’s rows, so the products above act on the right of the anomalies.

⓪ Xt∣t−1,y,Σε\mat{X}_{t \mid t-1}, \vect{y}, \gmat{\Sigma}_\varepsilon

① gather, eigh

② taper ρ\rho

③ obs plan

local_etkf④ holds nothing

Xt∣t\mat{X}_{t \mid t}

Every input of local_etkf sits on a lower rung; the algorithm itself holds nothing.

Kinda function
How to tellit takes models and strategies and holds nothing; if a line needs a piece not yet named, the explanation is missing one
In the windowlocal_etkf per patch; average_apply (D↓\mat{D}_\downarrow over the GLORYS plan); the model step over Δt\Delta t
Goes wrong whenit builds its own model inside (nothing can share it), or grows keyword flags (strategies waiting to be named)

⑤ Step: a sentence with its own settings

One transformation, ready to chain: an Operator that lifts an algorithm onto a carrier with a JSON config. Geo territory begins here; nothing below a step computes on a carrier. Explain it in three lines: what it unwraps, which algorithm it calls, what it rewraps.

⑤ LocalETKFcfg={cutoff_km:300,… }\mathrm{cfg} = \{\text{cutoff\_km}: 300, \dots\}

GeoArrayensemble

πcfg\pi_\mathrm{cfg}

arrays only · jitvmap(local_etkf)rungs ⓪ to ④

ιcfg\iota_\mathrm{cfg}

GeoArraysame grid

obs enter as a call argument, not a field, so a graph can wire them

The config never reaches the algorithm: cfg→θ\mathrm{cfg} \to \gvect{\theta} happens in the step, as in (1).

Kindan Operator; its config round-trips through JSON
How to tellit carries its own settings and runs alone in a notebook or inside a recipe
In the windowLocalETKF; Reproject(engine="interp"); WriteCOG; a JaxModelOp wrapping the model step
Goes wrong whena second input is a constructor field (a graph cannot wire it), or it computes on the carrier without unwrapping

⑥ Recipe: the paragraph

Steps in order, with their settings, making one job from source to product: a Sequential or a Graph in code, a YAML file as data. It holds configs only and computes nothing of its own. Explain it as boxes and what flows between them, and say why the shape is what it is.

read background

split (SphericalCap)

read obs (own geometry)

plan H\mat{H} (setup)

LocalETKF

combine (OverlapAdd)

write · commit

A Graph, not a chain: two inputs on two geometries meet at one step.

Kindan Operator; as data, pipekit_ops.dumps / loads
How to tellit holds configs only, and can be summarised and saved without any data
In the windowDACycle for one 10-day window, read to commit
Goes wrong whenlogic lives between the steps (it belongs in a step), or a setting is hidden in code so the recipe cannot be written as data

Setup: beside the ladder

Setup builds state from data or geometry, once, outside jit. In the window it builds three models’ state before any analysis runs, caches it per grid pair and ships it to the workers.

setup · onceNumPy, SciPy, pyprojfloat64, concrete

③ obs plan WH,VH\mat{W}_H, \mat{V}_H

③ GLORYS →\to model plan (9 taps)

③ land mask, depth (GEBCO reshape-mean)

cache per grid pair · ship to workers · never rebuild under a trace

Cache per grid pair, ship to workers, never rebuild under a trace.

Orchestration: above the ladder

The unit of work is one 10-day window. The same recipe with the same config runs once per window; a failed window resumes from its journal, and results go to the catalog.

one recipe, one config · unit of work = one 10-day window
window 1
window 2
retry
window 4
window 5
a failed window resumes from PatchJournal; results go to the catalog

One recipe, one config; a failed window is retried and resumes from PatchJournal.

Every piece of the window on its rung

PieceRungKindContext · stageMap properties
ensemble Xt∣t−1\mat{X}_{t \mid t-1} (member, field, y, x)⓪ structurearrayapply · compute—
GeoArray of the analysis⓪ structurecarrierhost I/O · read, write—
geocatalog.query① primitivefunctionhost I/O · query—
gather with the plan, Hx\mat{H}\vect{x}① primitivefunctionapply · computesurjection, gather, linear
eigh of the NE×NEN_{\mathcal{E}} \times N_{\mathcal{E}} matrix① primitivefunctionapply · computeglobal over members, nonlinear
LocalCache, parallel=8② strategyModulehost I/O · stage—
SphericalCap(cutoff_km=300)② strategyModuleparallelism · split—
Gaspari–Cohn taper ρ\rho, cutoff 300 km② strategyModuleapply · compute—
OverlapAdd(taper="cosine")② strategyModuleparallelism · combine—
obs plan WH,VH\mat{W}_H, \mat{V}_H③ modelModulestate from setup · plan; read in apply—
interp_plan, average_plansetup, besidefunctionsetup · plan—
local_etkf④ algorithmfunctionapply · computelossy, local within the cutoff, nonlinear
average_apply, D↓\mat{D}_\downarrow④ algorithmfunctionapply · computesurjection, regrid, linear
Reproject(engine="interp")⑤ stepOperatorsetup then apply · plan, computefrom its algorithm
WriteCOG⑤ stepOperatorhost I/O · write—
DACycle for the window⑥ recipeOperatorall · index to publish—
a nightly run over every windoworchestration, aboveschedulerorchestrate—

Map properties are filled in only where a name computes on arrays: ① primitives and ④ algorithms, inherited by the ⑤ step that wraps them. Strategies hold settings, not data, so they have none; the taper’s locality shows up in the algorithm that uses it.

What the ladder bought, against the three requests of the problem:

RequestHow
Reusethe obs plan is a ③ model built once by setup; the analysis and the forecast comparison both read it
Swapthe taper is a ② strategy: GaspariCohn to Gaussian is one argument, and the statement of the analysis is unchanged
SaveDACycle is a ⑥ recipe: its config (cutoff, members, patch size) is written as data with every window’s result

The local ETKF in seven moves

The explaining recipe applied to the window.

  1. Start from the sentence. Update each patch’s ensemble with the observations in its halo, weighting each observation by its distance.

  2. Name the nouns. The background ensemble Xt∣t−1\mat{X}_{t \mid t-1} (state, member), in m and m s⁻¹; the observations y\vect{y} (obs,) in m; the observation error Σε\gmat{\Sigma}_\varepsilon (obs, obs) in m².

  3. Name the verbs. gather gives Hx=∑j=18wijxVij\mat{H}\vect{x} = \sum_{j=1}^{8} w_{ij} x_{V_{ij}}; eigh gives the symmetric inverse and square root of a 32 × 32 matrix.

  4. Name the adverbs. The taper ρ\rho (Gaspari–Cohn, cutoff 300 km) and the eigen-solve; swapping either changes cost or smoothness, not the statement of the analysis.

  5. Name the noun phrases. The obs plan, whose state WH,VH\mat{W}_H, \mat{V}_H is built once by interp_plan and read by H\mat{H} and H⊤\mat{H}^\top.

  6. Return to the sentence. Write the five equations of the algorithm using only the pieces above. Nothing new appears, so nothing is missing.

  7. Go up only if the reader works there. For a geoscientist: LocalETKF is the step that unwraps the ensemble GeoArray, and DACycle the recipe that splits, analyses and combines. For an ML reader, stop at move 6.

References
  1. Hunt, B. R., Kostelich, E. J., & Szunyogh, I. (2007). Efficient data assimilation for spatiotemporal chaos: A local ensemble transform Kalman filter. Physica D: Nonlinear Phenomena, 230(1–2), 112–126. 10.1016/j.physd.2006.11.008