Foundations to Frontier
Tests
J. Scientific Machine Learning › J7 Inverse Problems and Data Assimilation

Variational data assimilation (3D-Var, 4D-Var)

Data assimilation combines a model forecast with new observations to estimate the current state of a system, as every weather centre does several times a day. Variational methods write this as minimising a cost: distance to the background forecast weighted by its error covariance B, plus distance to the observations weighted by R. 3D-Var does this at one time; 4D-Var fits a whole model trajectory to observations spread over a window, using the adjoint model for the gradient. This page builds both for the chaotic Lorenz-63 system, checks the adjoint, and compares window lengths with full and partial observations.

Level 0: Foundation

★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.

Blending forecasts with observations

A weather forecast drifts away from reality; observations are accurate but sparse and noisy. Data assimilation finds the state that best agrees with both, trusting each according to its known errors. 3D-Var solves this at a single moment. 4D-Var asks a stronger question: which starting state, run forward through the model, best matches all observations over the past few hours? The model’s own dynamics then carry information from observed to unobserved variables.

Inverse problems and data assimilation lab
━ truth━ background━ analysis
Six observations (dots) with error 0.2 correct a background with error 0.5. RMSE: background 0.500, analysis 0.140. The correlation length of B decides how far each observation spreads; the background errors were drawn with length 0.1.
Why engineers care

4D-Var has produced the initial conditions of the ECMWF and other leading weather forecasts since the late 1990s.

📝 Quick check (Level 0)
0/3 answered
  1. 1. Data assimilation combines…
  2. 2. 4D-Var fits…
  3. 3. Each source is trusted according to…

Level 1: Beginner

★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.

By hand

  • Background x_b: the forecast from the previous cycle, with error covariance B.
  • Observations y = H(x) + ε, with observation operator H and error covariance R.
  • 3D-Var: minimise J(x) = ½(x − x_b)ᵀB⁻¹(x − x_b) + ½(y − Hx)ᵀR⁻¹(y − Hx). For linear H the minimiser is x_b + K(y − H x_b) with K = BHᵀ(HBHᵀ + R)⁻¹, the Kalman filter update with a fixed B.
  • 4D-Var: the control variable is the initial state x₀ of a window; the cost sums observation misfits along the model trajectory x_k = M_k(x₀).
  • Adjoint model: the gradient of the 4D-Var cost needs the transposed Jacobians M_kᵀ, run backwards in time; its cost is a small multiple of one forward run.
  • Incremental 4D-Var: linearise about the current trajectory, solve a quadratic problem, update, repeat (Gauss–Newton outer loops).
  • Strong constraint assumes a perfect model; weak constraint adds model error terms.
📝 Quick check (Level 1)
0/3 answered
  1. 1. The 3D-Var gain is…
  2. 2. The 4D-Var control variable is…
  3. 3. The gradient of the 4D-Var cost uses…

Level 2: Intermediate

★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.

Lorenz-63, its tangent-linear model and the adjoint

Exercise 1.

  • The Lorenz-63 system (σ = 10, ρ = 28, β = 8/3) integrated with RK4, Δt = 0.01.
  • The exact Jacobian of each RK4 step (the tangent-linear model), checked against finite differences.
  • The 4D-Var cost and its gradient through the transposed Jacobians, checked against finite differences.

Practice.

  • Test the tangent-linear model and the adjoint before anything else: finite-difference and dot-product tests.
  • Model B carefully: its correlations decide how observations spread in space and between variables.
  • Keep windows short compared with error-growth times, or the cost becomes non-convex.
  • Use outer loops (re-linearisation) for nonlinear models.
  • Tools: OOPS/JEDI and the ECMWF IFS in operations; DAPPER and PyDA for experiments; JAX or PyTorch for automatic adjoints.
import numpy as np

def cost_and_grad(x0, xb, ys, H, Binv, Rinv, every):
    xs, Ms = run(x0, every * len(ys))              # trajectory and Jacobians
    d = x0 - xb; J = 0.5 * d @ Binv @ d; g = Binv @ d
    for j, y in enumerate(ys):
        r = y - H @ xs[(j + 1) * every]
        J += 0.5 * r @ Rinv @ r
        g -= Ms[(j + 1) * every].T @ H.T @ Rinv @ r # adjoint: transposed Jacobian
    return J, g
🐍 Exercise 1: tangent-linear model and adjoint
Implement one RK4 step with its exact Jacobian and the 4D-Var cost with its adjoint gradient, and verify both against finite differences.
📝 Quick check (Level 2)
0/3 answered
  1. 1. The first test of an adjoint code is…
  2. 2. B controls…
  3. 3. The joint system used by NOAA, NASA and others for new DA software:

Level 3: Advanced

★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.

Theory

