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

i_omega_win

aperture_spectrum (the windows as an solprop.stats.ApertureSet)

1/U_S

i_omega_reimaged

aperture_on_axis_spectrum

1/U_A

i_omega_full

TG: region_spectrum, one box: the signal quadrant. SD: the last row of aperture_spectrum, a hard half-plane of the mask beyond the gate-side edge

1/U_S

i_omega_beam

beam_spectrum

1/U_S

energy

energy

1

absorb_omega

absorbed_power[0] (spectral channel: the band edges)

1/(2 U_P)

absorb_lap

absorbed_power[4] (custom channel: the lap budget)

1/(2 U_P)

gd_band_power

beam_spectrum, the lap-budget bins over all

ratio

alias_fraction

region_spectrum, the inner box’s row, against beam_spectrum

ratio

absorb_k

absorbed_power[1] (transverse channel)

1/(2 U_P)

edge_fraction

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 of sum_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 of Re(A conj(G)): the on-axis spectrum, whose amplitude A = sum_c alpha_c W E and closure G (the same sum of conj(y) E) already carry the 1/N of the on-axis weight alpha_c = (-1)^(ix+iy) / N;

  • U_P = (eps_0 c / 2) (dx^2 / N) (dt / n_t), J/m per unit of sum r eta |E|^2: the absorbed powers, with solprop’s power rates r = 2 x this 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

STATISTICS

The solprop statistics a field-free delay point asks for at every plane.

Functions

aperture_set(windows[, signal, exact])

Return the windows as a solprop aperture set.

inner_box_region(kx)

Return the aliasing reading's inner box as one row of spectral_regions.

observation_from_statistics(values, scale, ...)

Turn one plane's solprop statistics into this package's observation.

signal_quadrant_region(kx)

Return the signal quadrant as one row of solprop's spectral_regions.

statistics_refusal(windows, *[, exact])

Return why the windows cannot be solprop apertures, or None if they can.

statistics_spec(windows, kx[, signal, exact])

Return the statistics a field-free delay point asks solprop for.

statistics_unavailable(windows, kx[, ...])

Return why solprop should not reduce these windows, or None if it should.

Classes

StatisticsScale(spectrum, on_axis, power)

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: object

The constants that turn solprop’s physical statistics into this package’s units.

Attributes:
spectrumfloat

U_S, J/(rad/s) per unit of sum_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 of sum r |E|^2.

spectrum: float#
on_axis: float#
power: float#
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 / N in m^2 (FreeGrid.spectral_weights, the same for every column).

Returns:
StatisticsScale

The unit constants U_S, U_A and U_P for 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 exact profile, SEP 53) over the nonlinear part of the field, the state less the input carried by the linear flow, as pnps.exact_windows.ExactWindows integrates 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 hard half_plane_x_ge row; 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]] with h from pnps.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 columns n/2 .. n-1 of 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 ApertureSet shares 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.

pnps.statistics.statistics_unavailable(windows, kx, signal=None, *, exact=False)[source]#

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.