Skip to content

Commit

Permalink
Merge pull request #1663 from pypeit/hotfix_bpm
Browse files Browse the repository at this point in the history
hotfix BPM
  • Loading branch information
rcooke-ast authored Sep 10, 2023
2 parents 0187781 + 1c550db commit 8a8d0e7
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Hotfix for skysub regions GUI that used np.bool
- Hotfix to stop pypeit_setup from crashing on data from lbt_luci1, lbt_luci2, magellan_fire,
magellan_fire_long, p200_tspec, or vlt_sinfoni.
- Hotfix to set BPM for each type of calibration file.
- Adds Keck/ESI to PypeIt
- Instrumental FWHM map is calculated and output in ``Calibrations`` and ``spec1d`` files.
- Adds Keck/ESI to PypeIt
Expand Down
30 changes: 28 additions & 2 deletions pypeit/calibrations.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,9 @@ def get_arc(self):
self.msarc = frame['class'].from_file(cal_file)
return self.msarc

# Reset the BPM
self.get_bpm(frame=raw_files[0])

# Otherwise, create the processed file.
msgs.info(f'Preparing a {frame["class"].calib_type} calibration frame.')
self.msarc = buildimage.buildimage_fromlist(self.spectrograph, self.det,
Expand Down Expand Up @@ -353,6 +356,9 @@ def get_tiltimg(self):
self.mstilt = frame['class'].from_file(cal_file)
return self.mstilt

# Reset the BPM
self.get_bpm(frame=raw_files[0])

# Otherwise, create the processed file.
msgs.info(f'Preparing a {frame["class"].calib_type} calibration frame.')
self.mstilt = buildimage.buildimage_fromlist(self.spectrograph, self.det,
Expand Down Expand Up @@ -399,6 +405,9 @@ def get_align(self):
self.alignments.is_synced(self.slits)
return self.alignments

# Reset the BPM
self.get_bpm(frame=raw_files[0])

# Otherwise, create the processed file.
msgs.info(f'Preparing a {frame["class"].calib_type} calibration frame.')
msalign = buildimage.buildimage_fromlist(self.spectrograph, self.det,
Expand Down Expand Up @@ -506,7 +515,7 @@ def get_dark(self):
# Return it
return self.msdark

def get_bpm(self):
def get_bpm(self, frame=None):
"""
Load or generate the bad pixel mask.
Expand All @@ -519,8 +528,11 @@ def get_bpm(self):
"""
# Check internals
self._chk_set(['par', 'det'])
# Set the frame to use for the BPM
if frame is None:
frame = self.fitstbl.frame_paths(self.frame)
# Build it
self.msbpm = self.spectrograph.bpm(self.fitstbl.frame_paths(self.frame), self.det,
self.msbpm = self.spectrograph.bpm(frame, self.det,
msbias=self.msbias if self.par['bpm_usebias'] else None)
# Return
return self.msbpm
Expand Down Expand Up @@ -602,6 +614,8 @@ def get_flats(self):
# Check if the image files are the same
pix_is_illum = Counter(raw_illum_files) == Counter(raw_pixel_files)
if len(raw_pixel_files) > 0:
# Reset the BPM
self.get_bpm(frame=raw_pixel_files[0])
msgs.info('Creating pixel-flat calibration frame using files: ')
for f in raw_pixel_files:
msgs.prindent(f'{Path(f).name}')
Expand All @@ -610,6 +624,8 @@ def get_flats(self):
raw_pixel_files, dark=self.msdark,
bias=self.msbias, bpm=self.msbpm)
if len(raw_lampoff_files) > 0:
# Reset the BPM
self.get_bpm(frame=raw_lampoff_files[0])
msgs.info('Subtracting lamp off flats using files: ')
for f in raw_lampoff_files:
msgs.prindent(f'{Path(f).name}')
Expand All @@ -633,6 +649,8 @@ def get_flats(self):

# Only build illum_flat if the input files are different from the pixel flat
if not pix_is_illum and len(raw_illum_files) > 0:
# Reset the BPM
self.get_bpm(frame=raw_illum_files[0])
msgs.info('Creating slit-illumination flat calibration frame using files: ')
for f in raw_illum_files:
msgs.prindent(f'{Path(f).name}')
Expand Down Expand Up @@ -751,6 +769,10 @@ def get_slits(self):
msgs.info('Creating edge tracing calibration frame using files: ')
for f in raw_trace_files:
msgs.prindent(f'{Path(f).name}')

# Reset the BPM
self.get_bpm(frame=raw_trace_files[0])

traceImage = buildimage.buildimage_fromlist(self.spectrograph, self.det,
self.par['traceframe'], raw_trace_files,
bias=self.msbias, bpm=self.msbpm,
Expand All @@ -760,6 +782,10 @@ def get_slits(self):
msgs.info('Subtracting lamp off flats using files: ')
for f in raw_lampoff_files:
msgs.prindent(f'{Path(f).name}')

# Reset the BPM
self.get_bpm(frame=raw_trace_files[0])

lampoff_flat = buildimage.buildimage_fromlist(self.spectrograph, self.det,
self.par['lampoffflatsframe'],
raw_lampoff_files, dark=self.msdark,
Expand Down

0 comments on commit 8a8d0e7

Please sign in to comment.