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(orchiin the reduced space) according toincrmodeandtestspace, then delegates to the appropriate test function based ontesttype:'adj'— full adjoint test viatesting_AD_whole().'tllinearity'— linearity test viatesting_TL_linearity().'tltaylor'— Taylor expansion test viatesting_TL_Taylor().'adj_sym'— symmetry test viatesting_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;Nonefor 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
dxand 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_itertimes, halvingλby factorlambdalineach 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_forwardis set) to obtainH·dx, then runs the adjoint to obtainH*·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 HandH^T R^{-1} H.Computes
H^T H uandH^T H vfor two independent random vectorsuandvand prints the inner products<H^T H u, v>vs<H^T H v, u>. Repeats the check withR^{-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.dxandcontrolvect.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(orH^T R^{-1} H) to the currentcontrolvect.dx.Runs the tangent-linear (or two finite-difference forward runs when
use_forwardis set) to computeH·dx, optionally appliesR^{-1}, then runs the adjoint to produceH^T(R^{-1})H·dxstored incontrolvect.dx.- Parameters:
self (Plugin) – mode plugin.
obsoper – observation operator plugin.
controlvect – control vector plugin (
dxis 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, multiplyobsvect.dybyR^{-1}before the adjoint run.**kwargs – forwarded verbatim to the observation operator.