3D-Var is a Bayesian estimate. With Gaussian errors, J(x) is minus the log posterior of x given the background and the observations. Its minimiser is x_b + K(y − H x_b), and with a fixed B this is a Kalman update without the covariance forecast.

The adjoint. Perturbing x₀ by δ changes x_k by M_k δ, with M_k the product of step Jacobians. The gradient of ½‖y_k − H x_k‖²_R⁻¹ is −M_kᵀHᵀR⁻¹(y_k − H x_k): the transposed Jacobians carry observation misfits back to the start of the window. In Exercise 1 both the Jacobian and the gradient agreed with finite differences to better than one part in a million.

Why windows have limits. Lorenz-63 has a largest Lyapunov exponent of about 0.9, so errors double in about 0.77 time units, and a perturbation of 1e-6 grew to 1.1 within 20 time units. Over long windows the cost develops multiple minima (Pires, Vautard and Talagrand, 1996), and Gauss–Newton from the background can converge to the wrong one.

📝 Quick check (Level 3)
0/3 answered
  1. 1. With Gaussian errors, the 3D-Var cost is…
  2. 2. Lorenz-63 errors double in about…
  3. 3. Long 4D-Var windows suffer from…

Level 4: Expert

★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.

How do cycled 3D-Var and 4D-Var with different window lengths compare on a chaotic system, with all variables observed and with only one observed?

History.

  • Y. Sasaki (1958) proposed variational analysis; L. Gandin (1963) introduced optimal interpolation.
  • F.-X. Le Dimet and O. Talagrand (1986) introduced the adjoint method for 4D-Var.
  • P. Courtier, J.-N. Thépaut and A. Hollingsworth (1994) introduced incremental 4D-Var; ECMWF made it operational in 1997.
  • C. Pires, R. Vautard and O. Talagrand (1996) studied multiple minima in long windows.

Exercise 2. Truth from Lorenz-63; observations every 0.1 time units with error standard deviation 2; B = 4I; 200 cycles; analysis RMSE averaged after the first 40 cycles; 4D-Var with 5 Gauss–Newton iterations, error measured at the end of each window. Seed 0:

method x, y, z observed only x observed
free run 11.0 8.6
3D-Var 1.2 5.2
4D-Var, window 0.1 0.9 1.6
4D-Var, window 0.2 0.83 1.5
4D-Var, window 0.4 0.6 1.3
4D-Var, window 0.8 1.7 2.8
  • Longer windows help up to 0.4 time units: more observations constrain each initial state, and the analysis error falls well below the observation error 2.
  • The 0.8 window got worse; 15 iterations instead of 5 did not fix it (1.8 with all variables observed), consistent with multiple minima rather than slow convergence.
  • Partial observations: with B diagonal, 3D-Var cannot update y and z from x alone (5.2), while 4D-Var infers them through the dynamics (1.3).
  • Seeds 1 and 2: 3D-Var 1.1 and 1.2, 4D-Var window 0.4: 0.62 and 0.68; window 0.8: 2.0 and 0.71. With only x observed: 3D-Var 6.6 and 7.4, window 0.4: 1.6 and 1.3.
🐍 Exercise 2 (research): how do cycled 3D-Var and 4D-Var with different window lengths compare on a chaotic system, with all variables observed and with only one observed?
Cycle 3D-Var and incremental 4D-Var with windows of 0.1 to 0.8 time units on Lorenz-63, with all variables observed and with only x observed.

Variational data assimilation in practice

  • Numerical weather prediction: ECMWF, Météo-France, the UK Met Office and others use 4D-Var or hybrid ensemble–variational methods with around 10⁹ state variables.
  • Ocean and atmospheric chemistry: 4D-Var for ocean state estimation (ECCO) and pollutant sources.
  • Hybrid methods: B blended with ensemble covariances (EnVar) to make it flow-dependent.
  • Machine learning: differentiable models give adjoints automatically, and learned models can replace the forecast step.

References

  1. F.-X. Le Dimet and O. Talagrand (1986). “Variational algorithms for analysis and assimilation of meteorological observations: theoretical aspects.” Tellus A.
  2. P. Courtier, J.-N. Thépaut and A. Hollingsworth (1994). “A strategy for operational implementation of 4D-Var, using an incremental approach.” Quarterly Journal of the Royal Meteorological Society.
  3. C. Pires, R. Vautard and O. Talagrand (1996). “On extending the limits of variational assimilation in nonlinear chaotic systems.” Tellus A.
  4. E. Kalnay (2003). Atmospheric Modeling, Data Assimilation and Predictability. Cambridge University Press.
  5. M. Asch, M. Bocquet and M. Nodet (2016). Data Assimilation: Methods, Algorithms, and Applications. SIAM.