summaryrefslogtreecommitdiff
path: root/lib/stwcs/wcsutil/hstwcs.py
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2012-01-26 11:50:20 -0500
committerhack <hack@stsci.edu>2012-01-26 11:50:20 -0500
commit50b7b6939954798bee2ce2e6979f916ce67f42b7 (patch)
treec42c682dd51255555b32cc57c2c68cb2b9f42dd2 /lib/stwcs/wcsutil/hstwcs.py
parentd93af18d08a2becf9a9407987b1d7b6b3595ddd5 (diff)
downloadstwcs_hcf-50b7b6939954798bee2ce2e6979f916ce67f42b7.tar.gz
This update to STWCS.wcsutil includes the following changes:
- removes use of RMS_RA and RMS_Dec in science header WCS keywords in favor of FITS standard keywords CRDER* - add default WCSNAME keyword to header created from .wcs2header() method of HSTWCS if that keyword did not exist in input image header - update WCSCORR table to populate RMS_RA and RMS_Dec columns using CRDER* keywords. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@14488 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/wcsutil/hstwcs.py')
-rw-r--r--lib/stwcs/wcsutil/hstwcs.py47
1 files changed, 47 insertions, 0 deletions
diff --git a/lib/stwcs/wcsutil/hstwcs.py b/lib/stwcs/wcsutil/hstwcs.py
index d90b4a5..d138f08 100644
--- a/lib/stwcs/wcsutil/hstwcs.py
+++ b/lib/stwcs/wcsutil/hstwcs.py
@@ -17,6 +17,46 @@ from mappings import basic_wcs
__docformat__ = 'restructuredtext'
+#
+#### Utility functions copied from 'updatewcs.utils' to avoid circular imports
+#
+def extract_rootname(kwvalue,suffix=""):
+ """ Returns the rootname from a full reference filename
+
+ If a non-valid value (any of ['','N/A','NONE','INDEF',None]) is input,
+ simply return a string value of 'NONE'
+
+ This function will also replace any 'suffix' specified with a blank.
+ """
+ # check to see whether a valid kwvalue has been provided as input
+ if kwvalue.strip() in ['','N/A','NONE','INDEF',None]:
+ return 'NONE' # no valid value, so return 'NONE'
+
+ # for a valid kwvalue, parse out the rootname
+ # strip off any environment variable from input filename, if any are given
+ if '$' in kwvalue:
+ fullval = kwvalue[kwvalue.find('$')+1:]
+ else:
+ fullval = kwvalue
+ # Extract filename without path from kwvalue
+ fname = os.path.basename(fullval).strip()
+
+ # Now, rip out just the rootname from the full filename
+ rootname = fileutil.buildNewRootname(fname)
+
+ # Now, remove any known suffix from rootname
+ rootname = rootname.replace(suffix,'')
+ return rootname.strip()
+
+def build_default_wcsname(idctab):
+
+ idcname = extract_rootname(idctab,suffix='_idc')
+ wcsname = 'IDC_' + idcname
+ return wcsname
+
+#
+#### HSTWCS Class definition
+#
class HSTWCS(WCS):
def __init__(self, fobj=None, ext=None, minerr=0.0, wcskey=" "):
@@ -283,6 +323,13 @@ class HSTWCS(WCS):
if self.wcs.has_cd():
h = altwcs.pc2cd(h, key=self.wcskey)
+ if 'wcsname' not in h:
+ if self.idctab is not None:
+ wname = build_default_wcsname(self.idctab)
+ else:
+ wname = 'DEFAULT'
+ h.update('wcsname',value=wname)
+
if idc2hdr:
for card in self._idc2hdr():
h.update(card.key,value=card.value,comment=card.comment)