diff options
author | Nadia Dencheva <nadia.astropy@gmail.com> | 2016-08-11 22:43:01 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-08-11 22:43:01 -0400 |
commit | 13f7b5958e4ec02bf3a2324d28db57d865349514 (patch) | |
tree | ff14adfad97d69385aabd4dc8f84bfb902f7c160 | |
parent | 892edca9d767cf2dfea48a60c9cc0eb97ef2e4e0 (diff) | |
parent | 341bf6a39e107b2a81a5b176582ecf2738d47a67 (diff) | |
download | stwcs_hcf-13f7b5958e4ec02bf3a2324d28db57d865349514.tar.gz |
Merge pull request #13 from nden/fix-deleteWCS
Catch KeyError when deleting header keywords
-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 |