Skip to content

Commit

Permalink
more mmirs fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tepickering committed Feb 8, 2024
1 parent 7259d22 commit 94ac888
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
13 changes: 13 additions & 0 deletions mmtwfs/scripts/fix_mmirs_exposure_time.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,16 @@ def main():
timedict = {}
for f in files:
with fits.open(f) as hdulist:
hdulist.verify('fix')
hdr = hdulist[-1].header
if 'DATE-OBS' in hdr:
timedict[str(f)] = hdr['DATE-OBS']
elif 'DATE' in hdr:
timedict[str(f)] = hdr['DATE']
elif 'DATEOBS' in hdr:
time_string = f"{hdr['DATEOBS']} {hdr['UT']}"
time_format = "%a %b %d %Y %H:%M:%S"
timedict[str(f)] = datetime.strptime(time_string, time_format).strftime("%Y-%m-%dT%H:%M:%S")
else:
log.error(f"No valid time information in {str(f)}")
return
Expand All @@ -79,6 +84,7 @@ def main():

f = files[i]
with fits.open(f) as hdulist:
hdulist.verify('fix')
changed = False
for h in hdulist:
if 'EXPTIME' in h.header:
Expand All @@ -91,6 +97,13 @@ def main():
changed = True
else:
log.info(f"EXPTIME already set to {h.header['EXPTIME']} for {str(f)}")
if 'CAMERA' not in h.header:
log.info(f"Adding CAMERA keyword to header for {str(f)}")
if h.header['WFSNAME'] == 'mmirs1':
h.header['CAMERA'] = 1
else:
h.header['CAMERA'] = 2
changed = True
if changed and not args.dryrun:
hdulist.writeto(f, overwrite=True, output_verify="silentfix")

Expand Down
7 changes: 7 additions & 0 deletions mmtwfs/scripts/reanalyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,13 @@ def check_image(f, wfskey=None):
if 'mmirs' in f.name:
wfskey = 'mmirs'

if wfskey == 'mmirs':
if 'CAMERA' not in hdr:
if hdr['WFSNAME'] == 'mmirs1':
hdr['CAMERA'] = 1
else:
hdr['CAMERA'] = 2

# check for binospec
if 'bino' in f.name or 'wfs_ff_cal_img' in f.name:
wfskey = 'binospec'
Expand Down

0 comments on commit 94ac888

Please sign in to comment.