kinextract.build_clean_protect_mask

kinextract.build_clean_protect_mask(st: FitState, cfg: FitConfig) ndarray[source]

Build the boolean “protect” mask exempting known real features from clipping.

This mask feeds directly into _update_clean_mask’s protect_mask argument during the iterative kinematic sigma-clipping of the LOSVD chi-squared fit: pixels marked True here are fully exempt from being clipped as outliers, regardless of the sign of their residual, because they are known to contain real spectral signal (Ca II triplet absorption, user-specified windows, or extra absorption lines) rather than cosmic rays, sky-subtraction residuals, or emission contamination. Without this protection, iterative sigma-clipping could progressively erode real, deep absorption features that legitimately produce large residuals against an imperfect model.

Combines three independent sources of protection:

  1. The Ca II triplet, at centers from get_ca_centers_for_cleaning with a per-line half-width from clean_ca_half_width_A (which widens the window for broad LOSVDs), if cfg.clean_protect_ca_triplet is True.

  2. User-specified custom wavelength windows (cfg.clean_protect_windows), converted to the st.x frame via _clean_window_to_fit_frame.

  3. User-specified extra absorption lines (cfg.extra_absorption_lines), each given as (center, half_width[, name]).

Parameters:
  • st (FitState) – Fit state; supplies the wavelength grid st.x and pixel count st.npix.

  • cfg (FitConfig) – Fit configuration; supplies clean_protect_ca_triplet, clean_protect_windows, clean_protect_windows_frame, and extra_absorption_lines.

Returns:

Mask of length st.npix; True marks pixels that must never be rejected by the kinematic-fit sigma-clipping regardless of residual sign.

Return type:

ndarray of bool