Power Observation Operators#
|
Power observation operator takes as input the model state and raise it to a given power. |
|
Exponential observation operator, i.e. observe the exponential of given state. |
|
Create a power observation operator from a simulation model. |
Create a power observation operator from a simulation model. |
Class for implementing oversimplified non-linear observation operators.
- class PowerConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, power=2.0)[source]#
Bases:
ObservationOperatorConfigs
Configuration class for the Power observation operator.
- 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) – an instance of a simulation model derived from
pyoed.models.SimulationModel
power (float) – the power to raise the model state to.
- model: SimulationModel | None#
- power: float#
- __init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None, power=2.0)#
- class Power(configs=None)[source]#
Bases:
ObservationOperator
Power observation operator takes as input the model state and raise it to a given power.
- Parameters:
configs (PowerConfigs | dict | None) – See
PowerConfigs
for more details.- Raises:
NotImplementedError – if the passed model simulates more than one prognostic variable; extensions require proper handling of the design which is on our TODO list.
- 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
PowerConfigs
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:
AttributeError – if any (or a group) of the configurations does not exist in the model configurations
PowerConfigs
.PyOEDConfigsValidationError – if the configurations are invalid and raise_for_invalid is set to True.
- 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
- 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,
- Notes:
The returned value will be nan if the power is non-integral and any of the entries in state is negative.
- 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
- 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 power#
The power used for defining the observation operator
- property model#
The underlying simulation model
- class ExponentialConfigs(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None)[source]#
Bases:
ObservationOperatorConfigs
Configuration class for the
Exponential
observation operator.- 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) – an instance of a simulation model derived from
pyoed.models.SimulationModel
power – the power to raise the model state to.
- model: SimulationModel | None#
- __init__(*, debug=False, verbose=False, output_dir='./_PYOED_RESULTS_', model=None)#
- class Exponential(configs=None)[source]#
Bases:
ObservationOperator
Exponential observation operator, i.e. observe the exponential of given state. The observation is defined as exponent of the passed state.
In addition to standard functionality, here we provide a specific attribute ‘design’ which enables modifying the observation space by projection/selection
If the design is a binary vector (bool or int dtype attributes with 0/1 entries), the observation operator restricts observations to only entries identified by the 1/True entries. This acts like sensor placing/activation where 1 means ON/ACTIVE, and 0 means OFF.
If the design contains non-binary values, it is transformed to boolean flag; any entry in the design variable that’s not zero is set to 1.
- Raises:
NotImplementedError – raised for now if the passed model simulates more than one prognostic variable; extensions require proper handling of the design which is on our TODO list.
- Remarks:
Currently, this implementation assumes a single prognostic variable; that is, the design does not repeat itself on the covariance matrix. This will be provided as needed!
- 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
ExponentialConfigs
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:
AttributeError – if any (or a group) of the configurations does not exist in the model configurations
ExponentialConfigs
.PyOEDConfigsValidationError – if the configurations are invalid and raise_for_invalid is set to True.
- 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
- 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
- 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
- create_Power_observation_operator(model, power)[source]#
Create a power observation operator from a simulation model. The observation operator raises a model state values to a specified power.
- Parameters:
model – a simulation model object; instance of
SimulationModel
power – the power (scalar) used to define the observation operator
- Returns:
an instance of
Power
inistantiated based on the passed simulation model
- create_Exponential_observation_operator(model)[source]#
Create a power observation operator from a simulation model. The observation operator raises a model state values to a specified power.
- Parameters:
model – a simulation model object; instance of
SimulationModel
- Returns:
an instance of
Power
inistantiated based on the passed simulation model