endas.algorithms.KalmanFilter

class endas.algorithms.KalmanFilter(model, model_tl, model_adj, cache=None, lag=0, forgetting_factor=1.0)

Bases: object

Kalman Filter and Smoother.

assimilate(z, H, R)

Performs assimilation of observations during the analysis update. Please note that assimilate() can only be called from within the analysis step, i.e. between the begin_analysis() and end_analysis() calls.

Parameters:
  • z – Vector of observations.
  • H – Observation operator at time t.
  • R – Observation covariance matrix.

Returns: nothing

begin_analysis(x, P, t)

Begins the analysis update of the Kalman Filter and Smoother. :param x: Forecast (prior) state vector :param P: Forecast (prior) error covariance matrix :param t: Analysis time

Returns: nothing

end_analysis(on_smoother_result=None, result_args=())

Ends the analysis update step and returns the filter analysis solution. Optionally, any available smoother solution is returned as well. If smoothing is enabled and any smoothing soluton is available at this point, on_smoother_result will be called (if not `None) as:

on_smoother_result(xs, Ps, t)

where xs and Ps is the state state vector and error covariance at time t.

Parameters:on_smoother_result – Callable to be executed when smoothing solution is available.

Returns: Tuple (xa, Pa) containing the state vector and error covariance matrix after the update step.

forecast(xb, Pb, Q, dt)

Implements the forecast step of the Kalman Filter.

Parameters:
  • xb – Background state vector
  • Pb – Background error covariance matrix
  • Q – Model error covariance matrix. Can be None for perfect model
  • dt – Time increment. This is simply passed to the model

Returns:

smoother_finish(on_smoother_result, result_args=())

Finalizes any pending smoothing solutions and calls on_smoother_result. For each available smoother solution, on_smoother_result will be called as:

on_smoother_result(xs, Ps, t)

where xs and Ps is the state state vector and error covariance at time t.

Parameters:on_smoother_result – Callable to be executed for all available smoothing solutions.

Returns: nothing