summaryrefslogtreecommitdiff
path: root/lib/stwcs/updatewcs/wfpc2_dgeo.py
diff options
context:
space:
mode:
authormcara <mcara@stsci.edu>2016-02-23 16:03:53 -0500
committermcara <mcara@stsci.edu>2016-02-23 16:03:53 -0500
commit5efd889bb01b592bd462fb15d78aad1b4fba6902 (patch)
treef2c27df344812477ffa1446f72a82fb896af45bb /lib/stwcs/updatewcs/wfpc2_dgeo.py
parentc3f5a3514eff40b3aa178b2996d997a98f03cee0 (diff)
downloadstwcs_hcf-5efd889bb01b592bd462fb15d78aad1b4fba6902.tar.gz
For WFPC2 only, stwcs should re-create missing d2imfile from ``ODGEOFIL`` if ``DGEOFILE`` was set to 'N/A'. See ticket #1244 for more details.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@49347 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/updatewcs/wfpc2_dgeo.py')
-rw-r--r--lib/stwcs/updatewcs/wfpc2_dgeo.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/lib/stwcs/updatewcs/wfpc2_dgeo.py b/lib/stwcs/updatewcs/wfpc2_dgeo.py
index 884bd7e..e0c01f2 100644
--- a/lib/stwcs/updatewcs/wfpc2_dgeo.py
+++ b/lib/stwcs/updatewcs/wfpc2_dgeo.py
@@ -17,7 +17,7 @@ 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
@@ -33,16 +33,19 @@ def update_wfpc2_d2geofile(filename, fhdu=None):
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
if fhdu is None:
fhdu = fileutil.openImage(filename, mode='update')
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)