From 34a65378c98e1a2c017cce36f06e88d7052e454d Mon Sep 17 00:00:00 2001 From: hack Date: Mon, 13 Oct 2014 22:22:46 +0000 Subject: 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 --- lib/stwcs/wcsutil/altwcs.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'lib/stwcs/wcsutil/altwcs.py') 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=' '): -- cgit