summaryrefslogtreecommitdiff
path: root/stwcs
diff options
context:
space:
mode:
authorNadia Dencheva <nadia.dencheva@gmail.com>2016-08-11 14:53:48 -0400
committerNadia Dencheva <nadia.dencheva@gmail.com>2016-08-11 14:53:48 -0400
commit341bf6a39e107b2a81a5b176582ecf2738d47a67 (patch)
treeff14adfad97d69385aabd4dc8f84bfb902f7c160 /stwcs
parent892edca9d767cf2dfea48a60c9cc0eb97ef2e4e0 (diff)
downloadstwcs_hcf-341bf6a39e107b2a81a5b176582ecf2738d47a67.tar.gz
Catch KeyError when deleting header keywords
Diffstat (limited to 'stwcs')
-rw-r--r--stwcs/wcsutil/altwcs.py7
1 files changed, 5 insertions, 2 deletions
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