From 5dac0a1d8683ea3667dfe31367c06ce02fcb74b1 Mon Sep 17 00:00:00 2001 From: Stephen Bailey Date: Thu, 22 Aug 2024 16:58:57 -0700 Subject: [PATCH] fix usage of FIBERSTATUS VARIABLETHRU --- py/desispec/fiberbitmasking.py | 4 ++-- py/desispec/fluxcalibration.py | 3 +++ py/desispec/sky.py | 8 ++++++-- 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/py/desispec/fiberbitmasking.py b/py/desispec/fiberbitmasking.py index 44c6987c7..1d79efde0 100644 --- a/py/desispec/fiberbitmasking.py +++ b/py/desispec/fiberbitmasking.py @@ -147,7 +147,7 @@ def get_skysub_fiberbitmask_val(band): Return mask of bad FIBERSTATUS bits for selecting sky fibers, i.e. fibers with these bits set should not be used for the sky model """ - return get_all_fiberbitmask_with_amp(band) | fmsk.VARIABLETHRU + return get_all_fiberbitmask_with_amp(band) def get_flat_fiberbitmask_val(band): """ @@ -169,7 +169,7 @@ def get_stdstars_fiberbitmask_val(band): Return mask of bad FIBERSTATUS bits for selecting standard stars, i.e. fibers with these bits set should not be used as standard stars """ - return get_all_fiberbitmask_with_amp(band) | fmsk.POORPOSITION | fmsk.VARIABLETHRU + return get_all_fiberbitmask_with_amp(band) | fmsk.POORPOSITION def get_all_nonamp_fiberbitmask_val(): """Return a mask for all fatally bad FIBERSTATUS bits except BADAMPB/R/Z diff --git a/py/desispec/fluxcalibration.py b/py/desispec/fluxcalibration.py index 8e669aefa..bdd474ab7 100644 --- a/py/desispec/fluxcalibration.py +++ b/py/desispec/fluxcalibration.py @@ -89,6 +89,9 @@ def isStdStar(fibermap, bright=None): log.warning('Using FA_TYPE to find standard stars instead') yes = (fibermap['FA_TYPE'] & FA_STDSTAR_MASK) != 0 + #- Remove fibers with known variable throughput + yes &= ((fibermap['FIBERSTATUS'] & fibermask.VARIABLETHRU) == 0) + return yes def applySmoothingFilter(flux,width=200) : diff --git a/py/desispec/sky.py b/py/desispec/sky.py index ecec84810..88fa6f8e4 100644 --- a/py/desispec/sky.py +++ b/py/desispec/sky.py @@ -21,7 +21,7 @@ import sys from desispec.fiberbitmasking import get_fiberbitmasked_frame_arrays, get_fiberbitmasked_frame import scipy.ndimage -from desispec.maskbits import specmask +from desispec.maskbits import specmask, fibermask from desispec.preproc import get_amp_ids,parse_sec_keyword from desispec.io import findfile,read_xytraceset from desispec.calibfinder import CalibFinder @@ -198,6 +198,8 @@ def get_sky_fibers(fibermap, override_sky_targetids=None, exclude_sky_targetids= some targetids by providing a list of them through exclude_sky_targetids or by just providing all the sky targetids directly (in that case the OBJTYPE information is ignored) + + Fibers with FIBERSTATUS bit VARIABLETHRU are also excluded """ log = get_logger() # Grab sky fibers on this frame @@ -206,7 +208,9 @@ def get_sky_fibers(fibermap, override_sky_targetids=None, exclude_sky_targetids= skyfibers = np.where(np.in1d(fibermap['TARGETID'], override_sky_targetids))[0] # we ignore OBJTYPEs else: - skyfibers = np.where(fibermap['OBJTYPE'] == 'SKY')[0] + oksky = (fibermap['OBJTYPE'] == 'SKY') + oksky &= ((fibermap['FIBERSTATUS'] & fibermask.VARIABLETHRU) == 0) + skyfibers = np.where(oksky)[0] if exclude_sky_targetids is not None: log.info('Excluding default sky fibers using exclude_sky_targetids') bads = np.in1d(fibermap['TARGETID'][skyfibers], exclude_sky_targetids)