From d8f6d050fb22cfc66ca41e002dc6c0da3be29c98 Mon Sep 17 00:00:00 2001 From: rcooke-ast Date: Wed, 12 Jul 2023 12:28:46 +0100 Subject: [PATCH] fix mask check --- pypeit/find_objects.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/pypeit/find_objects.py b/pypeit/find_objects.py index 53422c1b66..3bb531a651 100644 --- a/pypeit/find_objects.py +++ b/pypeit/find_objects.py @@ -1184,10 +1184,12 @@ def joint_skysub(self, skymask=None, update_crmask=True, trim_edg=(0,0), counts = global_sky _scale = None if self.sciImg.img_scale is None else self.sciImg.img_scale[thismask] # NOTE: darkcurr must be a float for the call below to work. - var = procimg.variance_model(self.sciImg.base_var[thismask], counts=counts[thismask], - count_scale=_scale, noise_floor=adderr) - model_ivar[thismask] = utils.inverse(var) - + if not self.bkg_redux: + var = procimg.variance_model(self.sciImg.base_var[thismask], counts=counts[thismask], + count_scale=_scale, noise_floor=adderr) + model_ivar[thismask] = utils.inverse(var) + else: + model_ivar[thismask] = self.sciImg.ivar[thismask] # RJC :: Recalculating the global sky and flexure is probably overkill... but please keep this code in for now # Recalculate the sky on each individual slit and redetermine the spectral flexure # global_sky_sep = super().global_skysub(skymask=skymask, update_crmask=update_crmask, @@ -1227,7 +1229,8 @@ def global_skysub(self, skymask=None, update_crmask=True, trim_edg=(0,0), global_sky_sep = super().global_skysub(skymask=skymask, update_crmask=update_crmask, trim_edg=trim_edg, show_fit=show_fit, show=show, show_objs=show_objs) - if np.any(global_sky_sep[skymask] == 0): + # Check if any slits failed + if np.any(global_sky_sep[self.slitmask>=0] == 0) and not self.bkg_redux: # Cannot continue without a sky model for all slits msgs.error("Global sky subtraction has failed for at least one slit.")