From 341bf6a39e107b2a81a5b176582ecf2738d47a67 Mon Sep 17 00:00:00 2001 From: Nadia Dencheva Date: Thu, 11 Aug 2016 14:53:48 -0400 Subject: Catch KeyError when deleting header keywords --- stwcs/wcsutil/altwcs.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'stwcs/wcsutil/altwcs.py') diff --git a/stwcs/wcsutil/altwcs.py b/stwcs/wcsutil/altwcs.py index 64cdc87..050a15e 100644 --- a/stwcs/wcsutil/altwcs.py +++ b/stwcs/wcsutil/altwcs.py @@ -356,7 +356,10 @@ def deleteWCS(fname, ext, wcskey=" ", wcsname=" "): if hwcs is None: continue for k in hwcs[::-1]: - del hdr[k] + try: + del hdr[k] + except KeyError: + pass prexts.append(i) if prexts != []: print('Deleted all instances of WCS with key %s in extensions' % wkey, prexts) @@ -455,7 +458,7 @@ def _restore(fobj, ukey, fromextnum, if kw in fobj[toextension].header: fobj[toextension].header[kw] = 0.0 - + # header operations -- cgit