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.
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:
Reuse. The forecast step needs the same interpolation weights to compare the model with the observations. The weights live inside the loop.
Swap. Someone wants a Gaussian taper, or a different patch decomposition. The taper is a formula in the middle of the loop.
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 , compute, rewrap
④ algorithm · sentencelocal_etkf(patch, obs_plan, y)
vmap , shardingover patches
③ model · noun phraseobs plan , Background
state built once, shipped
② strategy · adverbGaspariCohn, 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)
remembers: 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.
| Kind | a Module, or a third-party array |
| How to tell | it is passed to things and does nothing on its own |
| In the window | (57 600 × 32), the localised covariance as a structured operator, the analysis GeoArray, the observation table |
| Goes wrong when | it 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.
(field, y, x)
gather
(obs,)
no state · · same call for every member under vmap
gather is the observation operator as a verb: , where indexes the eight taps of an observation.
| Kind | a function: pure, arrays in and out, parameters on every call |
| How to tell | it knows its noun and nothing about the method; gather knows weights and indices, not ensembles |
| In the window | gather (), segment_sum (), eigh, solve, great-circle distance; on the host, geocatalog.query and write_cog |
| Goes wrong when | a 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=?)
Gaspari–Cohn
Gaussian
box-car
Same algorithm, same statement of the analysis; the taper changes how smoothly far observations fade, not what is computed.
| Kind | a Module whose fields are settings |
| How to tell | it holds no data from the problem, and a sibling can replace it |
| In the window | the taper with cutoff 300 km; the eigen-solve (eigh or a Cholesky); SphericalCap for split; OverlapAdd for combine; LocalCache for stage |
| Goes wrong when | it 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 and a state 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: method = bilinear: (obs, 8): (obs, 8)
(gather)
(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.
| Kind | a Module: setup may do untraceable work; the call afterwards is pure and jittable |
| How to tell | it means something (“this observation network on this grid”) and it remembers something between calls |
| In the window | the obs plan ; the GLORYS → model plan; a Background with and anomalies; the land mask |
| Goes wrong when | it 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 , anomalies , observation anomalies , observations , observation error , taper weights and members, at assimilation step :
Where
| Symbol | Meaning | Shape | Unit |
|---|---|---|---|
| background mean and anomalies in the patch | (state,), (state, member) | m, m s⁻¹ | |
| observation anomalies and observations in the halo | (obs, member), (obs,) | m | |
| observation operator (gather) | (obs, state) | — | |
| observation-error covariance (diagonal) and taper weight per observation | (obs, obs), (obs,) | m², — | |
| analysis covariance and weights in ensemble space | (member, member), (member,), (member, member) | — | |
| 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.
⓪
① gather, eigh
② taper
③ obs plan
local_etkf④ holds nothing
Every input of local_etkf sits on a lower rung; the algorithm itself holds nothing.
| Kind | a function |
| How to tell | it takes models and strategies and holds nothing; if a line needs a piece not yet named, the explanation is missing one |
| In the window | local_etkf per patch; average_apply ( over the GLORYS plan); the model step over |
| Goes wrong when | it 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.
⑤ LocalETKF
GeoArrayensemble
arrays only · jitvmap(local_etkf)rungs ⓪ to ④
GeoArraysame grid
obs enter as a call argument, not a field, so a graph can wire them
The config never reaches the algorithm: happens in the step, as in (1).
| Kind | an Operator; its config round-trips through JSON |
| How to tell | it carries its own settings and runs alone in a notebook or inside a recipe |
| In the window | LocalETKF; Reproject(engine="interp"); WriteCOG; a JaxModelOp wrapping the model step |
| Goes wrong when | a 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 (setup)
LocalETKF
combine (OverlapAdd)
write · commit
A Graph, not a chain: two inputs on two geometries meet at one step.
| Kind | an Operator; as data, pipekit_ops.dumps / loads |
| How to tell | it holds configs only, and can be summarised and saved without any data |
| In the window | DACycle for one 10-day window, read to commit |
| Goes wrong when | logic 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
③ GLORYS 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; a failed window is retried and resumes from PatchJournal.
Every piece of the window on its rung¶
| Piece | Rung | Kind | Context · stage | Map properties |
|---|---|---|---|---|
ensemble (member, field, y, x) | ⓪ structure | array | apply · compute | — |
GeoArray of the analysis | ⓪ structure | carrier | host I/O · read, write | — |
geocatalog.query | ① primitive | function | host I/O · query | — |
| gather with the plan, | ① primitive | function | apply · compute | surjection, gather, linear |
eigh of the matrix | ① primitive | function | apply · compute | global over members, nonlinear |
LocalCache, parallel=8 | ② strategy | Module | host I/O · stage | — |
SphericalCap(cutoff_km=300) | ② strategy | Module | parallelism · split | — |
| Gaspari–Cohn taper , cutoff 300 km | ② strategy | Module | apply · compute | — |
OverlapAdd(taper="cosine") | ② strategy | Module | parallelism · combine | — |
| obs plan | ③ model | Module | state from setup · plan; read in apply | — |
interp_plan, average_plan | setup, beside | function | setup · plan | — |
local_etkf | ④ algorithm | function | apply · compute | lossy, local within the cutoff, nonlinear |
average_apply, | ④ algorithm | function | apply · compute | surjection, regrid, linear |
Reproject(engine="interp") | ⑤ step | Operator | setup then apply · plan, compute | from its algorithm |
WriteCOG | ⑤ step | Operator | host I/O · write | — |
DACycle for the window | ⑥ recipe | Operator | all · index to publish | — |
| a nightly run over every window | orchestration, above | scheduler | orchestrate | — |
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:
| Request | How |
|---|---|
| Reuse | the obs plan is a ③ model built once by setup; the analysis and the forecast comparison both read it |
| Swap | the taper is a ② strategy: GaspariCohn to Gaussian is one argument, and the statement of the analysis is unchanged |
| Save | DACycle 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.
Start from the sentence. Update each patch’s ensemble with the observations in its halo, weighting each observation by its distance.
Name the nouns. The background ensemble (state, member), in m and m s⁻¹; the observations (obs,) in m; the observation error (obs, obs) in m².
Name the verbs.
gathergives ;eighgives the symmetric inverse and square root of a 32 × 32 matrix.Name the adverbs. The taper (Gaspari–Cohn, cutoff 300 km) and the eigen-solve; swapping either changes cost or smoothness, not the statement of the analysis.
Name the noun phrases. The obs plan, whose state is built once by
interp_planand read by and .Return to the sentence. Write the five equations of the algorithm using only the pieces above. Nothing new appears, so nothing is missing.
Go up only if the reader works there. For a geoscientist:
LocalETKFis the step that unwraps the ensembleGeoArray, andDACyclethe recipe that splits, analyses and combines. For an ML reader, stop at move 6.
Sources and status
From “Seven rungs, read as grammar” (24 November 2026), which shared its running example with the roles page; the general sections of that page (which rung, the role fixes the kind, the tiers, who works where) are now on the role ladder. The window, its sizes and the names on each rung follow GeoStack’s docs/design/kinds_and_roles.md and the role-ladder skill. Names are sketched: local_etkf, LocalETKF, DACycle, interp_plan, SphericalCap and OverlapAdd describe the design and were not checked against a pinned library for this page, and the page has no notebook behind it. The local ETKF follows Hunt et al. (2007).
- 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