Skip to content

otf.optim.gradient.gradient_computer

Classes:

Name Description
GradientComputer

Base class for objects that compute gradients of the assimilation error.

GradientComputer

GradientComputer(system: BaseSystem)

Base class for objects that compute gradients of the assimilation error.

Subclasses implement compute_gradient(observed_true, assimilated).

Create a GradientComputer bound to system.

Parameters:

Name Type Description Default
system BaseSystem

BaseSystem instance for which gradients are computed.

required

Methods:

Name Description
set_weight

Weight the error using a (positive definite) matrix.

Source code in src/otf/optim/gradient/gradient_computer.py
def __init__(self, system: BaseSystem):
    """Create a `GradientComputer` bound to `system`.

    Parameters
    ----------
    system
        `BaseSystem` instance for which gradients are computed.
    """
    self._system = system
    self._weight = None

set_weight

set_weight(weight: jndarray | None)

Weight the error using a (positive definite) matrix.

Use this matrix to weight the error (defined as the two-norm of the difference between the data assimilated system state and the observed portion of true system state). This accordingly weights the derivative of the error with respect to the unknown parameters of the data assimilated system.

If assimilating a system with noisy measurements, it is common to use the inverse of the covariance matrix as the weight.

Parameters:

Name Type Description Default
weight jndarray | None

Square array. Each dimension should be equal to the number of observed variables. Pass None to unset the weight (equivalently, set the weight to the identity).

required
Source code in src/otf/optim/gradient/gradient_computer.py
def set_weight(self, weight: jndarray | None):
    """Weight the error using a (positive definite) matrix.

    Use this matrix to weight the error (defined as the two-norm of the
    difference between the data assimilated system state and the observed
    portion of true system state). This accordingly weights the derivative
    of the error with respect to the unknown parameters of the data
    assimilated system.

    If assimilating a system with noisy measurements, it is common to use
    the *inverse* of the covariance matrix as the weight.

    Parameters
    ----------
    weight
        Square array. Each dimension should be equal to the number of
        observed variables. Pass `None` to unset the weight (equivalently,
        set the weight to the identity).
    """
    self._weight = weight