summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/stwcs/updatewcs/wfpc2_dgeo.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/lib/stwcs/updatewcs/wfpc2_dgeo.py b/lib/stwcs/updatewcs/wfpc2_dgeo.py
index b7b064a..e57bb5c 100644
--- a/lib/stwcs/updatewcs/wfpc2_dgeo.py
+++ b/lib/stwcs/updatewcs/wfpc2_dgeo.py
@@ -17,6 +17,23 @@ def update_wfpc2_d2geofile(filename, fhdu=None):
"""
Creates a D2IMFILE from the DGEOFILE for a WFPC2 image (input), and
modifies the header to reflect the new usage.
+
+ Parameters
+ ----------
+ filename: string
+ Name of WFPC2 file to be processed. This file will be updated
+ to delete any reference to a DGEOFILE and add a D2IMFILE to replace
+ that correction when running updatewcs.
+ fhdu: object
+ FITS object for WFPC2 image. If user has already opened the WFPC2
+ file, they can simply pass that FITS object in for direct processing.
+
+ Returns
+ -------
+ d2imfile: string
+ Name of D2IMFILE created from DGEOFILE. The D2IMFILE keyword in the
+ image header will be updated/added to point to this newly created file.
+
"""
close_fhdu = False
@@ -25,7 +42,10 @@ def update_wfpc2_d2geofile(filename, fhdu=None):
close_fhdu = True
dgeofile = fhdu['PRIMARY'].header.get('DGEOFILE', None)
- if dgeofile not in [None, "N/A", "", " "]:
+ already_converted = dgeofile not in [None, "N/A", "", " "]
+ if already_converted or 'ODGEOFIL' in fhdu['PRIMARY'].header:
+ if not already_converted:
+ dgeofile = fhdu['PRIMARY'].header.get('ODGEOFIL', None)
logger.info('Converting DGEOFILE %s into D2IMFILE...' % dgeofile)
rootname = filename[:filename.find('.fits')]
d2imfile = convert_dgeo_to_d2im(dgeofile,rootname)
@@ -35,7 +55,8 @@ def update_wfpc2_d2geofile(filename, fhdu=None):
else:
d2imfile = None
fhdu['PRIMARY'].header['DGEOFILE'] = 'N/A'
- fhdu['PRIMARY'].header['D2IMFILE'] = 'N/A'
+ if 'D2IMFILE' not in fhdu['PRIMARY'].header:
+ fhdu['PRIMARY'].header['D2IMFILE'] = 'N/A'
# Only close the file handle if opened in this function
if close_fhdu: