controlvects class#

class pycif.utils.classes.controlvects.ControlVect(**kwargs)[source]#

Bases: Plugin

Plugin type for control vector operations in the inversion system.

Handles transformations between control space (optimised parameters), native space (physical model units), and model input files, as well as background error covariance (B-matrix) products.

Concrete implementations live in pycif/plugins/controlvects/.

initiate_template()[source]#

Initialise the ControlVect plugin template.

Loads the registered control-vector module and attaches all standard methods (state2inputs, outputs2state, control2native, native2control, sqrtbprod, sqrtbprod_ad, dump, load, init_structure, init_xb, init_bprod, crop) as bound methods on this instance.

classmethod register_plugin(name, version, module, subtype='', **kwargs)[source]#

Register a module for a plugin and version with possibly options

Parameters:
  • name (str) – name of the plugin

  • version (str) – version of the plugin

  • module (types.ModuleType) – module defining the interface between pyCIF and the plugin

  • plugin_type (str) – type of plugin

  • **kwargs (dictionary) – default options for module

state2inputs(*args, **kwargs)[source]#

Convert the state vector from control space to model input files/arrays.

Maps optimised parameters (control space) to the format expected by the model run files. Must be overridden by each concrete plugin.

Raises:

PluginError – Always, in this default implementation.

outputs2state(*args, **kwargs)[source]#

Convert model outputs back into the state vector (control space).

Inverse of state2inputs(). Must be overridden.

Raises:

PluginError – Always, in this default implementation.

control2native(*args, **kwargs)[source]#

Convert the state vector from control space to physical (native) model units.

Applies any scaling or change of variable needed to go from the optimised parameters to the units used inside the model. Must be overridden.

Raises:

PluginError – Always, in this default implementation.

native2control(*args, **kwargs)[source]#

Convert model-unit quantities back to control space.

Inverse of control2native(). Must be overridden.

Raises:

PluginError – Always, in this default implementation.

sqrtbprod(*args, **kwargs)[source]#

Apply the square-root of the background error covariance: sqrt(B)·v.

Used in variational DA to precondition the minimisation. Must be overridden.

Raises:

PluginError – Always, in this default implementation.

sqrtbprod_ad(*args, **kwargs)[source]#

Apply the adjoint of the sqrt(B) operator: sqrt(B)ᵀ·v.

Adjoint counterpart of sqrtbprod(), required for gradient computation in variational DA. Must be overridden.

Raises:

PluginError – Always, in this default implementation.

dump(*args, **kwargs)[source]#

Serialise the control vector to disk. Must be overridden.

Raises:

PluginError – Always, in this default implementation.

crop(*args, **kwargs)[source]#

Crop the control vector to a sub-domain or time window. Must be overridden.

Raises:

PluginError – Always, in this default implementation.

load(*args, **kwargs)[source]#

Deserialise the control vector from disk. Must be overridden.

Raises:

PluginError – Always, in this default implementation.