API reference
This page covers the public surface exposed at the top level (import
kinextract / from kinextract import ...), grouped by the submodule
that defines each name. Internal helpers (leading-underscore names) are not
listed here but remain documented and importable from their defining
submodule for advanced use.
Configuration
All tunable parameters controlling a single LOSVD spectral fit. |
|
Build a |
Top-level fitting API
Run the full non-parametric LOSVD spectral fit end-to-end. |
|
Run the MAP fit, optionally with sigma-clipping. |
|
Build a per-parameter scale vector to precondition the L-BFGS-B fit. |
|
Iteratively sigma-clip outlier pixels while refitting the MAP model. |
|
Peak-normalised maximum absolute second difference of a LOSVD array. |
|
Count topographically-prominent peaks in a LOSVD. |
State
Mutable container holding the full numerical state of one spectral fit. |
|
Precompute linear-interpolation indices/weights from xl onto vgrid0. |
|
Precompute the (npix, nlosvd) pixel-shift index map for convolution. |
|
Resample a trial LOSVD histogram onto the fine internal velocity grid. |
Spectrum loading
Load a galaxy spectrum file and return arrays trimmed to the fit window. |
|
Load a spectrum and assemble the fully-populated FitState for one fit. |
|
Build the initial non-parametric-LOSVD parameter vector and its bounds. |
|
Determine whether a |
|
Resample a de-redshifted spectrum onto a uniform wavelength grid. |
Continuum
Fit a smooth asymmetric-least-squares baseline to a spectrum (Eilers 2003). |
|
Dilate a boolean mask by a fixed number of pixels on each side. |
|
Dilate a boolean mask by approximately a fixed wavelength on each side. |
|
Robust standard-deviation estimate via the normalized MAD. |
asymmetric_least_squares_continuum/robust_sigma are standalone,
one-time pre-normalization utilities – not part of the main fitting
pipeline.
Joint continuum-in-the-model fit
The continuum-cofitting method (FitConfig.fit_continuum = True). See
kinextract.joint for the full rationale.
Run the joint fit and package results in the same shape as |
|
Run the joint LOSVD + template + continuum-P-spline MAP fit. |
|
Automatically select the joint model's LOSVD regularization strength. |
|
Self-consistent fixed-point refinement of the wing-taper's |
|
Build a B-spline design matrix for the continuum. |
|
Evaluate the joint forward model for a trial parameter vector. |
LOSVD analysis
Fit the classic 4-moment Gauss-Hermite model to a non-parametric LOSVD. |
|
Fit a higher-order Gauss-Hermite model (h3..h_max_order) to a LOSVD. |
|
Four-moment Gauss-Hermite LOSVD model, legacy Fortran normalization. |
|
Higher-order Gauss-Hermite LOSVD model, van der Marel & Franx (1993) convention. |
|
Third-order Gauss-Hermite basis polynomial, legacy Fortran normalization. |
|
Fourth-order Gauss-Hermite basis polynomial, legacy Fortran normalization. |
|
Estimate the full-width-at-fraction-of-max and flux moments of a curve. |
Numerics
Evaluate the forward model spectrum for a trial parameter vector. |
|
Scalar objective function minimised by the MAP LOSVD/template fit. |
|
Break down the MAP objective into its individual terms. |
|
Compute the weighted mixture of stellar templates for given weights. |
Templates
Linearly interpolate a single template spectrum onto the galaxy grid. |
|
Build the full (npix, ntemplates) stellar template matrix. |
|
Compute the Gaussian kernel needed to remove a data/template LSF mismatch. |
|
Convolve flux with a Gaussian kernel of a fixed width in pixels. |
Masking
Build a boolean mask of emission-line pixels to exclude from the fit. |
|
Build the boolean "protect" mask exempting known real features from clipping. |
Plotting
Plot the observed spectrum against the best-fit model and residuals. |
|
Plot the recovered non-parametric LOSVD with its Gauss-Hermite overlay. |
|
Diagnostic plot for a continuum-cofit fit ( |
Error estimation
Unified interface for estimating uncertainties on a recovered LOSVD. |
|
Convenience wrapper: run all requested error estimation methods and return the combined summary. |
Recovery-bias validation
Measure empirical LOSVD recovery bias on a grid of known truths. |
|
Apply an empirical bias correction from an |
|
Synthetic spectrum matched to st's instrument/template/continuum/noise. |
|
Ground-truth LOSVD histogram on xl, normalized so |
I/O
Read a raw 3-column galaxy spectrum file. |
|
Read a pre-normalized |
|
Load a single stellar/SSP template spectrum file. |
|
Read a template-list file and resolve each entry to a full path. |
|
Read a legacy galaxy.params file. |
|
Write the final LOSVD fit results to legacy-format ASCII files. |
|
Write LOSVD vector with error bars to a file for modeling pipeline. |
|
Write Gauss-Hermite moment errors to a file. |
Optional Bayesian (NUTS) path
Not part of the top-level namespace (requires pip install
kinextract[bayesian]); import directly from kinextract.bayesian.
Run the full Bayesian LOSVD/template/continuum fit, called from |
|
Build the NumPyro model function for one LOSVD/template/continuum- offset posterior, at fixed regularization strength |