Models¶
The seven analysis methods are peers — sibling equinox.Module classes
with no inheritance between them, each owning exactly the assumptions its
math requires. Pick by problem structure: a single analysis time with a
linear observation operator wants OI or
3DVar; an assimilation window with perfect-model
dynamics wants strong-constraint 4DVar; admitting
model error turns that into weak-constraint 4DVar;
the operational linearise-and-iterate formulation with control-variable
transform is incremental 4DVar; and replacing
the inner-loop optimiser with a trained ConvLSTM gives
4DVarNet.
Every model exposes .as_analysis_step(), returning a lightweight wrapper
that satisfies the pipekit-cycle AnalysisStep Protocol —
that is the seam through which all seven plug into
VarDACycle / VarSmootherCycle interchangeably.
Classical methods¶
Closed-form and optimisation-based analyses. OptimalInterpolation is the
linear-Gaussian BLUE solution and refuses non-linear observation operators
at construction; ThreeDVar minimises the same cost iteratively and accepts
non-linear operators; the three 4DVar variants extend the cost over a time
window. IncrementalConfig collects the outer/inner-loop knobs of
IncrementalFourDVar.
vardax — Modular variational data assimilation with learned components.
All public symbols are re-exported from the private _src subpackage so
that user code imports from the top-level namespace:
OptimalInterpolation
¶
Bases: Module
BLUE / OI — closed-form linear-Gaussian analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
obs_op |
Any
|
Observation operator. Must be linear (its
|
prior_mean |
Float[Array, 'T N']
|
Background \(x_b\) of shape |
prior_cov_op |
AbstractLinearOperator
|
Background-error covariance \(B\) as a
|
obs_cov_op |
AbstractLinearOperator
|
Observation-error covariance \(R\) as a
|
cg_atol |
float
|
CG absolute tolerance for the inner solve. |
cg_rtol |
float
|
CG relative tolerance for the inner solve. |
cg_max_steps |
int
|
CG iteration cap. |
Examples:
With \(B = R = I\), identity \(H\) and everything observed, the analysis splits the innovation in half: \(x^* = y / 2\).
>>> import jax, jax.numpy as jnp, lineax as lx, vardax
>>> eye = lx.IdentityLinearOperator(jax.ShapeDtypeStruct((1, 3), jnp.float32))
>>> oi = vardax.OptimalInterpolation(
... obs_op=vardax.MaskedIdentity(),
... prior_mean=jnp.zeros((1, 3)),
... prior_cov_op=eye,
... obs_cov_op=eye,
... )
>>> batch = vardax.Batch1D(input=jnp.ones((1, 1, 3)), mask=jnp.ones((1, 1, 3)))
>>> xa = oi(batch)
>>> xa.shape
(1, 1, 3)
>>> bool(jnp.allclose(xa, 0.5, atol=1e-4))
True
Source code in src/vardax/_src/models/optimal_interpolation.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
as_analysis_step
¶
ThreeDVar
¶
Bases: Module
3D variational analysis.
Attributes:
| Name | Type | Description |
|---|---|---|
obs_op |
Any
|
Observation operator (linear or nonlinear). |
prior_mean |
Float[Array, 'T N']
|
Background \(x_b\) of shape |
prior_cov_op |
AbstractLinearOperator
|
\(B\). |
obs_cov_op |
AbstractLinearOperator
|
\(R\). |
minimiser |
AbstractMinimiser
|
|
minimiser_adjoint |
AbstractAdjoint
|
|
max_steps |
int
|
Iteration cap on the inner solver. |
Examples:
With \(B = R = I\), identity \(H\) and everything observed, the analysis agrees with the closed-form BLUE, \(x^* = y / 2\).
>>> import jax, jax.numpy as jnp, lineax as lx, vardax
>>> eye = lx.IdentityLinearOperator(jax.ShapeDtypeStruct((1, 3), jnp.float32))
>>> three = vardax.ThreeDVar(
... obs_op=vardax.MaskedIdentity(),
... prior_mean=jnp.zeros((1, 3)),
... prior_cov_op=eye,
... obs_cov_op=eye,
... )
>>> batch = vardax.Batch1D(input=jnp.ones((1, 1, 3)), mask=jnp.ones((1, 1, 3)))
>>> xa = three(batch)
>>> xa.shape
(1, 1, 3)
>>> bool(jnp.allclose(xa, 0.5, atol=1e-3))
True
Source code in src/vardax/_src/models/threedvar.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
as_analysis_step
¶
StrongFourDVar
¶
Bases: Module
Strong-constraint 4DVar.
Attributes:
| Name | Type | Description |
|---|---|---|
forward |
Any
|
|
obs_op |
Any
|
Observation operator. |
prior_mean |
Float[Array, N]
|
Background \(x_b\) — initial state of shape
|
prior_cov_op |
AbstractLinearOperator
|
\(B\). |
obs_cov_op |
AbstractLinearOperator
|
\(R\). |
minimiser |
AbstractMinimiser
|
|
minimiser_adjoint |
AbstractAdjoint
|
|
forward_adjoint |
Any
|
|
max_steps |
int
|
Iteration cap on the outer solver. |
Examples:
Trivial dynamics (\(M_t(x) = x\)) and a single timestep reduce strong 4DVar to 3DVar, so with \(B = R = I\) the analysis is \(x_0^* = y / 2\).
>>> import jax, jax.numpy as jnp, lineax as lx, vardax
>>> class Identity:
... dt = 1.0
...
... def step(self, x, dt):
... return x
>>> eye = lx.IdentityLinearOperator(jax.ShapeDtypeStruct((3,), jnp.float32))
>>> strong = vardax.StrongFourDVar(
... forward=Identity(),
... obs_op=vardax.MaskedIdentity(),
... prior_mean=jnp.zeros(3),
... prior_cov_op=eye,
... obs_cov_op=eye,
... )
>>> batch = vardax.Batch1D(input=jnp.ones((1, 1, 3)), mask=jnp.ones((1, 1, 3)))
>>> strong(batch).shape
(1, 3)
Source code in src/vardax/_src/models/strong_fourdvar.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
WeakFourDVar
¶
Bases: Module
Weak-constraint 4DVar with augmented control vector.
Attributes:
| Name | Type | Description |
|---|---|---|
forward |
Any
|
|
obs_op |
Any
|
Observation operator. |
prior_mean |
Float[Array, N]
|
Background \(x_b\) — initial state |
prior_cov_op |
AbstractLinearOperator
|
\(B\). |
obs_cov_op |
AbstractLinearOperator
|
\(R\). |
model_err_cov_op |
AbstractLinearOperator
|
\(Q\) — covariance of the per-step model error \(\eta_t\). Defaults to identity scaled by a small variance if not supplied (effectively strong-constraint with a tiny relaxation). |
minimiser |
AbstractMinimiser
|
As in |
minimiser_adjoint |
AbstractAdjoint
|
As in |
max_steps |
int
|
As in |
Examples:
Trivial dynamics and a single timestep: no model-error steps remain (\(T = 0\)) and the analysis initial state reduces to the 3DVar / BLUE answer \(x_0^* = y / 2\) for \(B = R = I\).
>>> import jax, jax.numpy as jnp, lineax as lx, vardax
>>> class Identity:
... dt = 1.0
...
... def step(self, x, dt):
... return x
>>> eye = lx.IdentityLinearOperator(jax.ShapeDtypeStruct((3,), jnp.float32))
>>> weak = vardax.WeakFourDVar(
... forward=Identity(),
... obs_op=vardax.MaskedIdentity(),
... prior_mean=jnp.zeros(3),
... prior_cov_op=eye,
... obs_cov_op=eye,
... model_err_cov_op=eye,
... )
>>> batch = vardax.Batch1D(input=jnp.ones((1, 1, 3)), mask=jnp.ones((1, 1, 3)))
>>> x0_star, eta_star = weak(batch)
>>> x0_star.shape, eta_star.shape
((1, 3), (1, 0, 3))
Source code in src/vardax/_src/models/weak_fourdvar.py
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 | |
IncrementalFourDVar
¶
Bases: Module
Operational incremental 4DVar (Decision D11).
Functionally equivalent to StrongFourDVar
(same problem, same answer in the converged limit) but with a
specialised inner solver: Gauss-Newton outer iterations and CG
inner iterations on the linearised cost. Use this for production /
long-window 4DVar.
Attributes:
| Name | Type | Description |
|---|---|---|
forward |
Any
|
|
obs_op |
Any
|
Observation operator. |
prior_mean |
Float[Array, N]
|
Background \(x_b\) — initial state |
prior_cov_op |
AbstractLinearOperator
|
\(B\). |
obs_cov_op |
AbstractLinearOperator
|
\(R\). |
config |
IncrementalConfig
|
Examples:
Trivial dynamics (\(M_t(x) = x\)) and a single timestep reduce the problem to 3DVar, so with \(B = R = I\) the converged analysis is \(x_0^* = y / 2\).
>>> import jax, jax.numpy as jnp, lineax as lx, vardax
>>> class Identity:
... dt = 1.0
...
... def step(self, x, dt):
... return x
>>> eye = lx.IdentityLinearOperator(jax.ShapeDtypeStruct((3,), jnp.float32))
>>> inc = vardax.IncrementalFourDVar(
... forward=Identity(),
... obs_op=vardax.MaskedIdentity(),
... prior_mean=jnp.zeros(3),
... prior_cov_op=eye,
... obs_cov_op=eye,
... )
>>> batch = vardax.Batch1D(input=jnp.ones((1, 1, 3)), mask=jnp.ones((1, 1, 3)))
>>> xa = inc(batch)
>>> xa.shape
(1, 3)
>>> bool(jnp.allclose(xa, 0.5, atol=1e-2))
True
Source code in src/vardax/_src/models/incremental_fourdvar.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 | |
IncrementalConfig
¶
Bases: Module
Configuration for IncrementalFourDVar.
Attributes:
| Name | Type | Description |
|---|---|---|
n_outer |
int
|
Number of Gauss-Newton outer iterations (typical: 3). |
n_inner |
int
|
Max CG iterations per outer (typical: 20-50). |
cg_atol |
float
|
CG absolute tolerance. |
cg_rtol |
float
|
CG relative tolerance. |
Source code in src/vardax/_src/models/incremental_fourdvar.py
Learned solvers — 4DVarNet¶
End-to-end-trainable 4DVar: the variational cost is kept explicit, but the
inner-loop descent direction is produced by a ConvLSTM
gradient modulator instead of a hand-tuned optimiser. The 1D
variant operates on Batch1D (e.g. Lorenz-96 trajectories); the 2D variant
on Batch2D / Batch2DMultivar fields (e.g. SSH reconstruction). The
inner-loop iteration functions live on the
Costs, Priors & Solvers page; training utilities on
Training & Adjoints.
vardax — Modular variational data assimilation with learned components.
All public symbols are re-exported from the private _src subpackage so
that user code imports from the top-level namespace:
FourDVarNet1D
¶
Bases: Module
End-to-end 4DVarNet model for 1-D spatiotemporal reconstruction.
Minimises the variational cost
using n_solver_steps learned gradient steps modulated by a ConvLSTM,
with the differentiation strategy selected by solver_adjoint.
Attributes:
| Name | Type | Description |
|---|---|---|
n_solver_steps |
int
|
Number of solver iterations to unroll. |
alpha |
float
|
Gradient step-size. |
prior_weight |
float
|
Weight \(\lambda\) for the prior cost term. |
solver_adjoint |
AbstractAdjoint
|
|
prior |
BilinAEPrior1D
|
BilinAEPrior1D learned prior. |
grad_mod |
ConvLSTMGradMod1D
|
ConvLSTMGradMod1D learned gradient modulator. |
Source code in src/vardax/_src/model.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 | |
as_analysis_step
¶
FourDVarNet2D
¶
Bases: Module
End-to-end 4DVarNet model for 2-D spatiotemporal reconstruction.
Attributes:
| Name | Type | Description |
|---|---|---|
n_solver_steps |
int
|
Number of solver iterations to unroll. |
alpha |
float
|
Gradient step-size. |
prior_weight |
float
|
Weight for the prior cost term. |
solver_adjoint |
AbstractAdjoint
|
|
prior |
BilinAEPrior2D
|
BilinAEPrior2D learned prior. |
grad_mod |
ConvLSTMGradMod2D
|
ConvLSTMGradMod2D learned gradient modulator. |
Source code in src/vardax/_src/model.py
183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 | |