pycif.plugins.modes.adjtl_test — API reference#

Configuration reference: adjtl_test plugin

pycif.plugins.modes.adjtl_test.execute.execute(self, **kwargs)[source]#

Dispatch and run the requested adjoint / tangent-linear test.

Builds the perturbation increment dx (or chi in the reduced space) according to incrmode and testspace, then delegates to the appropriate test function based on testtype:

  • 'adj' — full adjoint test via testing_AD_whole().

  • 'tllinearity' — linearity test via testing_TL_linearity().

  • 'tltaylor' — Taylor expansion test via testing_TL_Taylor().

  • 'adj_sym' — symmetry test via testing_AD_symmetry().

Parameters:
  • self (Plugin) – mode plugin carrying all configuration attributes.

  • **kwargs – forwarded verbatim to the individual test functions.

Returns:

for testtype='adj', the adjoint-test ratio expressed in multiples of machine epsilon; None for other test types.

Return type:

float or None

pycif.plugins.modes.adjtl_test.testing_TL.testing_TL_linearity(self, accuracy)[source]#

Verify that the tangent-linear operator is linear: TL(λ·dx) == λ·TL(dx).

Runs the TL operator twice — once for dx and once for λ·dx — and prints the ratio of the two scalar products. The ratio should equal 1 to machine precision for a truly linear operator.

Parameters:
  • self (Plugin) – mode plugin with all configuration attributes.

  • accuracy (float) – machine epsilon (np.finfo(np.float64).eps).

pycif.plugins.modes.adjtl_test.testing_TL.testing_TL_Taylor(self, accuracy)[source]#

Run a Taylor-expansion test of the tangent-linear operator.

Checks the first-order convergence property: ‖H(x + λ·dx) H(x) TL(λ·dx)‖ = O(λ²).

Iterates taylor_iter times, halving λ by factor lambdalin each time, and prints a summary table of norms and ratios.

Parameters:
  • self (Plugin) – mode plugin with all configuration attributes.

  • accuracy (float) – machine epsilon (np.finfo(np.float64).eps).

pycif.plugins.modes.adjtl_test.testing_adj.testing_AD_whole(self, accuracy, testspace, **kwargs)[source]#

Verify the adjoint identity <H·dx, H·dx> == <dx, H*·H·dx>.

Runs either the tangent-linear operator or two finite-difference forward runs (when use_forward is set) to obtain H·dx, then runs the adjoint to obtain H*·H·dx. The two inner products are printed and their relative discrepancy expressed as a multiple of machine epsilon is returned.

Parameters:
  • self (Plugin) – mode plugin with all configuration attributes.

  • accuracy (float) – machine epsilon (np.finfo(np.float64).eps).

  • testspace (str) – 'control' to work in control space or 'chi' to include the square-root-B mapping.

  • **kwargs – forwarded verbatim to the observation operator.

Returns:

floor(|<dx, H*(H·dx)> / <H·dx, H·dx> - 1| / epsilon), the test ratio in multiples of machine accuracy. Values up to a few tens are typically acceptable.

Return type:

float

pycif.plugins.modes.adjtl_test.testing_adj_sym.testing_AD_symmetry(self, accuracy, increments, testspace, **kwargs)[source]#

Check symmetry of the operators H^T H and H^T R^{-1} H.

Computes H^T H u and H^T H v for two independent random vectors u and v and prints the inner products <H^T H u, v> vs <H^T H v, u>. Repeats the check with R^{-1} included.

Parameters:
  • self (Plugin) – mode plugin with all configuration attributes.

  • accuracy (float) – machine epsilon (np.finfo(np.float64).eps).

  • increments (float) – standard deviation used to draw random vectors.

  • testspace (str) – 'control' or 'chi'.

  • **kwargs – forwarded verbatim to the observation operator.

pycif.plugins.modes.adjtl_test.testing_adj_sym.init_random(self, controlvect, **kwargs)[source]#

Draw a random perturbation and store it in controlvect.dx and controlvect.chi.

pycif.plugins.modes.adjtl_test.testing_adj_sym.compute_HtH(self, obsoper, controlvect, obsvect, datei, datef, workdir, include_R=False, **kwargs)[source]#

Apply H^T H (or H^T R^{-1} H) to the current controlvect.dx.

Runs the tangent-linear (or two finite-difference forward runs when use_forward is set) to compute H·dx, optionally applies R^{-1}, then runs the adjoint to produce H^T(R^{-1})H·dx stored in controlvect.dx.

Parameters:
  • self (Plugin) – mode plugin.

  • obsoper – observation operator plugin.

  • controlvect – control vector plugin (dx is read on entry and overwritten on exit).

  • obsvect – observation vector plugin.

  • datei (datetime) – simulation start date.

  • datef (datetime) – simulation end date.

  • workdir (str) – working directory.

  • include_R (bool) – if True, multiply obsvect.dy by R^{-1} before the adjoint run.

  • **kwargs – forwarded verbatim to the observation operator.