dafi.inverse

Collection of ensemble-based Bayesian inversion techniques.

class dafi.inverse.AD_EnKF(inputs_dafi, inputs)[source]

Implementation of the adaptive-stepping ensemble Kalman method (AD_EnKF).

\(x_f\) is the forecasted state vector (by the forward model), \(x_a\) is the updated vector after data-assimilation, \(K\) is the Kalman gain matrix, \(obs\) is the observation vector, and \(Hx\) is the forecasted state vector in observation space.

__init__(inputs_dafi, inputs)[source]

See InverseMethod.__init__() for details.

analysis(iteration, state_forecast, state_in_obsspace, obs, obs_error, obs_vec, corr=None)[source]

Correct the forecast ensemble states using AD-EnKF.

See InverseMethod.analysis() for I/O details.

class dafi.inverse.EnKF(inputs_dafi, inputs)[source]

Implementation of the ensemble Kalman Filter (EnKF).

The EnKF is updated by: \(x_a = x_f + K*(obs - Hx)\) where \(x_f\) is the forecasted state vector (by the forward model), \(x_a\) is the updated vector after data-assimilation, \(K\) is the Kalman gain matrix, \(obs\) is the observation vector, and \(Hx\) is the forecasted state vector in observation space.

__init__(inputs_dafi, inputs)[source]

See InverseMethod.__init__() for details.

analysis(iteration, state_forecast, state_in_obsspace, obs, obs_error, obs_vec)[source]

Correct the forecast ensemble states using EnKF.

See InverseMethod.analysis() for I/O details.

class dafi.inverse.EnKF_MDA(inputs_dafi, inputs)[source]

Implementation of the ensemble Kalman Filter-Multi data assimilaton (EnKF-MDA).

The EnKF-MDA is updated by: \(x_a = x_f + K_{mda}*(obs - Hx - err_{mda})\) where \(x_f\) is the forecasted state vector (by the dynamic model), \(x_a\) is the updated vector after data-assimilation, \(K_{mda}\) is the modified Kalman gain matrix, \(obs\) is the observation vector, \(Hx\) is the forwarded state vector in observation space, and \(err_{mda}\) is the inflated error.

Required inputs in inputs dictionary:

  • nsteps - int Number of steps used in the multiple data assimilation.

__init__(inputs_dafi, inputs)[source]

See InverseMethod.__init__() for details.

analysis(iteration, state_forecast, state_in_obsspace, obs, obs_error, obs_vec)[source]

Correct the forecast ensemble states using EnKF-MDA.

See InverseMethod.analysis() for I/O details.

class dafi.inverse.EnRML(inputs_dafi, inputs)[source]

Implementation of the ensemble Randomized Maximal Likelihood (EnRML).

The EnRML is updated by: \(x_a = x_f + GN*(obs - Hx)+PN\) where \(x_f\) is the forecasted state vector (by the forward model), \(x_a\) is the updated vector after data-assimilation, \(GN\) is the Gauss-Newton matrix, \(obs\) is the observation vector, \(Hx\) is the forecasted state vector in observation space, and \(PN\) is the penalty matrix.

Required inputs in inputs dictionary:

  • step_length - float EnRML step length parameter. has value between 0 and 1.

__init__(inputs_dafi, inputs)[source]

See InverseMethod.__init__() for details.

analysis(iteration, state_forecast, state_in_obsspace, obs, obs_error, obs_vec)[source]

Correct the forecast ensemble states using EnRML.

See InverseMethod.analysis() for I/O details.

class dafi.inverse.InverseMethod(inputs_dafi, inputs)[source]

Parent class for ensemble-based Bayesian inversion techniques.

Use this as a template to write new inversion classes. To implement a new inverse technique create a child class and override the analysis method.

__init__(inputs_dafi, inputs)[source]

Parse input file and assign values to class attributes.

Parameters:
  • inputs_dafi (dict) – Dictionary containing all the dafi inputs in case the model requires access to this information.

  • inputs (dict) – Dictionary containing required inverse method inputs.

analysis(iteration, state_forecast, state_in_obsspace, obs, obs_error, obs_vec)[source]

Correct the forecast ensemble states to analysis state.

This is the data assimilation step.

Parameters:
  • iteration (int) – Iteration number at current DA time step.

  • state_forecast (ndarray) – Ensemble of forecast states (\(x_f\)). dtype=float, ndim=2, shape=(nstate, nsamples)

  • state_in_obsspace (ndarray) – Ensemble forecast states mapped to observation space (Hx). dtype=float, ndim=2, shape=(nobs, nsamples).

  • obs (ndarray) – Ensemble of (possibly perturbed) observations. dtype=float, ndim=2, shape=(nobs, nsamples)

  • obs_error (ndarray) – Observation error (covariance) matrix. dtype=float, ndim=2, shape=(nobs, nobs)

  • obs_vec (ndarray) – Unperturbed observation vector. This is the actual observation and is the mean of obs. dtype=float, ndim=1, shape=(nobs)

Returns:

state_analysis – Ensemble matrix of updated states (\(x_a\)). dtype=float, ndim=2, shape=(nstate, nsamples)

Return type:

ndarray

class dafi.inverse.REnKF(inputs_dafi, inputs)[source]

Implementation of the regularized ensemble Kalman Filter (REnKF).

Required inputs in inputs dictionary:

  • penalties_python_file (string) - Path to python file that contains penalties (function) that returns a list of dictionaries. Each dictionary represents one penalty and includes: lambda (float), weight_matrix (ndarray), penalty (function), and gradient (function).

__init__(inputs_dafi, inputs)[source]

See InverseMethod.__init__() for details.

analysis(iteration, state_forecast, state_in_obsspace, obs, obs_error, obs_vec)[source]

Correct the forecast ensemble states using REnKF.

See InverseMethod.analysis() for I/O details.