Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change Roman detector naming to support WFIxy #71

Draft
wants to merge 4 commits into
base: develop
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stpsf/distortion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down Expand Up @@ -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()

Expand Down
8 changes: 6 additions & 2 deletions stpsf/gridded_library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down
11 changes: 10 additions & 1 deletion stpsf/roman.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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)))

Expand Down
5 changes: 4 additions & 1 deletion stpsf/stpsf_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down