summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhack <hack@stsci.edu>2012-02-17 15:00:12 -0500
committerhack <hack@stsci.edu>2012-02-17 15:00:12 -0500
commit0755855e563f8fbd9cc8e6c2698fad8fa3044734 (patch)
tree0658d255ddad626439606e7d095ba775c3738c2b
parentd50931dcc2c5ec0476ee60d94ebace3b1ed45a32 (diff)
downloadstwcs_hcf-0755855e563f8fbd9cc8e6c2698fad8fa3044734.tar.gz
Add logic to wcscorr.update_wcscorr that allows it to reformat an old WCSCORR table extension written out by previous versions of this code. The newly formatted table should contain all the previous table's information (as it gets created using init_wcscorr) and will conform to the latest table format (for now and for whatever that may end up being in the future). This will prevent the code from crashing when processing data updated with previous versions of 'updatewcs()' or 'tweakreg' from the drizzlepac package.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stsci_python/trunk/stwcs@15172 fe389314-cf27-0410-b35b-8c050e845b92
-rw-r--r--lib/stwcs/wcsutil/wcscorr.py16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/stwcs/wcsutil/wcscorr.py b/lib/stwcs/wcsutil/wcscorr.py
index 0bc7bc2..d9d42cd 100644
--- a/lib/stwcs/wcsutil/wcscorr.py
+++ b/lib/stwcs/wcsutil/wcscorr.py
@@ -281,6 +281,21 @@ def update_wcscorr(dest, source=None, extname='SCI', wcs_id=None, active=True):
# Initialize the WCSCORR table extension in dest if not already present
init_wcscorr(dest)
+ # check to see whether or not this is an up-to-date table
+ # replace with newly initialized table with current format
+ old_table = dest['WCSCORR']
+ wcscorr_cols = ['WCS_ID','EXTVER', 'SIPNAME',
+ 'HDRNAME', 'NPOLNAME', 'D2IMNAME']
+
+ for colname in wcscorr_cols:
+ if colname not in old_table.data.columns.names:
+ print "WARNING: Replacing outdated WCSCORR table..."
+ outdated_table = old_table.copy()
+ del dest['WCSCORR']
+ init_wcscorr(dest)
+ old_table = dest['WCSCORR']
+ break
+
# Current implementation assumes the same WCS keywords are in each
# extension version; if this should not be assumed then this can be
# modified...
@@ -307,7 +322,6 @@ def update_wcscorr(dest, source=None, extname='SCI', wcs_id=None, active=True):
# create new table for hdr and populate it with the newly updated values
new_table = create_wcscorr(descrip=True,numrows=0, padding=len(wcs_keys)*numext)
- old_table = dest['WCSCORR']
prihdr = source[0].header
# Get headerlet related keywords here