pnps.reduce_numba#
The fused host reduction of a saved plane to the measured spectra and diagnostics.
solprop hands back each saved plane as a read-only host array (pnps.bridge);
this module reduces it, immediately, to an Observation in
one traversal of the state:
all the accumulators of
pnps.observables– per window the collected energy and the on-axis sum with its magnetic closure, plus the energy, the signal region, the two absorber channels and the group-delay band – are filled together, each weighted by the medium’s axial admittance (pnps.flux), with the admittance and the mask-plane radius computed once per element and shared across the windows;the two-stage form (a partial per transverse row, then a reduction over rows in index order) makes the result deterministic and thread-count invariant.
The optional time-window edge diagnostic needs an inverse transform along the
frequency axis. It is computed over blocks of transverse rows with
scipy.fft.ifft(), so it needs a block-sized scratch array rather than a second
field (Config.edge_diagnostic; off by default, when it is reported as NaN).
The numerical reference for everything here is
pnps.extraction.extract_observables() with
pnps.reference.linear_diagnostics() and pnps.reference.time_edge_fraction().
Module Attributes
Fraction of the time window counted as "edge" by the edge diagnostic, split between the two ends (inherited convention). |
Classes
|
Reduce saved planes of one configuration on the host. |
- pnps.reduce_numba.EDGE_FRACTION = 0.05#
Fraction of the time window counted as “edge” by the edge diagnostic, split between the two ends (inherited convention).
- class pnps.reduce_numba.Reducer(tables, kx, windows, energy_prefactor, edge_diagnostic, region)[source]#
Bases:
objectReduce saved planes of one configuration on the host.
Holds the operator and window tables and the small reduction workspace (the per-row partials,
n * n_slots * ntdoubles); nothing field-sized.- Parameters:
- tablesOperatorTables
The operator the diagnostics describe (the bridge’s configured one, see
pnps.bridge.bridge_tables()).- kxnumpy.ndarray
The momentum axis shared by x and y, rad/m.
- windowssequence of WindowSpec
Collection apertures with resolved edge parameters, differing only in diameter.
- energy_prefactorfloat
Converts summed
eta |E|^2to joules (pnps.pulse.energy_prefactor()).- edge_diagnosticbool
Whether to compute the time-window edge fraction (one blocked inverse transform along omega per plane); NaN is reported otherwise.
- regionSignalRegion
The momentum region
i_omega_fullsums (pnps.setup.Setup.signal_region).
- Raises:
- ReductionError
If the windows do not share a centre, mask distance, edge profile and weighting.
- reduce(field)[source]#
Reduce one saved plane to the spectra and the diagnostics.
- Parameters:
- fieldnumpy.ndarray
The state
(n, n, nt), complex128, C-contiguous; only read, so a read-only view of a backend’s live state is fine (reduce it before the backend steps again).
- Returns:
- Observation
The windowed and full spectra, the energy and the diagnostics of the plane.
- Raises:
- ReductionError
If the field has the wrong shape.
- property edge_diagnostic: bool[source]#
Whether the time-window edge fraction is computed (NaN otherwise).
- Returns:
- bool
True when
reduce()computes the edge fraction.
- edge_fraction(field)[source]#
Return the field-norm fraction in the outer edges of the time window.
A blocked inverse transform along omega, so the scratch is one block of rows rather than a field. The ratio is invariant under the transform’s normalisation, and the blocks are summed in row order, so the result does not depend on the block size beyond rounding. It is the one per-plane observable solprop’s statistics cannot form (it is a time-domain quantity), so a field-free run (
Config.reduction = "solprop") still observes the field when it is asked for.- Parameters:
- fieldnumpy.ndarray
The state
(n, n, nt).
- Returns:
- float
The fraction of
EDGE_FRACTIONof the window, split between its ends.