Skip to content

Commit

Permalink
Merge pull request #1418 from pypeit/slittrace_nsig_fix
Browse files Browse the repository at this point in the history
Update slittrace smash_nsig to smash_snr
  • Loading branch information
profxj authored May 28, 2022
2 parents ac1659e + 1659282 commit cd1f9dc
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions pypeit/slittrace.py
Original file line number Diff line number Diff line change
Expand Up @@ -1158,7 +1158,7 @@ def get_maskdef_objpos(self, plate_scale, det_buffer):
return

def get_maskdef_offset(self, sobjs, platescale, spat_flexure, slitmask_off, bright_maskdefid,
nsig_thrshd, use_alignbox, dither_off=None):
snr_thrshd, use_alignbox, dither_off=None):
"""
Determine the Slitmask offset (pixels) from position expected by the slitmask design
Expand All @@ -1168,7 +1168,7 @@ def get_maskdef_offset(self, sobjs, platescale, spat_flexure, slitmask_off, brig
spat_flexure (:obj:`float`): Shifts, in spatial pixels, between this image and SlitTrace
slitmask_off (:obj:`float`): User provided slitmask offset in pixels
bright_maskdefid (:obj:`str`): User provided maskdef_id of a bright object to be used to measure offset
nsig_thrshd (:obj:`float`): Objects detected above this sigma threshold will be use to
snr_thrshd (:obj:`float`): Objects detected above this S/N ratio threshold will be use to
compute the slitmask offset
use_alignbox (:obj:`bool`): Flag that determines if the alignment boxes are used to measure the offset
dither_off (:obj:`float`, optional): dither offset recorded in the header of the observations
Expand Down Expand Up @@ -1296,25 +1296,25 @@ def get_maskdef_offset(self, sobjs, platescale, spat_flexure, slitmask_off, brig
self.maskdef_offset = 0.0
return

# Determine offsets using only detections with the highest significance
# objects added in manual extraction have smash_nsig = None
nonone = cut_sobjs.smash_nsig != None
# Determine offsets using only detections with the highest signal
# objects added in manual extraction have smash_snr = None
nonone = cut_sobjs.smash_snr != None
if len(cut_sobjs[nonone]) > 0:
highsig_measured = measured[nonone][cut_sobjs[nonone].smash_nsig > nsig_thrshd]
highsig_expected = expected[nonone][cut_sobjs[nonone].smash_nsig > nsig_thrshd]
if len(highsig_measured) >= 3:
off = highsig_measured - highsig_expected
highsnr_measured = measured[nonone][cut_sobjs[nonone].smash_snr > snr_thrshd]
highsnr_expected = expected[nonone][cut_sobjs[nonone].smash_snr > snr_thrshd]
if len(highsnr_measured) >= 3:
off = highsnr_measured - highsnr_expected
mean, median_off, std = sigma_clipped_stats(off, sigma=2.)
self.maskdef_offset = median_off
msgs.info(f'Slitmask offset estimated in {self.detname}: '
f'{round(self.maskdef_offset, 2)} pixels ('
f'{round(self.maskdef_offset*platescale, 2)} arcsec)')
else:
msgs.warn(f'Less than 3 objects detected above {nsig_thrshd} sigma threshold. '
msgs.warn(f'Less than 3 objects detected above {snr_thrshd} sigma threshold. '
f'Slitmask offset cannot be estimated in {self.detname}.')
self.maskdef_offset = 0.0
else:
msgs.warn(f'Less than 3 objects detected above {nsig_thrshd} sigma threshold. '
msgs.warn(f'Less than 3 objects detected above {snr_thrshd} sigma threshold. '
f'Slitmask offset cannot be estimated in {self.detname}.')
self.maskdef_offset = 0.0

Expand Down

0 comments on commit cd1f9dc

Please sign in to comment.