From e88d4ce148bd7ea094591543874724cd430b0c59 Mon Sep 17 00:00:00 2001 From: hack Date: Fri, 4 Nov 2011 21:07:32 +0000 Subject: 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 --- lib/stwcs/wcsutil/wcscorr.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'lib/stwcs/wcsutil') 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 -- cgit