summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2011-11-04 17:07:32 -0400
committerhack <hack@stsci.edu>2011-11-04 17:07:32 -0400
commite88d4ce148bd7ea094591543874724cd430b0c59 (patch)
treef3e871b8c775e5e8f9755cc54b57c9a1bacec9ef
parentdfce74536e2b65362441eb9016ea3c2d90644e13 (diff)
downloadstwcs_hcf-e88d4ce148bd7ea094591543874724cd430b0c59.tar.gz
The WCSCORR table update will not crash anymore (based on my testing) when WCSNAME is missing from the image PRIMARY WCS. This required adding a new function to define the default WCSNAME value based on the IDCTAB so that it could be called upon initialization of the table, and when updating it if WCSNAME is missing.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@13961 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r--lib/stwcs/updatewcs/utils.py6
-rw-r--r--lib/stwcs/wcsutil/wcscorr.py10
2 files changed, 11 insertions, 5 deletions
diff --git a/lib/stwcs/updatewcs/utils.py b/lib/stwcs/updatewcs/utils.py
index f851522..0e7d77b 100644
--- a/lib/stwcs/updatewcs/utils.py
+++ b/lib/stwcs/updatewcs/utils.py
@@ -99,6 +99,12 @@ def build_distname(sipname,npolname,d2imname):
return distname
+def build_default_wcsname(idctab):
+
+ idcname = extract_rootname(idctab,suffix='_idc')
+ wcsname = 'IDC_' + idcname
+ return wcsname
+
def build_sipname(fobj):
try:
sipname = fobj[0].header["SIPNAME"]
diff --git a/lib/stwcs/wcsutil/wcscorr.py b/lib/stwcs/wcsutil/wcscorr.py
index 96883c5..3071d0d 100644
--- a/lib/stwcs/wcsutil/wcscorr.py
+++ b/lib/stwcs/wcsutil/wcscorr.py
@@ -134,10 +134,7 @@ def init_wcscorr(input, force=False):
wcskey=uwkey)
wcshdr = wcs.wcs2header()
if 'WCSNAME' + uwkey not in wcshdr:
- idctab = fileutil.osfn(fimg[0].header['idctab'])
- idcname = os.path.split(idctab)[-1]
- idcname = idcname[:idcname.find('_')]
- wcsid = 'IDC_' + idcname
+ wcsid = utils.build_default_wcsname(fimg[0].header['idctab'])
else:
wcsid = wcshdr['WCSNAME' + uwkey]
@@ -300,7 +297,10 @@ def update_wcscorr(dest, source=None, extname='SCI', wcs_id=None, active=True):
else:
tab_extver = extver
hdr = source[extn].header
- wcsname = hdr['WCSNAME' + wcs_key]
+ if 'WCSNAME'+wcs_key in hdr:
+ wcsname = hdr['WCSNAME' + wcs_key]
+ else:
+ wcsname = utils.build_default_wcsname(hdr['idctab'])
selection = {'WCS_ID': wcsname, 'EXTVER': tab_extver,
'SIPNAME':sipname, 'HDRNAME': hdrname,
'NPOLNAME': npolname, 'D2IMNAME':d2imname