Skip to content

Commit

Permalink
fix it
Browse files Browse the repository at this point in the history
  • Loading branch information
debora-pe committed Nov 16, 2024
1 parent 6a16f26 commit b8c529d
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pypeit/wavetilts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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]
Expand Down

0 comments on commit b8c529d

Please sign in to comment.