Skip to content

Commit

Permalink
make MAX_VALID_DATA modifiable
Browse files Browse the repository at this point in the history
  • Loading branch information
gbrammer committed Feb 12, 2024
1 parent 772442b commit 623340c
Showing 1 changed file with 28 additions and 13 deletions.
41 changes: 28 additions & 13 deletions msaexp/slit_combine.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

HUBER_ALPHA = 7

MAX_VALID_DATA = 100

def split_visit_groups(files, join=[0, 3], gratings=['PRISM']):
"""
Compute groupings of `SlitModel` files based on exposure, visit, detector, slit_id
Expand Down Expand Up @@ -512,6 +514,7 @@ def parse_data(self, verbose=True):
Read science, variance and trace data from the ``slits`` SlitModel files
"""
import scipy.ndimage as nd
global MAX_VALID_DATA

slits = self.slits

Expand Down Expand Up @@ -620,7 +623,7 @@ def parse_data(self, verbose=True):

self.bad_exposures = bad_exposures

bad |= sci > 100
bad |= sci > MAX_VALID_DATA
bad |= sci == 0

# bad |= np.abs(yslit > 8)
Expand Down Expand Up @@ -1797,6 +1800,18 @@ def extract_spectra(target='1208_5110240', root='nirspec', path_to_files='./', f

if trace_with_ypos in ['auto']:
trace_with_ypos = ('b' not in target) & (not get_background)

if root.startswith('glazebrook-v'):
utils.log_comment(utils.LOGFILE, ' ! Auto glazebrook', verbose=True)
trace_from_yoffset = True

elif 'maseda' in root:
utils.log_comment(utils.LOGFILE, ' ! Auto maseda', verbose=True)
trace_from_yoffset = True

elif 'smacs0723-ero-v' in root:
utils.log_comment(utils.LOGFILE, ' ! Auto SMACS0723', verbose=True)
trace_from_yoffset = True

obj = SlitGroup(groups[g], g, position_key=position_key,
diffs=diffs, #(True & (~isinstance(id, str))),
Expand Down Expand Up @@ -1859,18 +1874,18 @@ def extract_spectra(target='1208_5110240', root='nirspec', path_to_files='./', f
continue

ind = None
if root.startswith('glazebrook-v'):
# flipped??
utils.log_comment(utils.LOGFILE, ' ! Flip glazebrook', verbose=True)
ind = [0,2,1]

elif 'maseda' in root:
utils.log_comment(utils.LOGFILE, ' ! Flip maseda', verbose=True)
ind = [0,2,1]

elif 'smacs0723-ero-v' in root:
utils.log_comment(utils.LOGFILE, ' ! Flip SMACS0723', verbose=True)
ind = [0,2,1]
# if root.startswith('glazebrook-v'):
# # flipped??
# utils.log_comment(utils.LOGFILE, ' ! Flip glazebrook', verbose=True)
# ind = [0,2,1]
#
# elif 'maseda' in root:
# utils.log_comment(utils.LOGFILE, ' ! Flip maseda', verbose=True)
# ind = [0,2,1]
#
# elif 'smacs0723-ero-v' in root:
# utils.log_comment(utils.LOGFILE, ' ! Flip SMACS0723', verbose=True)
# ind = [0,2,1]

if ind is not None:
obj.xslit = obj.xslit[ind,:]
Expand Down

0 comments on commit 623340c

Please sign in to comment.