summaryrefslogtreecommitdiff
path: root/lib/stwcs/wcsutil
diff options
context:
space:
mode:
Diffstat (limited to 'lib/stwcs/wcsutil')
-rw-r--r--lib/stwcs/wcsutil/altwcs.py6
-rw-r--r--lib/stwcs/wcsutil/headerlet.py16
-rw-r--r--lib/stwcs/wcsutil/hstwcs.py4
-rw-r--r--lib/stwcs/wcsutil/instruments.py4
4 files changed, 16 insertions, 14 deletions
diff --git a/lib/stwcs/wcsutil/altwcs.py b/lib/stwcs/wcsutil/altwcs.py
index 15123b7..293f22d 100644
--- a/lib/stwcs/wcsutil/altwcs.py
+++ b/lib/stwcs/wcsutil/altwcs.py
@@ -80,7 +80,7 @@ def archiveWCS(fname, ext, wcskey=" ", wcsname=" ", reusekey=False):
Alternatively choose another wcskey with altwcs.available_wcskeys()." %wcskey)
elif wcskey == " ":
# wcsname exists, overwrite it if reuse is True or get the next key
- if wcsname.strip() in wcsnames(f[wcsext].header):
+ if wcsname.strip() in wcsnames(f[wcsext].header).values():
if reusekey:
# try getting the key from an existing WCS with WCSNAME
wkey = getKeyFromName(f[wcsext].header, wcsname)
@@ -133,7 +133,7 @@ def archiveWCS(fname, ext, wcskey=" ", wcsname=" ", reusekey=False):
except:
pass
- for k in hwcs:
+ for k in hwcs.keys():
key = k[:7] + wkey
f[e].header[key] = hwcs[k]
closefobj(fname, f)
@@ -419,7 +419,7 @@ def _restore(fobj, ukey, fromextnum,
if hwcs is None:
return
- for k in hwcs:
+ for k in hwcs.keys():
key = k[:-1]
if key in fobj[toextension].header:
#fobj[toextension].header.update(key=key, value = hwcs[k])
diff --git a/lib/stwcs/wcsutil/headerlet.py b/lib/stwcs/wcsutil/headerlet.py
index 6b3e752..c0dd9b0 100644
--- a/lib/stwcs/wcsutil/headerlet.py
+++ b/lib/stwcs/wcsutil/headerlet.py
@@ -109,12 +109,14 @@ def with_logging(func):
level = kw.get('logging', 100)
mode = kw.get('logmode', 'w')
func_args = kw.copy()
- if sys.version_info[0] < 3:
- for argname, arg in zip(func.func_code.co_varnames, args):
- func_args[argname] = arg
+ if sys.version_info[0] >= 3:
+ argnames = func.__code__.co_varnames
else:
- for argname, arg in zip(func.__code__.co_varnames, args):
- func_args[argname] = arg
+ argnames = func.func_code.co_varnames
+
+ for argname, arg in zip(argnames, args):
+ func_args[argname] = arg
+
init_logging(func.__name__, level, mode, **func_args)
return func(*args, **kw)
return wrapped
@@ -157,7 +159,7 @@ def parse_filename(fname, mode='readonly'):
"""
close_fobj = False
if not isinstance(fname, list):
- if sys.version > '3':
+ if sys.version_info[0] >= 3:
is_string = isinstance(fname, str)
else:
is_string = isinstance(fname, basestring)
@@ -1493,7 +1495,7 @@ def restore_from_headerlet(filename, hdrname=None, hdrext=None, archive=True,
priwcs_name = None
scihdr = extlist[0].header
- #sci_wcsnames = altwcs.wcsnames(scihdr).values()
+ sci_wcsnames = altwcs.wcsnames(scihdr).values()
if 'hdrname' in scihdr:
priwcs_hdrname = scihdr['hdrname']
else:
diff --git a/lib/stwcs/wcsutil/hstwcs.py b/lib/stwcs/wcsutil/hstwcs.py
index cb61f1c..a71c33a 100644
--- a/lib/stwcs/wcsutil/hstwcs.py
+++ b/lib/stwcs/wcsutil/hstwcs.py
@@ -137,7 +137,7 @@ class HSTWCS(WCS):
ext=ext)
self.filename = filename
instrument_name = hdr0.get('INSTRUME', 'DEFAULT')
- if instrument_name == 'DEFAULT' or instrument_name not in inst_mappings:
+ if instrument_name == 'DEFAULT' or instrument_name not in list(inst_mappings.keys()):
#['IRAF/ARTDATA','',' ','N/A']:
self.instrument = 'DEFAULT'
else:
@@ -203,7 +203,7 @@ class HSTWCS(WCS):
extension header
"""
- if self.instrument in inst_mappings:
+ if self.instrument in list(inst_mappings.keys()):
inst_kl = inst_mappings[self.instrument]
inst_kl = instruments.__dict__[inst_kl]
insobj = inst_kl(prim_hdr, ext_hdr)
diff --git a/lib/stwcs/wcsutil/instruments.py b/lib/stwcs/wcsutil/instruments.py
index 45da046..f662513 100644
--- a/lib/stwcs/wcsutil/instruments.py
+++ b/lib/stwcs/wcsutil/instruments.py
@@ -165,7 +165,7 @@ class ACSWCS(InstrWCS):
'HRC':[[-1.0,0.0],[0.0,1.0]],
'SBC':[[-1.0,0.0],[0.0,1.0]]}
- if self.detector not in parity:
+ if self.detector not in list(parity.keys()):
parity = InstrWCS.set_parity(self)
else:
self.parity = parity[self.detector]
@@ -243,7 +243,7 @@ class WFC3WCS(InstrWCS):
parity = {'UVIS':[[-1.0,0.0],[0.0,1.0]],
'IR':[[-1.0,0.0],[0.0,1.0]]}
- if self.detector not in parity:
+ if self.detector not in list(parity.keys()):
parity = InstrWCS.set_parity(self)
else:
self.parity = parity[self.detector]