From b8c529d26a63dd249dfbf64190c1d639b1a9c696 Mon Sep 17 00:00:00 2001 From: Debora Pelliccia Date: Fri, 15 Nov 2024 17:23:08 -1000 Subject: [PATCH 1/2] fix it --- pypeit/wavetilts.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pypeit/wavetilts.py b/pypeit/wavetilts.py index e0949b9d9..4931e9fee 100644 --- a/pypeit/wavetilts.py +++ b/pypeit/wavetilts.py @@ -797,6 +797,13 @@ def run(self, doqa=True, debug=False, show=False): self.spat_order[slit_idx], self.spec_order[slit_idx], slit_idx, doqa=doqa, show_QA=show) + # Flag slits with high number of rejected pixels (>95%) + # TODO: Is 95% the right threshold? + _gpm = self.all_fit_dict[slit_idx]['pypeitFit'].bool_gpm + if np.sum(np.logical_not(_gpm)) > 0.95 * np.sum(_gpm): + msgs.warn(f'Large number of pixels rejected in the fit. This slit/order will not be reduced!') + self.slits.mask[slit_idx] = self.slits.bitmask.turn_on(self.slits.mask[slit_idx], 'BADTILTCALIB') + continue self.coeffs[:self.spec_order[slit_idx]+1,:self.spat_order[slit_idx]+1,slit_idx] = coeff_out # TODO: Need a way to assess the success of fit_tilts and @@ -807,6 +814,12 @@ def run(self, doqa=True, debug=False, show=False): # images, trace images, and pixelflats etc. self.tilts = tracewave.fit2tilts(self.slitmask_science.shape, coeff_out, self.par['func2d']) + # Check that the tilts image has values that span a reasonable range + # TODO: Is this the right threshold? + if np.nanmax(self.tilts) - np.nanmin(self.tilts) < 0.8: + msgs.warn('Tilts image fit not good. This slit/order will not be reduced!') + self.slits.mask[slit_idx] = self.slits.bitmask.turn_on(self.slits.mask[slit_idx], 'BADTILTCALIB') + continue # Save to final image thismask_science = self.slitmask_science == slit_spat self.final_tilts[thismask_science] = self.tilts[thismask_science] From f125d02f7a012b34356b932a7548191a69ee5f00 Mon Sep 17 00:00:00 2001 From: Debora Pelliccia Date: Sat, 16 Nov 2024 08:43:49 -1000 Subject: [PATCH 2/2] small change --- pypeit/wavetilts.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pypeit/wavetilts.py b/pypeit/wavetilts.py index 4931e9fee..d717173be 100644 --- a/pypeit/wavetilts.py +++ b/pypeit/wavetilts.py @@ -800,7 +800,7 @@ def run(self, doqa=True, debug=False, show=False): # Flag slits with high number of rejected pixels (>95%) # TODO: Is 95% the right threshold? _gpm = self.all_fit_dict[slit_idx]['pypeitFit'].bool_gpm - if np.sum(np.logical_not(_gpm)) > 0.95 * np.sum(_gpm): + if np.sum(np.logical_not(_gpm)) > 0.95 * _gpm.size: msgs.warn(f'Large number of pixels rejected in the fit. This slit/order will not be reduced!') self.slits.mask[slit_idx] = self.slits.bitmask.turn_on(self.slits.mask[slit_idx], 'BADTILTCALIB') continue