filtering
cuthbertlib.enkf.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/enkf/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). |