NMF Rectify¶
NMF Rectify performs continuum normalization of stellar spectra using Non-negative Matrix Factorization (NMF). It provides a data-driven continuum estimate that is used by downstream pipelines.
What it does¶
NMF Rectify separates the observed spectrum into a continuum component and a rectified (continuum-normalized) component. It produces:
NMF coefficients (
log10_W) that describe the spectral featuresContinuum coefficients (
continuum_theta) that describe the smooth continuum shapeGoodness-of-fit statistics
How it works¶
The continuum model has two components:
NMF spectral component: A set of pre-trained NMF basis vectors (components) capture the spectral line features. The NMF coefficients
Ware non-negative weights on these components. The rectified model spectrum is1 - W * components.Sinusoidal continuum: The smooth continuum shape is modeled as a sum of sinusoidal functions with a specified length scale (
L) and degree (deg). This flexible functional form can represent slowly-varying continuum shapes without overfitting spectral lines.
The pipeline fits both components simultaneously, optimizing the NMF weights and continuum coefficients to minimize the residuals between the model and the observed flux.
BOSS spectra¶
For BOSS spectra, the pipeline operates per-source: all visit spectra for a given source
are fit jointly. Visit spectra are shifted to the rest frame using the XCSAO radial
velocity, resampled onto a common wavelength grid, and fit with shared NMF coefficients
but per-visit continuum coefficients. Visits are filtered to require SNR > 3, adequate
cross-correlation quality (XCSAO R > 6, unless the source is in the mwm_wd program),
and no DRP warning flags.
APOGEE spectra¶
For APOGEE coadded spectra, each spectrum is fit individually.
Initial guess¶
The initial guess for the NMF coefficients is obtained using a “small W” heuristic
(flagged as flag_initialised_from_small_w), which provides a conservative starting
point for the optimization.
Output fields¶
Field |
Description |
|---|---|
|
Log10 of the NMF coefficients (array) |
|
Continuum model coefficients (array) |
|
Sinusoidal length scale used for the continuum model |
|
Sinusoidal degree used for the continuum model |
|
Reduced chi-squared for this spectrum |
|
Joint reduced chi-squared from the simultaneous fit (BOSS: across all visits for the source) |
|
Bitfield describing processing flags |
Flags¶
The nmf_flags bitfield uses the following bits:
Flag |
Bit |
Meaning |
|---|---|---|
|
2^0 |
NMF coefficients were initialized using the small-W heuristic |
|
2^3 |
The spectrum could not be read (I/O error) |
|
2^4 |
A runtime exception occurred during fitting |
Key caveats¶
NMF Rectify is a preprocessing step, not a science pipeline. Its outputs (continuum and rectified spectra) are consumed by downstream pipelines such as SLAM and Grok.
The NMF components are pre-trained and fixed. They capture typical stellar spectral features but may not accurately represent unusual or exotic spectra.
For BOSS spectra, the joint fit across visits means that the NMF coefficients are shared. If one visit has a very different spectral shape (e.g., due to variability), this can affect the fit quality for all visits.
The
rchi2is computed per spectrum, whilejoint_rchi2reflects the fit quality across all spectra in the joint fit.