pnps.calibrate#
Accuracy harnesses: Richardson step calibration and the observed order.
There is no in-loop error norm in this package — deliberately. A whole-field local
truncation error, the usual adaptive-step control, is blind to the four-wave-mixing
signal living orders of magnitude below the pumps in the same array. Here the error is
controlled on the measured quantity: run the fixed-step propagation at step target h
and h/2 and compare every extracted observable (richardson_metric(), or per save
plane and window with richardson_table()); confirm the expected convergence order
(convergence_order()); then run the production scan at a step size whose metric is
comfortably below the target accuracy.
The propagation is solprop’s Runge-Kutta march (DOPRI5, fifth order) replayed
on a fixed schedule, so a healthy configuration shows an observed order near 5;
the first-Born check that validates the emergent signal independently of any
stepper is pnps.reference.first_born_signal().
Functions
|
Observed convergence order between successive step targets. |
|
Worst peak-normalised observable change between step targets h and h/2. |
|
Tabulate the h against h/2 differences per save plane, window and observable. |
Classes
|
The h against h/2 differences of every observable, per save plane and window. |
- class pnps.calibrate.RichardsonTable(h_target, difference, peak, alias_fraction)[source]#
Bases:
objectThe h against h/2 differences of every observable, per save plane and window.
- Attributes:
- h_targetfloat
The coarser step target
h, m.- differencemapping of str to numpy.ndarray
For each observable of
pnps.simulate.OBSERVABLES, the largest absolute difference over frequency between the h and h/2 runs:(n_z, n_windows)for the windowed spectra,(n_z,)fori_omega_full.- peakmapping of str to numpy.ndarray
The h/2 run’s peak over frequency, the same shapes.
- alias_fractionnumpy.ndarray
The h/2 run’s share of the energy outside the inner momentum box at each plane,
(n_z,)(pnps.observables.Observation.alias_fraction).
- alias_fraction: Float[ndarray, 'n_z']#
- relative(key)[source]#
Return one observable’s differences over its own peaks.
A spectrum with a zero peak (a window dark at the entrance) contributes zero.
- Parameters:
- keystr
An observable of
pnps.simulate.OBSERVABLES.
- Returns:
- numpy.ndarray
difference / peak, the shape ofdifference[key].
- pnps.calibrate.convergence_order(setup, tau, zsave, h_list, *, backend='auto')[source]#
Observed convergence order between successive step targets.
Runs
richardson_metric()for eachhinh_list(typically a halving sequence) and returns the metrics with the pairwise observed orderslog2(D(h_i) / D(h_{i+1})) / log2(h_i / h_{i+1}). The replayed DOPRI5 march shows orders near 5 in its asymptotic regime — this is itself a correctness test of the stepper on your configuration.- Parameters:
- setupSetup
The configuration (
pnps.setup.build_setup()).- taufloat
The delay to probe, in s.
- zsavenumpy.ndarray
Save positions in m.
- h_listlist of float
Step targets in m, decreasing.
- backendstr
Backend registry name in solprop, see
pnps.bridge.build_bridge().
- Returns:
- tuple of numpy.ndarray
(metrics, orders)withlen(orders) == len(h_list) - 1.
- pnps.calibrate.richardson_metric(setup, tau, zsave, h_target, *, backend='auto')[source]#
Worst peak-normalised observable change between step targets h and h/2.
For every save position, window and observable, the difference between the h and h/2 runs is normalised to that spectrum’s peak — the error measure a trace retrieval sees (max abs difference over the trace peak). Bin-relative errors in near-empty spectral wings are deliberately not what this reports: a few-percent wiggle on a 1e-4-of-peak bin is a 1e-6 trace error.
- Parameters:
- setupSetup
The configuration (
pnps.setup.build_setup()).- taufloat
The delay to probe, in s. tau = 0 (maximum beam overlap, strongest nonlinearity) is the worst case; check one large delay as well.
- zsavenumpy.ndarray
Save positions, as for
pnps.simulate.simulate_delay_point().- h_targetfloat
The candidate step target in m.
- backendstr
Backend registry name in solprop, see
pnps.bridge.build_bridge().
- Returns:
- float
D(h)— the maximum peak-normalised difference over everything compared. The production run should use anh_targetwithDcomfortably below the accuracy you need. For the fifth-order march,Dis the h-run’s own error up to a factor32/31and the h/2-run’s error is aboutD/31.
- pnps.calibrate.richardson_table(setup, tau, zsave, h_target, *, backend='auto')[source]#
Tabulate the h against h/2 differences per save plane, window and observable.
The table behind
richardson_metric(), whose number is itsRichardsonTable.worst. Keeping the differences and the peaks apart lets a caller normalise by a trace’s peak over several delays rather than by each spectrum’s own.- Parameters:
- setupSetup
The configuration (
pnps.setup.build_setup()).- taufloat
The delay to probe, in s.
- zsavenumpy.ndarray
Save positions, as for
pnps.simulate.simulate_delay_point().- h_targetfloat
The coarser step target in m.
- backendstr
Backend registry name in solprop, see
pnps.bridge.build_bridge().
- Returns:
- RichardsonTable
The differences, the h/2 run’s peaks and its aliasing proxy.