diff --git a/CHANGES.rst b/CHANGES.rst index 17cc07f3a9..5a53ec71f7 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -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 diff --git a/pypeit/calibrations.py b/pypeit/calibrations.py index e849dd8123..8291fe1d9d 100644 --- a/pypeit/calibrations.py +++ b/pypeit/calibrations.py @@ -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, @@ -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, @@ -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, @@ -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. @@ -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 @@ -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}') @@ -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}') @@ -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}') @@ -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, @@ -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,