jwspecfit.models
Gaussian emission-line profiles with bin-averaged evaluation.
The core building block is gaussian_binned(), which computes the
mean value of a unit-area Gaussian over each pixel bin using the error
function. This avoids the sampling bias that arises when the line is
narrower than the pixel width (as happens with the NIRSpec prism).
Functions
|
Asymmetric (skewed-normal) Gaussian profile. |
|
Build multi-line emission model from a flat parameter vector. |
|
Bin-averaged, area-normalised Gaussian profile. |
|
Pixel-width weighting to down-weight overly narrow/wide pixels. |
|
Bin-averaged skewed Gaussian profile for Lyman-alpha. |
- jwspecfit.models.asymmetric_gaussian(wave_A, A_peak, mu_A, sigma_A, alpha)[source]
Asymmetric (skewed-normal) Gaussian profile.
Follows the Owen/Bolan+2025 parameterisation used in Lyα fitting:
f(λ) = A_peak × exp(-(λ-μ)²/(2σ²)) × [1 + erf(α(λ-μ)/(√2 σ))]
When α=0 this reduces to a symmetric Gaussian with peak
A_peak. Positive α produces a red-asymmetric tail (standard for Lyα).- Parameters:
wave_A (np.ndarray) – Wavelength grid (Å) — typically bin centres.
A_peak (float) – Peak amplitude of the underlying Gaussian (before the erf modulation). Units match the flux-density units of the spectrum.
mu_A (float) – Location parameter (Å). Note: the observed peak shifts redward of μ when α > 0.
sigma_A (float) – Width parameter (Å).
alpha (float) – Skewness parameter. α = 0 → symmetric; α > 0 → red tail.
- Returns:
Profile evaluated at each wavelength (same units as A_peak).
- Return type:
np.ndarray
- jwspecfit.models.build_model(params, wave_edges_A, n_lines)[source]
Build multi-line emission model from a flat parameter vector.
Parameters are packed as:
[A_0, A_1, ..., A_{n-1}, # amplitudes (flux × Å) mu_0, mu_1, ..., # centroids (Å) sigma_0, sigma_1, ...] # widths (Å)
Uses vectorised numpy broadcasting to evaluate all lines simultaneously rather than looping in Python.
- Parameters:
params (np.ndarray) – Parameter vector of length
3 * n_lines.wave_edges_A (np.ndarray) – Pixel-edge wavelengths (length
n_pix + 1).n_lines (int) – Number of emission lines.
- Returns:
Model flux density per pixel (Å⁻¹ × amplitude units).
- Return type:
np.ndarray
- jwspecfit.models.gaussian_binned(lam_left_A, lam_right_A, mu_A, sigma_A)[source]
Bin-averaged, area-normalised Gaussian profile.
Returns the mean value (per Angstrom) of a Gaussian with unit area integrated over each
[left, right]pixel bin.- Parameters:
- Returns:
Profile value in each bin (Å⁻¹). Multiply by amplitude (in flux × Å units) to get flux density.
- Return type:
np.ndarray
- jwspecfit.models.pixel_weight(dlam_A, power=0.35)[source]
Pixel-width weighting to down-weight overly narrow/wide pixels.
Weight = (median_dλ / dλ)^power. Pixels with atypical widths (edges of the detector, bad pixels) get reduced influence.
- Parameters:
dlam_A (np.ndarray) – Pixel widths in Angstroms.
power (float) – Weighting exponent (default 0.35).
- Returns:
Multiplicative weight for each pixel.
- Return type:
np.ndarray
- jwspecfit.models.skewed_gaussian_binned(lam_left_A, lam_right_A, amplitude, mu_A, sigma_A, skew)[source]
Bin-averaged skewed Gaussian profile for Lyman-alpha.
Uses
scipy.stats.skewnormevaluated at bin centres. The amplitude parameter gives the integrated flux.- Parameters:
- Returns:
Flux density per bin (Å⁻¹ × amplitude units).
- Return type:
np.ndarray