From c236091b7f953ef59c453a61ac390cd319bfef17 Mon Sep 17 00:00:00 2001 From: Charles-Philippe Lajoie Date: Wed, 19 Feb 2025 12:44:40 -0500 Subject: [PATCH 1/3] initial commit to allow detector names with WFI instead of SCA --- stpsf/roman.py | 11 ++++++++++- stpsf/stpsf_core.py | 5 ++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/stpsf/roman.py b/stpsf/roman.py index 241e2ff..45b2e9e 100644 --- a/stpsf/roman.py +++ b/stpsf/roman.py @@ -374,7 +374,11 @@ def _get_fits_header(self, result, options): super()._get_fits_header(result, options) result[0].header['DETXPIXL'] = (self.detector_position[0], 'X pixel position (for field dependent aberrations)') result[0].header['DETYPIXL'] = (self.detector_position[1], 'Y pixel position (for field dependent aberrations)') - result[0].header['DETECTOR'] = (self.detector, 'Detector selected') + + if self.telescope == 'Roman': + result[0].header['DETECTOR'] = (self.detector.replace("SCA", "WFI"), 'Detector selected') + else: + result[0].header['DETECTOR'] = (self.detector, 'Detector selected') def _calc_psf_format_output(self, result, options): """ @@ -739,6 +743,11 @@ def detector(self, value): """ The current WFI detector. See WFI.detector_list for valid values. """ + + + if value.startswith("WFI"): + # Allow users to input detector names as WFIxy; this is then changed to SCAxy for backward compatibility. + value = "SCA" + value[-2:] if value.upper() not in self.detector_list: raise ValueError('Invalid detector. Valid detector names are: {}'.format(', '.join(self.detector_list))) diff --git a/stpsf/stpsf_core.py b/stpsf/stpsf_core.py index 8617295..8f35005 100644 --- a/stpsf/stpsf_core.py +++ b/stpsf/stpsf_core.py @@ -355,7 +355,10 @@ def _get_fits_header(self, result, options): result[0].header['VERSION'] = (version, 'STPSF software version') result[0].header['DATAVERS'] = (self._data_version, 'STPSF reference data files version') - result[0].header['DET_NAME'] = (self.detector, 'Name of detector on this instrument') + if self.telescope == 'Roman': + result[0].header['DET_NAME'] = (self.detector.replace("SCA", "WFI"), 'Name of detector on this instrument') + else: + result[0].header['DET_NAME'] = (self.detector, 'Name of detector on this instrument') # Correct detector pixel coordinates to allow for even arrays to be centered on half pixel boundary dpos = np.asarray(self.detector_position, dtype=float) From 0dd513292beee5ea279364752c9c6840855d33bd Mon Sep 17 00:00:00 2001 From: Charles-Philippe Lajoie Date: Thu, 20 Feb 2025 10:22:34 -0500 Subject: [PATCH 2/3] Fixed another instance of detector name change for WFI --- stpsf/gridded_library.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/stpsf/gridded_library.py b/stpsf/gridded_library.py index e96098b..a5bb84d 100644 --- a/stpsf/gridded_library.py +++ b/stpsf/gridded_library.py @@ -308,7 +308,8 @@ def create_grid(self): model_list = [] for k, det in enumerate(self.detector_list): if self.verbose is True: - print(' Running detector: {}'.format(det)) + print_det = det.replace("SCA", "WFI") if self.instr.upper() == "WFI" else det + print(' Running detector: {}'.format(print_det)) # Create an array to fill ([i, y, x]) psf_size = self.fov_pixels * self.oversample @@ -359,7 +360,10 @@ def create_grid(self): meta = OrderedDict() meta['INSTRUME'] = (self.instr, 'Instrument name') - meta['DETECTOR'] = (det, 'Detector name') + if self.instr.upper() == 'WFI': + meta['DETECTOR'] = (det.replace("SCA", "WFI"), 'Detector name') + else: + meta['DETECTOR'] = (det, 'Detector name') meta['FILTER'] = (self.filter, 'Filter name') meta['PUPILOPD'] = (psf[ext].header['PUPILOPD'], 'Pupil OPD source name') meta['OPD_FILE'] = (psf[ext].header['OPD_FILE'], 'Pupil OPD file name') From 4392f8476cfef0d71c828e93dde735611ac3fa26 Mon Sep 17 00:00:00 2001 From: Charles-Philippe Lajoie Date: Thu, 20 Feb 2025 10:46:02 -0500 Subject: [PATCH 3/3] Updated distortion.py since header now contains WFIxy --- stpsf/distortion.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/stpsf/distortion.py b/stpsf/distortion.py index 4a216e9..365e3fc 100644 --- a/stpsf/distortion.py +++ b/stpsf/distortion.py @@ -125,7 +125,7 @@ def distort_image( instrument = hdu_list[0].header['INSTRUME'].upper().strip() if instrument == 'WFI': - aper_name = 'WFI' + hdu_list[0].header['DETECTOR'][-2:] + '_FULL' + aper_name = hdu_list[0].header['DETECTOR'] + '_FULL' else: aper_name = hdu_list[0].header['APERNAME'].upper() @@ -246,7 +246,7 @@ def apply_distortion(hdulist_or_filename=None, fill_value=0): # Log instrument and detector names instrument = hdu_list[0].header['INSTRUME'].upper().strip() if instrument == 'WFI': - aper_name = 'WFI' + hdu_list[0].header['DETECTOR'][-2:] + '_FULL' + aper_name = hdu_list[0].header['DETECTOR'] + '_FULL' else: aper_name = hdu_list[0].header['APERNAME'].upper() @@ -315,7 +315,7 @@ def apply_rotation(hdulist_or_filename=None, rotate_value=None, crop=True): # Log instrument and detector names instrument = hdu_list[0].header['INSTRUME'].upper().strip() if instrument == 'WFI': - aper_name = 'WFI' + hdu_list[0].header['DETECTOR'][-2:] + '_FULL' + aper_name = hdu_list[0].header['DETECTOR'] + '_FULL' else: aper_name = hdu_list[0].header['APERNAME'].upper()