From 699fc840e70e4bf9a62afd1b43e66a75b159d16e Mon Sep 17 00:00:00 2001 From: Jim Chiang Date: Thu, 6 Jun 2019 14:59:22 -0700 Subject: [PATCH 1/2] re-insert the WCSAXES keyword to precede other WCS keywords --- python/desc/imsim/camera_readout.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/python/desc/imsim/camera_readout.py b/python/desc/imsim/camera_readout.py index 531ba1a6..9264ec03 100644 --- a/python/desc/imsim/camera_readout.py +++ b/python/desc/imsim/camera_readout.py @@ -461,6 +461,12 @@ def write_fits_file(self, outfile, overwrite=True, run_number=None, """ output = fits.HDUList(fits.PrimaryHDU()) output[0].header = self.eimage[0].header + # Re-insert the WCSAXES keyword to precede any other WCS + # keywords as stipulated in the FITS Standard, version 4.0, + # section 8.2. + wcsaxes = output[0].header['WCSAXES'] + del output[0].header['WCSAXES'] + output[0].header.insert(5, ('WCSAXES', wcsaxes, '')) if run_number is None: run_number = self.visit output[0].header['RUNNUM'] = str(run_number) From ef7e897e309b395f9c76872562d58321407d8804 Mon Sep 17 00:00:00 2001 From: James Chiang Date: Sun, 9 Jun 2019 07:42:15 -0700 Subject: [PATCH 2/2] add further explanation in comment for re-inserting WCSAXES keyword --- python/desc/imsim/camera_readout.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/python/desc/imsim/camera_readout.py b/python/desc/imsim/camera_readout.py index 9264ec03..bcc5ccf7 100644 --- a/python/desc/imsim/camera_readout.py +++ b/python/desc/imsim/camera_readout.py @@ -461,9 +461,10 @@ def write_fits_file(self, outfile, overwrite=True, run_number=None, """ output = fits.HDUList(fits.PrimaryHDU()) output[0].header = self.eimage[0].header - # Re-insert the WCSAXES keyword to precede any other WCS - # keywords as stipulated in the FITS Standard, version 4.0, - # section 8.2. + # Since `.header` acts like an unordered dict when set like + # this, we need to re-insert the WCSAXES keyword to precede + # any other WCS keywords as stipulated in the FITS Standard, + # version 4.0, section 8.2. wcsaxes = output[0].header['WCSAXES'] del output[0].header['WCSAXES'] output[0].header.insert(5, ('WCSAXES', wcsaxes, ''))