From 5efd889bb01b592bd462fb15d78aad1b4fba6902 Mon Sep 17 00:00:00 2001 From: mcara Date: Tue, 23 Feb 2016 21:03:53 +0000 Subject: 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 --- lib/stwcs/updatewcs/wfpc2_dgeo.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'lib/stwcs/updatewcs/wfpc2_dgeo.py') 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) -- cgit