endas.ObservationOperator

class endas.ObservationOperator

Bases: object

Abstract base class for observation operators.

Observation operators provide mapping from the state space to the observation space. In other words, the operator transforms the state vector to the corresponding set of observations that we would expect.

The operator may be implemented as a (typically sparse) matrix but more abstract implementations are possible too.

is_linear

True if the operator is linear.

shape

Returns the “shape” of the operator as a tuple (k, n), where k is the number of observations this operator represents and n is the state vector size.

localize(selected)

Returns new ObservationOperator for a subset of observations.

Parameters:selected – Array of indexes of observations to select
Returns:An instance of ObservationOperator of shape (s, n), where s = len(selected).
Raises:NotImplementedError – if the operation is not supported by this operator
dot(x, out=None)

Applies the observation operator to an ensemble or state vector.

This implements the matrix product \(\mathbf{H}x\) if H is linear, or more generally \(\mathscr{H}(x)\) for non-linear observation operators. Here \(x\) is an nxN array (i.e. either the ensemble or state vector).

Parameters:
  • x – Vector or matrix of shape nxN to which the operator is applied to, where \(N \geq 1\).
  • out – If supplied, it is used as a buffer for the output instead of allocating new array. The passed array must be of shape kxN, where k=self.shape[0]`.
Returns:

The result as kxN array, where k=self.shape[0].

to_matrix(force_dense=False, out=None)

Returns the matrix form of the operator, if available.

Parameters:
  • force_dense – If True, the returned matrix is always a dense Numpy array. Otherwise a sparse matrix may be returned, if suitable for the observation operator.
  • out – If supplied, it is used as a buffer for the output instead of allocating new array. The passed array must be same shape as self.shape`.
Raises:

NotImplementedError – if the operation is not supported by this covariance operator

Note

Please note that this should only be used on sparse observation operators and exists primarily so that the (Extended) Kalman Filter can be implemented.