diff options
author | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-11 14:53:48 -0400 |
---|---|---|
committer | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-11 14:53:48 -0400 |
commit | 341bf6a39e107b2a81a5b176582ecf2738d47a67 (patch) | |
tree | ff14adfad97d69385aabd4dc8f84bfb902f7c160 /stwcs | |
parent | 892edca9d767cf2dfea48a60c9cc0eb97ef2e4e0 (diff) | |
download | stwcs_hcf-341bf6a39e107b2a81a5b176582ecf2738d47a67.tar.gz |
Catch KeyError when deleting header keywords
Diffstat (limited to 'stwcs')
-rw-r--r-- | stwcs/wcsutil/altwcs.py | 7 |
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 |