Ensemble Kalman
This sub-repository provides modular functions for ensemble Kalman methods, including the ensemble Kalman filter (EnKF) and ensemble RTS smoother (EnRTS smoother).
The core functions are:
predict: Propagate ensemble members through nonlinear dynamics with additive Gaussian noise.filter_update: Update ensemble members with an observation using the EnKF update equation.smoother_update: Apply one Ensemble Rauch-Tung-Striebel smoother update.
Together, predict and filter_update can be used to perform an online EnKF filtering step.
The EnKF uses an ensemble of particles with a Kalman-style measurement update based on empirical covariances. Unlike the EKF, it does not require Jacobians, while naturally handling nonlinear dynamics.
The EnRTS algorithm provides a smoothing counterpart to the EnKF, based on the RTS smoother. It makes an empirical approximation of the RTS smoother gain, which is applied to the ensemble in a backwards pass to obtain a smoothing distribution. Note that, based on the outputs of the EnKF, the EnRTS step is entirely deterministic.
cuthbertlib.ensemble_kalman.filtering
Implements the Ensemble Kalman Filter (EnKF) predict and update steps.
See Algorithm 10.2, Sanz-Alonso et al., Inverse Problems and Data Assimilation. Based in part on the CD-Dynamax implementation.
ObservationFn = Callable[[Array], Array]
module-attribute
DynamicsFn = Callable[[Array, KeyArray], Array]
module-attribute
predict(key, ensemble, dynamics_fn, inflation=0.0)
Propagate ensemble members through an arbitrary simulator p(x_{t+1} | x_t).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
KeyArray
|
JAX PRNG key. |
required |
ensemble
|
Array
|
Ensemble of state vectors, shape (N, x_dim). |
required |
dynamics_fn
|
DynamicsFn
|
Dynamics function mapping (state, key) -> state. |
required |
inflation
|
float
|
Multiplicative inflation factor applied to ensemble deviations. |
0.0
|
Returns:
| Type | Description |
|---|---|
Array
|
Predicted ensemble, shape (N, x_dim). |
Source code in cuthbertlib/ensemble_kalman/filtering.py
update(key, predicted_ensemble, observation_fn, chol_R, y, perturbed_obs=True)
Update ensemble members with an observation using the EnKF update.
NaNs in y are treated as missing dimensions and are excluded from the
update. When y is entirely NaN, the update is a no-op: the predicted
ensemble is returned unchanged with zero log-likelihood contribution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
KeyArray
|
JAX PRNG key. |
required |
predicted_ensemble
|
Array
|
Predicted ensemble, shape (N, x_dim). |
required |
observation_fn
|
ObservationFn
|
Observation function mapping state -> obs. |
required |
chol_R
|
Array
|
Cholesky factor of the observation noise covariance, shape (y_dim, y_dim). |
required |
y
|
Array
|
Observation vector, shape (y_dim,). NaNs indicate missing dimensions. |
required |
perturbed_obs
|
bool
|
If True, use perturbed observations (stochastic EnKF). If False, use deterministic update. |
True
|
Returns:
| Type | Description |
|---|---|
tuple[Array, ScalarArray]
|
Tuple of (updated_ensemble, log_likelihood). |
Source code in cuthbertlib/ensemble_kalman/filtering.py
cuthbertlib.ensemble_kalman.smoothing
Implements the Ensemble Rauch-Tung-Striebel (EnRTS) smoother update.
Cf. [Raanes (2016)[https://doi.org/10.1002/qj.2728].
update(filtered_ensemble, predicted_ensemble, next_smoothed_ensemble)
Applies one EnRTS smoother update step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
filtered_ensemble
|
Array
|
Filtered ensemble at time t, shape (N, x_dim). |
required |
predicted_ensemble
|
Array
|
Paired forecast ensemble at time t + 1, shape (N, next_x_dim). |
required |
next_smoothed_ensemble
|
Array
|
Smoothed ensemble at time t + 1, shape (N, next_x_dim). |
required |
Returns:
| Type | Description |
|---|---|
tuple[Array, Array]
|
Tuple of the smoothed ensemble at time t and the EnRTS gain. |