Interpolation Observation Operators#

ArrayOperator([configs])

This class implements a linear observation operator given its array representation.

SelectionOperator([configs])

This class implements an observation operator that is selects entries of the state vector.

CartesianInterpolator([configs])

An obsevation operator that interpolates prognostic (physics) variables from the model grid to the observation grid points.

Class implementing multiple observation-by-interpolation operators.

  • Selection (restriction) operator, as well as 1D, 2D, 3D interpolation operators in cartesian coordinates are developed.

class ArrayOperatorConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, obs_array=None)[source]#

Bases: ObservationOperatorConfigs

Configuration class for ArrayOperator

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • model (SimulationModel | None) – the simulation model to use

  • obs_array (ndarray | None) – The array/matrix representation of the observation operator

model: SimulationModel | None#
obs_array: ndarray | None#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, obs_array=None)#
class ArrayOperator(configs=None)[source]#

Bases: ObservationOperator

This class implements a linear observation operator given its array representation. The operator is thus both linear and constant.

All functions/methods return a restriction of the states passed as arguments to the observation space by dot product with the underlying array represenation of the observation operator passed upon initialization.

In addition to standard functionality, here we provide a specific attribute ‘design’ which enables modifying the space of the error model by projection or reweighting

  • If the design is a binary vector (bool or int dtype attributes with 0/1 entries) the mean, the covariance, and all random vectors are projected onto the space identified by the 1/True entries.

  • If the design contains non-binary values, the covariance matrix is weighted based on the design as follows. The underlying Cholesky decomposition of the distribution covariance is premultiplied by a design matrix with the design set to its diagonal. This is the standard relaxed OED formulation

__init__(configs=None)[source]#
validate_configurations(configs, raise_for_invalid=True)[source]#

Check the passed configuratios and make sure they are conformable with each other, and with current configurations once combined. This guarantees that any key-value pair passed in configs can be properly used

Note

Here only the locally-defined configurations in ArrayOperatorConfigs are validated. Finally, super classes validators are called.

Parameters:
  • configs – full or partial (subset) configurations to be validated

  • raise_for_invalid – if True raise an error for invalid configrations type/key. Default True

Returns:

flag indicating whether passed configurations dictionary is valid or not

Raises:
observation_vector(init_val=0.0)[source]#

Create an observation vector

Parameters:

init_val (float) – (optional) value assigned to entries of the state vector upon initialization

Returns:

an observation vector identical to state vectors generated by the underlying model

is_observation_vector(observation)[source]#

Test whether the passed observation vector is valid or not

Parameters:

observation – an observation vector

get_observation_grid()[source]#

Return a copy of the observational grid

apply(state)[source]#

Given a state/parameter vector (laid out as defined by the model grid passed upon instantiation), evaluate the observation vector by applying interpolation

Parameters:

state – instance of a model state with entries corresponding the model grid passed upon instantiation

Returns:

an observation vector/instance

Raises:

TypeError is raised if state has the wrong shape,

Jacobian_T_matvec(observation, eval_at=None)[source]#

Multiply (Matrix-free matrix-vector product) of transpose of the Jacobian/tangent-linear (TLM) of the observation operator by the passed observation;

Parameters:
  • observation – observation instance/vector

  • eval_at – state around which observation operator is linearized; ignored here since \(\mathbf{I}\) is linear

Returns:

result of multiplying the transpose of derivative of the observation operator by the passed observation

property shape#

A tuple holding the shape of the observation operator (observation size, model state size)

property extended_design#

Return a vector indicating active/inactive entries (with proper replication for multiple prognostic variables) of the observation vector/range

property design#

Get a copy of the design vector (bool representing active/inactive sensors)

property model#

The underlying simulation model

class SelectionOperatorConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, observation_indexes=None, target='state')[source]#

Bases: ObservationOperatorConfigs

Configuration class for SelectionOperator

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • model (SimulationModel | None) – the simulation model to use

  • observation_indexes (ndarray | None) – indexes of the model state_vector to select.

  • target (str) – either ‘state’ or ‘observation’

model: SimulationModel | None#
observation_indexes: ndarray | None#
target: str#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, observation_indexes=None, target='state')#
class SelectionOperator(configs=None)[source]#

Bases: ObservationOperator

This class implements an observation operator that is selects entries of the state vector. The operator is thus both linear and constant.

All functions/methods return a restriction of the states passed as arguments to the observation indexes

In addition to standard functionality, here we provide a specific attribute ‘design’ which enables modifying the space of the error model by projection or reweighting

  • If the design is a binary vector (bool or int dtype attributes with 0/1 entries) the mean, the covariance, and all random vectors are projected onto the space identified by the 1/True entries.

  • If the design contains non-binary values, the covariance matrix is weighted based on the design as follows. The underlying Cholesky decomposition of the distribution covariance is premultiplied by a design matrix with the design set to its diagonal. This is the standard relaxed OED formulation

Parameters:
  • model – the simulation model to use

  • observation_indexes – indexes of the model state_vector to select.

  • target (str) – either ‘state’ or ‘observation’

__init__(configs=None)[source]#
validate_configurations(configs, raise_for_invalid=True)[source]#

Check the passed configuratios and make sure they are conformable with each other, and with current configurations once combined. This guarantees that any key-value pair passed in configs can be properly used

Note

Here only the locally-defined configurations in SelectionOperatorConfigs are validated. Finally, super classes validators are called.

Parameters:
  • configs – full or partial (subset) configurations to be validated

  • raise_for_invalid – if True raise an error for invalid configrations type/key. Default True

