pnps.pulse#

Input pulse construction, spectral resampling, duration metrics and energy.

The 1-D pulse spectrum built here is the shape (amplitude and spectral phase) of the input; its absolute scale is arbitrary because the beamlet builder rescales the full 3-D field to the requested energy. The spectral phase follows the FFT sign convention used throughout: a physical spectral phase phi(omega) is applied as exp(-1j * phi), so positive GDD (phi2 > 0) chirps the pulse in the normal-dispersion sense.

Functions

energy_prefactor(tgrid, sgrid)

Factor turning sum |E|^2 of the spectral state into joules.

energy_spectral(e, tgrid, sgrid)

Pulse energy of the spectral state E(..., ky, kx, omega) in J.

energy_time(et, tgrid, sgrid)

Pulse energy of a real-space/time field E(..., y, x, t) in J.

fit_spectral_chirp(omega, e_omega, lam0[, ...])

Fit (GDD, TOD) from a stored complex spectrum by a weighted cubic.

gaussian_pulse_spectrum(tgrid, tau_fwhm[, ...])

Spectrum of a Gaussian pulse with optional GDD/TOD chirp.

intensity_fwhm(t, intensity)

Full width at half maximum of a sampled intensity profile.

planck_taper(x, left0, left1, right1, right0)

Planck-taper window: 0 outside (left0, right0), 1 in [left1, right1].

resample_spectrum(spectrum, omega_ref, ...)

Evaluate an FFT-ordered spectrum at arbitrary frequencies, exactly.

taylor_phase(omega, lam0[, cep, gd, gdd, tod])

Taylor spectral phase about the carrier omega_c = 2*pi*c/lam0.

pnps.pulse.energy_prefactor(tgrid, sgrid)[source]#

Factor turning sum |E|^2 of the spectral state into joules.

The state is the unnormalised 3-D FFT of the field in V/m, so by Parseval the time-domain energy functional applies directly once divided by the total sample count.

Parameters:
tgrid, sgridTimeGrid, SpaceGrid

The simulation grids.

Returns:
float

c eps_0 / 2 * dx^2 * dt / (n^2 nt), in J per (V/m)^2.

pnps.pulse.energy_spectral(e, tgrid, sgrid)[source]#

Pulse energy of the spectral state E(..., ky, kx, omega) in J.

A leading batch axis survives. See energy_prefactor() for the normalisation.

Parameters:
enumpy.ndarray

Spectral state (..., n_y, n_x, n_omega), complex: the unnormalised 3-D FFT of the field in V/m, with any leading batch axes.

tgrid, sgridTimeGrid, SpaceGrid

The simulation grids.

Returns:
numpy.ndarray or float

The energy in J, one value per leading batch index (a float for a single state).

pnps.pulse.energy_time(et, tgrid, sgrid)[source]#

Pulse energy of a real-space/time field E(..., y, x, t) in J.

(c epsilon_0 / 2) * dx * dy * dt * sum(|E|^2) for a field in V/m. The three field axes are reduced; a leading batch axis survives.

Parameters:
etnumpy.ndarray

Field (..., n_y, n_x, n_t) in V/m, with any leading batch axes.

tgrid, sgridTimeGrid, SpaceGrid

The simulation grids.

Returns:
numpy.ndarray or float

The energy in J, one value per leading batch index (a float for a single field).

pnps.pulse.fit_spectral_chirp(omega, e_omega, lam0, threshold=0.001)[source]#

Fit (GDD, TOD) from a stored complex spectrum by a weighted cubic.

The spectral phase is unwrapped over the bins carrying more than threshold of the peak spectral power, fitted with a cubic weighted by the spectral amplitude, and reported in the package’s convention (phase applied as exp(-1j phi) with phi = gdd dw^2/2 + tod dw^3/6), so a positive GDD is normal dispersion. Constant and linear terms — carrier- envelope phase and any residual time offset — are absorbed by the fit and not reported.

Two details are load-bearing. The stored pulse peaks at the centre sample of its time grid, so the FFT-ordered spectrum carries an exact (-1)^k ramp — very nearly pi radians per bin, which defeats any unwrap; it is removed exactly first. And threshold is part of the measurement, not a detail: on a structured spectrum with deep minima, raising it from 1e-3 to 1e-2 discards the wings that constrain the curvature and can move the fitted GDD by a factor of two.

Parameters:
omeganumpy.ndarray

Absolute angular frequency axis in rad/s, any order.

e_omeganumpy.ndarray

Complex spectrum on omega in the storage convention.

lam0float

Wavelength the Taylor expansion is taken about, in m.

thresholdfloat

Fraction of the peak spectral power a bin must carry to enter the fit.

Returns:
tuple of (float, float)

(gdd, tod) in s^2 and s^3.

Raises:
PulseError

If fewer than four bins pass the threshold (a cubic needs four).

pnps.pulse.gaussian_pulse_spectrum(tgrid, tau_fwhm, gdd=0.0, tod=0.0, lam0=None)[source]#

Spectrum of a Gaussian pulse with optional GDD/TOD chirp.

The transform-limited envelope has intensity FWHM tau_fwhm and peaks at grid time t = 0 (the centre sample). The chirp is applied as a multiplicative spectral phase exp(-1j * phi).

Parameters:
tgridTimeGrid

The temporal grid the pulse lives on.

tau_fwhmfloat

