diff options
author | hack <hack@stsci.edu> | 2014-10-13 18:22:46 -0400 |
---|---|---|
committer | hack <hack@stsci.edu> | 2014-10-13 18:22:46 -0400 |
commit | 34a65378c98e1a2c017cce36f06e88d7052e454d (patch) | |
tree | 9ddc783fa94aa262810eb64aba70d7730f2949fa /lib/stwcs/wcsutil/altwcs.py | |
parent | ce0b790f0d19bb1b85328ee64f83a67f5a9905f5 (diff) | |
download | stwcs_hcf-34a65378c98e1a2c017cce36f06e88d7052e454d.tar.gz |
The logic in altwcs.getKeyFromName() was improved to correctly handle the random ordering of keys in the wcsnames dict. This update supports the changes for Ticket #1165.
git-svn-id: http://svn.stsci.edu/svn/ssb/stsci_python/stwcs/trunk@34873 fe389314-cf27-0410-b35b-8c050e845b92
Diffstat (limited to 'lib/stwcs/wcsutil/altwcs.py')
-rw-r--r-- | lib/stwcs/wcsutil/altwcs.py | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/stwcs/wcsutil/altwcs.py b/lib/stwcs/wcsutil/altwcs.py index 6a2ddbd..7719ce7 100644 --- a/lib/stwcs/wcsutil/altwcs.py +++ b/lib/stwcs/wcsutil/altwcs.py @@ -636,10 +636,15 @@ def getKeyFromName(header, wcsname): """ wkey = None names = wcsnames(header) + wkeys = [] for item in names.items(): if item[1].lower() == wcsname.lower(): - wkey = item[0] - break + wkeys.append(item[0]) + wkeys.sort() + if len(wkeys) > 0: + wkey = wkeys[-1] + else: + wkey = None return wkey def pc2cd(hdr, key=' '): |