From 8effc9a9897ffc5767d022fadb74d68dbf00c378 Mon Sep 17 00:00:00 2001 From: dencheva Date: Fri, 29 May 2015 15:07:47 +0000 Subject: Add RADESYS to headers. Fixed cleanWCS which was trying to delete WCS keywords from the primary header and raising an error. Resolves #1173. git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@40546 fe389314-cf27-0410-b35b-8c050e845b92 --- lib/stwcs/updatewcs/__init__.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'lib/stwcs/updatewcs') diff --git a/lib/stwcs/updatewcs/__init__.py b/lib/stwcs/updatewcs/__init__.py index d09f5a8..9509dbd 100644 --- a/lib/stwcs/updatewcs/__init__.py +++ b/lib/stwcs/updatewcs/__init__.py @@ -347,7 +347,7 @@ def newIDCTAB(fname): def cleanWCS(fname): # A new IDCTAB means all previously computed WCS's are invalid - # We are deleting all of them except the original OPUS WCS.nvalidates all WCS's. + # We are deleting all of them except the original OPUS WCS. f = fits.open(fname, mode='update') keys = wcsutil.wcskeys(f[1].header) # Remove the primary WCS from the list @@ -355,9 +355,13 @@ def cleanWCS(fname): keys.remove(' ') except ValueError: pass - fext = list(range(len(f))) + fext = list(range(1, len(f))) for key in keys: - wcsutil.deleteWCS(fname, ext=fext, wcskey=key) + try: + wcsutil.deleteWCS(fname, ext=fext, wcskey=key) + except KeyError: + # Some extensions don't have the alternate (or any) WCS keywords + continue def getCorrections(instrument): """ -- cgit