kinextract.build_emission_line_mask
- kinextract.build_emission_line_mask(x: ndarray, g: ndarray, gerr: ndarray, cfg: FitConfig) ndarray[source]
Build a boolean mask of emission-line pixels to exclude from the fit.
Called from ~kinextract.spectrum.make_fit_state to set
gerr = BIGat detected emission-line pixels before any LOSVD/template fitting begins. Stellar templates contain no emission lines, so an unmasked emission feature (e.g. [N I], [Cl II], or other nebular/AGN lines superposed on the stellar spectrum) would otherwise bias the recovered LOSVD; pre-masking ensures this even for lines too weak to later be caught by the kinematic sigma-clipping in _update_clean_mask.Detection is based on the excess flux above the local continuum within the line window, not on the raw continuum signal-to-noise of the region (which would produce false positives near strong, high-S/N absorption features like Ca II even when no emission is present). For each candidate line (drawn from the “em”-tagged, and optionally “paschen”-tagged, entries of ~kinextract.continuum._STELLAR_ABSORPTION_LINE_TABLES):
Estimate the local continuum and noise from the flanking regions just outside the line window (within
±snr_context_Abut excluding±half_width_A), after excluding the Ca II triplet windows from the flanks so their absorption troughs cannot bias the continuum estimate downward.Compute
excess_snr = (peak_flux_in_line - cont_est) / noise_est.Mask the line window only if
excess_snr >= snr_threshold.
- Parameters:
x (ndarray) – Wavelength array (Å), same frame as the fit state’s
st.x.g (ndarray) – Flux array corresponding to x.
gerr (ndarray) – Flux uncertainty array corresponding to x; used to estimate the local noise level and to identify already-bad pixels (
gerr >= BIG).cfg (FitConfig) – Fit configuration; supplies
mask_emission_lines_in_fit,mask_emission_line_half_width_A,mask_emission_line_snr_threshold,mask_emission_line_snr_context_A,mask_paschen_lines_in_fit, andwavefitmin/wavefitmax. The fixed Ca II triplet window used to protect the flanking-continuum estimate is not configurable (see_CAII_CENTERS_A/_CAII_HALF_WIDTHS_A).
- Returns:
Mask of length
len(x); True marks pixels to exclude from the fit (by settinggerr = BIG). All-False ifcfg.mask_emission_lines_in_fitis False.- Return type:
ndarray of bool