Intensity FWHM of the transform-limited pulse in s.

gdd, todfloat

Group-delay dispersion (s^2) and third-order dispersion (s^3) about the pulse carrier.

lam0float or None

Pulse carrier wavelength in m; defaults to the grid reference. A different carrier appears as an envelope frequency offset.

Returns:
numpy.ndarray

Complex spectrum on tgrid.omega, arbitrary overall scale.

pnps.pulse.intensity_fwhm(t, intensity)[source]#

Full width at half maximum of a sampled intensity profile.

The half-maximum crossings are found on the outermost samples above half the peak and placed by linear interpolation between the bracketing samples, so the result is not quantised to the sample spacing. On an 8x-oversampled envelope grid that leaves an error of order (delta_t)^2 times the profile’s curvature at the crossing — below 1e-4 fs for a femtosecond pulse — but the estimate does assume a single connected region above half maximum: for a profile with a satellite above half the peak it measures the outermost crossings, which is the width of the whole structure, not of the main peak.

Parameters:
tnumpy.ndarray

Monotonically increasing time axis, shape (n,), in s.

intensitynumpy.ndarray

Non-negative intensity samples on t.

Returns:
float

FWHM in the units of t.

Raises:
PulseError

If the profile is not positive, or its half-maximum region touches an end of the axis (the crossing is then off-grid and the width is not measurable).

Examples

>>> import numpy as np
>>> t = np.linspace(-5, 5, 2001)
>>> round(intensity_fwhm(t, np.exp(-t**2 / 2)), 4)  # 2 sqrt(2 ln 2)
2.3548
pnps.pulse.planck_taper(x, left0, left1, right1, right0)[source]#

Planck-taper window: 0 outside (left0, right0), 1 in [left1, right1].

A C-infinity bump [McKechan2010] used here to band-limit the input spectrum to the simulation window once at setup — its smoothness means the hard grid-boundary truncation never rings into the time domain. It is never applied during propagation.

Parameters:
xnumpy.ndarray

Abscissa, any shape and any unit.

left0, left1, right1, right0float

The window’s corners in the unit of x, with left0 < left1 <= right1 < right0: it rises over (left0, left1) and falls over (right1, right0).

Returns:
numpy.ndarray

The window value in [0, 1], the shape of x.

References

[McKechan2010]

D. J. A. McKechan, C. Robinson and B. S. Sathyaprakash, Class. Quantum Grav. 27, 084020 (2010), eq. (7).

pnps.pulse.resample_spectrum(spectrum, omega_ref, delta_t, omega)[source]#

Evaluate an FFT-ordered spectrum at arbitrary frequencies, exactly.

The samples of a spectrum on a uniform frequency grid determine a unique trigonometric polynomial in frequency, whose coefficients are the conjugate-domain (time) samples obtained by one inverse FFT. Evaluating that polynomial at arbitrary frequencies is exact interpolation for any signal contained in the implied time window, at any ratio of grid spacings. Linear or spline interpolation of the sampled values is not: on a delayed trace the spectrum carries fringes of period 2 pi / tau (about twenty bins at 13 fs), where linear interpolation errs by ~1% of the fringe amplitude, and on a phase-wrapped complex field it fails outright.

The conjugate-domain coefficients are indexed by signed lags, so the interpolant is the one appropriate to a signal centred on zero lag. Two kinds of input satisfy that: a power spectrum, whose conjugate domain is the field autocorrelation (peaked at zero lag by construction), and the centred-time transform sum_n E(t_n) exp(-1j omega t_n) of a field peaked at t = 0. A spectrum carrying this package’s storage ramp (see gaussian_pulse_spectrum()) must have it removed first.

Parameters:
spectrumnumpy.ndarray

Spectral samples in FFT order, shape (n,); real or complex.

omega_reffloat

Absolute angular frequency of element 0, in rad/s (the carrier for a baseband envelope grid, 0 for a one-sided absolute axis).

delta_tfloat

Time step of the conjugate grid in s, i.e. the sample spacing implied by the spectrum’s own frequency spacing 2 pi / (n * delta_t).

omeganumpy.ndarray

Absolute angular frequencies to evaluate at, in rad/s, any order.

Returns:
numpy.ndarray

Complex values at omega, shape omega.shape. For a real input spectrum the imaginary part is round-off and callers may drop it.

Examples

Evaluating at the grid’s own frequencies returns the samples:

>>> import numpy as np
>>> s = np.fft.fft(np.exp(-((np.arange(32) - 16.0) ** 2) / 8))
>>> w = 2 * np.pi * np.fft.fftfreq(32, 1.0)
>>> bool(np.allclose(resample_spectrum(s, 0.0, 1.0, w), s))
True
pnps.pulse.taylor_phase(omega, lam0, cep=0.0, gd=0.0, gdd=0.0, tod=0.0)[source]#

Taylor spectral phase about the carrier omega_c = 2*pi*c/lam0.

Parameters:
omeganumpy.ndarray

Absolute angular frequency axis in rad/s.

lam0float

Expansion wavelength in m.

cep, gd, gdd, todfloat

Phase orders 0..3 in s^0..s^3: carrier-envelope phase, group delay, group-delay dispersion, third-order dispersion.

Returns:
numpy.ndarray

phi(omega) = cep + gd*dw + gdd*dw^2/2 + tod*dw^3/6 with dw = omega - omega_c.