From e6a58ae2ee34f5a89573fa4ca08854a5708ab72e Mon Sep 17 00:00:00 2001 From: John Moustakas Date: Thu, 5 Dec 2024 16:51:10 -0500 Subject: [PATCH] always mask strong lines; lower-order smooth-continuum fitting --- py/fastspecfit/continuum.py | 5 +++-- py/fastspecfit/linemasker.py | 8 +++++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/py/fastspecfit/continuum.py b/py/fastspecfit/continuum.py index 79c17f2b..1d46b728 100644 --- a/py/fastspecfit/continuum.py +++ b/py/fastspecfit/continuum.py @@ -218,9 +218,10 @@ def _smooth_percamera(camwave, camflux, camivar, camlinemask): # We supply estimates local inverse stddev in each window # (i.e., how noisy the data is there) so that variation is - # down-weighted in noisier regions. + # down-weighted in noisier regions. Note: ext=3 means constant + # extrapolation. if len(swave) > 3: - spl_flux = UnivariateSpline(swave, sflux, w=sisig, ext=3, k=3) + spl_flux = UnivariateSpline(swave, sflux, w=sisig, ext=3, k=2) smoothflux = spl_flux(camwave) else: smoothflux = np.zeros_like(camflux) diff --git a/py/fastspecfit/linemasker.py b/py/fastspecfit/linemasker.py index cb9fef1a..22d66530 100644 --- a/py/fastspecfit/linemasker.py +++ b/py/fastspecfit/linemasker.py @@ -838,10 +838,12 @@ def fit_patches(continuum_patches, patchMap, linemodel, snrpix = pix['snr'] - # remove low signal-to-noise ratio lines from the mask + # remove low signal-to-noise ratio lines from the mask, but always keep + # the "expected" strong lines (see, e.g., CIV 1549 in + # sv3-dark-25960-39627770216580342). linenames = snrpix.keys() - for linename in linenames: - if snrpix[linename] < minsnr_linemask: + for linename, isstrong in zip(linenames, EMFit.line_table[EMFit.line_in_range]['isstrong'].value): + if not isstrong and snrpix[linename] < minsnr_linemask: log.debug(f'Removing {linename} from linepix: S/N={snrpix[linename]:.1f}<{minsnr_linemask:.1f}.') linepix.pop(linename)