otf.optim.gradient
Modules:
| Name | Description |
|---|---|
adjoint |
|
gradient_computer |
|
sensitivity |
|
Classes:
| Name | Description |
|---|---|
AdjointGradient |
Compute parameter gradients using adjoint-based methods. |
GradientComputer |
Base class for objects that compute gradients of the assimilation error. |
SensitivityGradient |
Compute gradients using sensitivity (forward) equations. |
AdjointGradient
AdjointGradient(
system: BaseSystem,
update_option: UpdateOption = UpdateOption.asymptotic,
solver: tuple[type[SinglestepSolver | MultistepSolver]]
| type[SinglestepSolver | MultistepSolver]
| None = None,
dt: float | None = None,
interval_fraction: float = 1,
)
Bases: GradientComputer
Compute parameter gradients using adjoint-based methods.
Supports different update strategies controlled by UpdateOption.
Initialize an AdjointGradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
BaseSystem
|
|
required |
update_option
|
UpdateOption
|
Which adjoint/update method to use ( |
asymptotic
|
solver
|
tuple[type[SinglestepSolver | MultistepSolver]] | type[SinglestepSolver | MultistepSolver] | None
|
Solver class or tuple of solver classes used when simulation-based
adjoint computation is selected ( |
None
|
dt
|
float | None
|
Time-step used with the solver (required when |
None
|
interval_fraction
|
float
|
Fraction of the input time series to use for gradient computation (value in (0, 1]). |
1
|
Source code in src/otf/optim/gradient/adjoint.py
GradientComputer
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
|
|
required |
Methods:
| Name | Description |
|---|---|
set_weight |
Weight the error using a (positive definite) matrix. |
Source code in src/otf/optim/gradient/gradient_computer.py
set_weight
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 |
required |
Source code in src/otf/optim/gradient/gradient_computer.py
SensitivityGradient
SensitivityGradient(
system: BaseSystem,
update_option: UpdateOption = UpdateOption.last_state,
solver: tuple[type[SinglestepSolver | MultistepSolver]]
| type[SinglestepSolver | MultistepSolver]
| None = None,
dt: float | None = None,
use_unobserved_asymptotics: bool = False,
)
Bases: GradientComputer
Compute gradients using sensitivity (forward) equations.
Different UpdateOptions select how the sensitivity information is
assembled (last state, mean state, mean gradient, or complete simulation).
Initialize a SensitivityGradient.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
system
|
BaseSystem
|
|
required |
update_option
|
UpdateOption
|
Strategy for forming the gradient ( |
last_state
|
solver
|
tuple[type[SinglestepSolver | MultistepSolver]] | type[SinglestepSolver | MultistepSolver] | None
|
Solver class or tuple of solver classes used when the |
None
|
dt
|
float | None
|
Time-step used with the solver (required when |
None
|
use_unobserved_asymptotics
|
bool
|
When True attempt to use asymptotic information from unobserved state components (experimental). |
False
|