pnps.statistics#
Form this package’s per-plane observables from solprop’s far-field statistics.
With Config.reduction = "solprop" a delay point keeps no field: solprop evaluates
its own statistics at every save plane (SEP 23’s far-field statistics, on SEP 22’s
statistics-only planes) and this module turns them back into this package’s
Observation, in this package’s units. The host reduction
(pnps.reduce_numba) is the reference it is tested against.
Notes#
The mapping. Each observable comes from one solprop statistic, scaled:
observable |
solprop statistic |
scale |
|---|---|---|
|
|
|
|
|
|
|
TG: |
|
|
|
|
|
|
1 |
|
|
|
|
|
|
|
|
ratio |
|
|
ratio |
|
|
|
|
none: a time-domain quantity; stays on the host |
– |
Measure. Both codes measure energy by the medium’s axial flux (solprop’s SEP 34,
pnps.flux): every statistic weights |E|^2 by the admittance eta, as
the host reduction does, so the constants below are the vacuum ones and eta is
already inside both sides.
Units. The state is the unnormalised 3-D DFT of the field in V/m in both codes (they
share the raw-DFT convention, docs/dev/numerics.md), so solprop reads this package’s
state as its own and its statistics are physical: on an envelope grid of n_t samples
at dt, and N = n^2 columns of spacing dx, solprop’s spectral weight is
w = dx^2 / N and its spectral density (dt^2 / 2 pi) |E|^2. Hence
U_S = (eps_0 c / 2) (dx^2 / N) (dt^2 / 2 pi), J/(rad/s) per unit ofsum_c eta |E|^2: a spectrum summed over columns;U_A = (eps_0 c / 2) (dt^2 / 2 pi), J s/m^2 per unit ofRe(A conj(G)): the on-axis spectrum, whose amplitudeA = sum_c alpha_c W Eand closureG(the same sum ofconj(y) E) already carry the1/Nof the on-axis weightalpha_c = (-1)^(ix+iy) / N;U_P = (eps_0 c / 2) (dx^2 / N) (dt / n_t), J/m per unit ofsum r eta |E|^2: the absorbed powers, with solprop’s power ratesr = 2 xthis package’s amplitude rates.
energy needs no constant: (eps_0 c / 2) (dx^2 / N) (dt / n_t) sum eta |E|^2
is exactly pnps.pulse.energy_prefactor() times sum eta |E|^2.
Sign convention. SEP 23’s aperture centres are physical mask-plane positions, and a
stored column at transverse wavevector k travels along -k (SEP 23, equation
(1)). This package’s window centres are in the stored axes (the signal corner is at
(-d, -d) with the beamlets launched at the stored +k corners), so the centres
are negated: X = -holex. The signal quadrant is the stored kx, ky < 0 corner,
upper half of each FFT-ordered axis including the Nyquist column, hence the physical box
[dk/2, inf) x [dk/2, inf): its lower edge lies between the zero column and the first
positive one, so it selects exactly the stored columns n/2 .. n-1.
Module Attributes
The solprop statistics a field-free delay point asks for at every plane. |
Functions
|
Return the windows as a solprop aperture set. |
|
Return the aliasing reading's inner box as one row of |
|
Turn one plane's solprop statistics into this package's observation. |
Return the signal quadrant as one row of solprop's |
|
|
Return why the windows cannot be solprop apertures, or None if they can. |
|
Return the statistics a field-free delay point asks solprop for. |
|
Return why solprop should not reduce these windows, or None if it should. |
Classes
|
The constants that turn solprop's physical statistics into this package's units. |
- pnps.statistics.STATISTICS = ('energy', 'beam_spectrum', 'aperture_spectrum', 'aperture_on_axis_spectrum', 'region_spectrum', 'absorbed_power')#
The solprop statistics a field-free delay point asks for at every plane.
- class pnps.statistics.StatisticsScale(spectrum, on_axis, power)[source]#
Bases:
objectThe constants that turn solprop’s physical statistics into this package’s units.
- Attributes:
- spectrumfloat
U_S, J/(rad/s) per unit ofsum_c |E|^2(module notes).- on_axisfloat
U_A, J s/m^2 per unit of|A|^2.- powerfloat
U_P, J/m per unit ofsum r |E|^2.
- classmethod for_grids(dt, n_t, spectral_weight)[source]#
Form the constants from the grids solprop evaluates on.
- Parameters:
- dtfloat
Time step of the envelope grid, s.
- n_tint
Temporal samples.
- spectral_weightfloat
The solprop transverse spectral weight of one column,
dx^2 / Nin m^2 (FreeGrid.spectral_weights, the same for every column).
- Returns:
- StatisticsScale
The unit constants
U_S,U_AandU_Pfor those grids.
Examples
>>> scale = StatisticsScale.for_grids(1e-16, 64, 1e-12 / 16) >>> round(scale.spectrum / scale.on_axis * 16 / 1e-12, 12) 1.0
- pnps.statistics.aperture_set(windows, signal=None, *, exact=False)[source]#
Return the windows as a solprop aperture set.
The centres are negated into SEP 23’s physical axes (see the module notes). The diameters are the nominal ones under both weightings: solprop applies the quadrature correction of
pnps.beams.quadrature_holediam()itself (its equation (6), with the same second moments).With exact, each window is its hard disc integrated exactly (solprop’s
exactprofile, SEP 53) over the nonlinear part of the field, the state less the input carried by the linear flow, aspnps.exact_windows.ExactWindowsintegrates it on the host. The rendering (apod,weighting) then plays no part. The whole set reduces that part, so the SD signal half-plane does too: no linear light reaches it behind compact input holes, so there it is the field.- Parameters:
- windowssequence of WindowSpec
The collection windows, with resolved edge parameters.
- signaltuple of float or None, optional
The SD signal region as a mask-plane edge and its distance, m (
pnps.geometry.signal_half_plane()), appended as a hardhalf_plane_x_gerow; None for none.- exactbool, optional
The windows as exact hard discs on the nonlinear field (
Config.exact_windows).
- Returns:
- solprop.stats.ApertureSet
One aperture per window, labelled by the trace names, and the signal half-plane last when there is one.
- Raises:
- ReductionError
If the windows cannot be expressed (
statistics_refusal()), or solprop refuses the set (an edge too wide for its hole, say), naming the reason.
- pnps.statistics.inner_box_region(kx)[source]#
Return the aliasing reading’s inner box as one row of
spectral_regions.- Parameters:
- kxnumpy.ndarray
The stored momentum axis shared by x and y, rad/m.
- Returns:
- numpy.ndarray
[[-h, h, -h, h]]withhfrompnps.observables.inner_half_width(); symmetric, so the same in the physical axes.
- pnps.statistics.observation_from_statistics(values, scale, gd_band, edge_fraction, *, signal_row=False)[source]#
Turn one plane’s solprop statistics into this package’s observation.
- Parameters:
- valuesmapping
The solprop statistics at one plane (
STATISTICS), without the batch axis.- scaleStatisticsScale
The unit constants.
- gd_bandnumpy.ndarray
The lap-budget indicator,
(nt,).- edge_fractionfloat
The time-window edge diagnostic, computed on the host (NaN when off).
- signal_rowbool, optional
Whether the signal region is the aperture set’s last row (SD), rather than
region_spectrum(TG).
- Returns:
- Observation
The plane’s spectra and diagnostics in this package’s units.
- pnps.statistics.signal_quadrant_region(kx)[source]#
Return the signal quadrant as one row of solprop’s
spectral_regions.- Parameters:
- kxnumpy.ndarray
The stored momentum axis shared by x and y, FFT-ordered, rad/m.
- Returns:
- numpy.ndarray
[[dk/2, inf, dk/2, inf]]in physical rad/m, which selects exactly the stored columnsn/2 .. n-1of each axis.
- pnps.statistics.statistics_refusal(windows, *, exact=False)[source]#
Return why the windows cannot be solprop apertures, or None if they can.
solprop’s
ApertureSetshares one profile and one weighting across the set and has the four radial profiles; this package’s pixel-area rendering ("area") is an input-hole rendering with no aperture equivalent. The edge-width limits are solprop’s own and are checked when the set is built. As exact hard discs every window is a physical hole whatever its rendering, so only an achromatic window is refused.- Parameters:
- windowssequence of WindowSpec
The collection windows, with resolved edge parameters.
- exactbool, optional
Ask for the windows as exact hard discs (
Config.exact_windows).
- Returns:
- str or None
The reason, or None.
- pnps.statistics.statistics_spec(windows, kx, signal=None, *, exact=False)[source]#
Return the statistics a field-free delay point asks solprop for.
- Parameters:
- windowssequence of WindowSpec
The collection windows, with resolved edge parameters.
- kxnumpy.ndarray
The stored momentum axis, rad/m.
- signaltuple of float or None, optional
The SD signal half-plane (
pnps.geometry.signal_half_plane()), or None for the TG quadrant.- exactbool, optional
The windows as exact hard discs on the nonlinear field (
aperture_set()).
- Returns:
- solprop.stats.StatsSpec
STATISTICS, with the apertures and the regions: for TG the signal quadrant, and for both the aliasing reading’s inner box (inner_box_region()), last.
- Raises:
- ReductionError
If the windows cannot be solprop apertures.
Return why solprop should not reduce these windows, or None if it should.
The choice behind
reduction="auto": solprop’s statistics are used only when solprop accepts the windows as apertures (statistics_refusal()and solprop’s own edge-width limits) and raises no warning about them. A warning (for example a tanh edge that slopes at the hole centre, collected with a lattice error near 1e-5) is an accuracy caveat the host reduction does not have, so it is a reason to stay on the host.- Parameters:
- windowssequence of WindowSpec
The collection windows, with resolved edge parameters.
- kxnumpy.ndarray
The stored momentum axis, rad/m.
- signaltuple of float or None, optional
The SD signal half-plane, or None for the TG quadrant.
- exactbool, optional
The windows as exact hard discs on the nonlinear field (
aperture_set()).
- Returns:
- str or None
The reason, or None when solprop’s statistics are to be used.