Returns:

flag indicating whether passed configurations dictionary is valid or not

Raises:
observation_vector(init_val=0.0)[source]#

Create an observation vector

Parameters:

init_val (float) – (optional) value assigned to entries of the state vector upon initialization

Returns:

an observation vector identical to state vectors generated by the underlying model

is_observation_vector(observation)[source]#

Test whether the passed observation vector is valid or not

Parameters:

observation – an observation vector

get_observation_grid()[source]#

Return a copy of the observational grid

apply(state)[source]#

Given a state/parameter vector (laid out as defined by the model grid passed upon instantiation), evaluate the observation vector by applying interpolation

Parameters:

state – instance of a model state with entries corresponding the model grid passed upon instantiation

Returns:

an observation vector/instance

Raises:

TypeError is raised if state has the wrong shape,

Jacobian_T_matvec(observation, eval_at=None)[source]#

Multiply (Matrix-free matrix-vector product) of transpose of the Jacobian/tangent-linear (TLM) of the observation operator by the passed observation;

Parameters:
  • observation – observation instance/vector

  • eval_at – state around which observation operator is linearized; ignored here since \(\mathbf{I}\) is linear

Returns:

result of multiplying the transpose of derivative of the observation operator by the passed observation

property shape#

A tuple holding the shape of the observation operator (observation size, model state size)

property extended_design#

Return a vector indicating active/inactive entries (with proper replication for multiple prognostic variables) of the observation vector/range

property design#

Get a copy of the design vector (bool representing active/inactive sensors)

property model#

The underlying simulation model

class CartesianInterpolatorConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model_grid=None, observation_grid=None, method='linear')[source]#

Bases: ObservationOperatorConfigs

Configuration class for CartesianInterpolator

Parameters:
  • verbose (bool) – a boolean flag to control verbosity of the object.

  • debug (bool) – a boolean flag that enables adding extra functionlity in a debug mode

  • output_dir (str | Path) – the base directory where the output files will be saved.

  • model_grid (ndarray | None) – one or two dimensional numpy array holding grid coordinates corresponding to model state entries.

  • observation_grid (ndarray | None) – one or two dimensional numpy array (must be same as model_grid) holding observational coordinates corresponding to observation instance entries.

  • method (str) – interpolation method to use; default is ‘linear’

model_grid: ndarray | None#
observation_grid: ndarray | None#
method: str#
__init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model_grid=None, observation_grid=None, method='linear')#
class CartesianInterpolator(configs=None)[source]#

Bases: ObservationOperator

An obsevation operator that interpolates prognostic (physics) variables from the model grid to the observation grid points.

Remarks:
  • It is assumed in general that there are multiple prognostic variables, thus there must be an assumption about the layout of the model state and the observation entries, specifically whether the prognostic variables (all physics variables) at one grid are stored consecutively, or not. This is determined by inspecting the first two entries of the model grid and the observation grid respectively

  • It is also assumed that all prognostic variables are observed

Warning

All observational grid points must be inside the model domain (we can interpolate, not extrapolate)

Raises:
  • TypeError is raised if either the model grid or the observation grid is not in one/two/three dimensional coordinate systems or if they are not in the same coordinate system

  • TypeError is raised if the model or observation grid have irregular structure; e.g., not all variables are observed;

  • ValueError is raised if the observation grid is not within the model grid domain

__init__(configs=None)[source]#
validate_configurations(configs, raise_for_invalid=True)[source]#

Check the passed configuratios and make sure they are conformable with each other, and with current configurations once combined. This guarantees that any key-value pair passed in configs can be properly used

Note

Here only the locally-defined configurations in CartesianInterpolatorConfigs are validated. Finally, super classes validators are called.

Parameters:
  • configs – full or partial (subset) configurations to be validated

  • raise_for_invalid – if True raise an error for invalid configrations type/key. Default True

Returns:

flag indicating whether passed configurations dictionary is valid or not

Raises:
observation_vector(init_val=0.0)[source]#

Create an observation vector

Parameters:

init_val (float) – (optional) value assigned to entries of the state vector upon initialization

Returns:

a (1d) numpy array with size equal to the range of the observation operator

is_observation_vector(observation)[source]#

Test whether the passed observation vector is valid or not

Parameters:

observation – an observation vector

get_observation_grid()[source]#

Return a copy of the observational grid

apply(state)[source]#

Given a state vector (laid out as defined by the model grid passed upon instantiation), evaluate the observation vector by applying interpolation

Parameters:

state – instance of a model state with entries corresponding the model grid passed upon instantiation

Returns:

an observation vector/instance

Raises:

TypeError is raised if state has the wrong shape,

Jacobian_T_matvec(observation, eval_at=None)[source]#

Multiply (Matrix-free matrix-vector product) of transpose of the Jacobian/tangent-linear (TLM) of the observation operator by the passed observation; The Jacobian is evaluated (for nonlinear operators) at eval_at

Parameters:
  • observation – observation instance/vector

  • eval_at – state around which observation operator is linearized; ignored here for I is linear

Returns:

result of multiplying the transpose of Jacobian of the observation operator by the passed observation

Raises:

TypeError is raised if the passed observation ]

property shape#

A tuple holding the shape of the observation operator (observation size, model state size)

property extended_design#

Return a vector indicating active/inactive entries (with proper replication for multiple prognostic variables) of the observation vector/range

property design#

Get a copy of the design vector (bool representing active/inactive sensors)