convolutions¶
- starkzee.convolutions.calculate_doppler_width_ev(E0_ev, Ti_ev, A_emitter)[source]¶
Return the thermal Doppler 1/e half-width ΔE_D [eV].
For a Maxwellian ion distribution at temperature T_i the emission line is Doppler broadened into a Gaussian with 1/e half-width:
ΔE_D = E₀ × v_th / c
where the thermal velocity is
v_th = √(2 k_B T_i / m) → v_th/c = √(2 T_i / (m c² / e))
and m c² is the emitter rest energy in eV. The resulting FWHM is
FWHM = 2 √(ln 2) × ΔE_D
- Parameters:
- Returns:
Gaussian 1/e half-width ΔE_D [eV]. The full Gaussian profile is exp(−(E − E₀)² / ΔE_D²).
- Return type:
Notes
The formula uses the non-relativistic approximation v_th ≪ c, valid for all plasma temperatures relevant to magnetic fusion diagnostics.
- starkzee.convolutions.convolve_fft(grid, profile, kernel)[source]¶
Convolve profile with kernel on a uniform grid using FFT.
Both
profileandkernelmust be sampled on the same uniform grid. The convolution is computed via the convolution theorem:(f * g)[n] = IFFT(FFT(f) × FFT(g))
The input arrays are zero-padded by half their length on each side to suppress the wrap-around artefacts of the circular FFT convolution. The kernel is area-normalized before application so that the integrated intensity of the profile is conserved.
- Parameters:
grid (
array-like,shape (N,)) – Uniform coordinate grid (wavelengths or energies). Used only to determine array length; the actual coordinate values are not used.profile (
array-like,shape (N,)) – Spectral profile to be convolved.kernel (
array-like,shape (N,)) – Broadening kernel (not necessarily normalized). Its center must coincide with the center ofgrid;fftshiftis applied internally to place the peak at the origin for correct phase.
- Returns:
Convolved profile, trimmed back to length N.
- Return type:
ndarray,shape (N,)
Notes
Edge-padding (
mode='edge') is used for the profile to reduce ringing at the spectrum boundaries. Zero-padding is used for the kernel because the kernel is assumed to be compact relative to the grid.
- starkzee.convolutions.apply_doppler_broadening(wavelengths_nm, profile, Ti_ev, species='H')[source]¶
Apply thermal Doppler broadening to a spectrum on a uniform wavelength grid.
Constructs a Gaussian kernel with 1/e width
Δλ_D = λ₀ × v_th / c, v_th = √(2 T_i / m c²)
centered at the grid midpoint λ₀ = mean(wavelengths_nm), and convolves it with
profileviaconvolve_fft().- Parameters:
- Returns:
Doppler-broadened profile (same units as input).
- Return type:
ndarray,shape (N,)
Notes
The wavelength grid must be uniform (constant spacing). If the grid is non-uniform, resample before calling this function.
- starkzee.convolutions.apply_instrument_broadening(wavelengths_nm, profile, fwhm_nm)[source]¶
Apply Gaussian instrumental slit broadening to a spectrum.
Models the finite spectral resolution of the spectrometer as a Gaussian instrumental profile with the given FWHM. The standard deviation is
σ = FWHM / (2 √(2 ln 2))
and the kernel is exp(−(λ − λ̄)² / (2σ²)).
- Parameters:
wavelengths_nm (
ndarray,shape (N,)) – Uniform wavelength grid [nm].profile (
ndarray,shape (N,)) – Input spectral profile (arbitrary units).fwhm_nm (
float) – Instrumental FWHM [nm]. If ≤ 0 the profile is returned unchanged.
- Returns:
Instrument-broadened profile (same units as input).
- Return type:
ndarray,shape (N,)