summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/stwcs/updatewcs/__init__.py6
-rw-r--r--lib/stwcs/updatewcs/det2im.py6
-rw-r--r--lib/stwcs/updatewcs/npol.py6
-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
7 files changed, 25 insertions, 23 deletions
diff --git a/lib/stwcs/updatewcs/__init__.py b/lib/stwcs/updatewcs/__init__.py
index a7f9a3e..d09f5a8 100644
--- a/lib/stwcs/updatewcs/__init__.py
+++ b/lib/stwcs/updatewcs/__init__.py
@@ -8,10 +8,10 @@ import stwcs
from astropy import wcs as pywcs
import astropy
-import utils, corrections, makewcs
-import npol, det2im
+from . import utils, corrections, makewcs
+from . import npol, det2im
from stsci.tools import parseinput, fileutil
-import apply_corrections
+from . import apply_corrections
import time
import logging
diff --git a/lib/stwcs/updatewcs/det2im.py b/lib/stwcs/updatewcs/det2im.py
index dfda9d1..bddb37b 100644
--- a/lib/stwcs/updatewcs/det2im.py
+++ b/lib/stwcs/updatewcs/det2im.py
@@ -224,7 +224,7 @@ class DET2IMCorr(object):
kw_comm1 = {}
kw_val1 = {}
- for key in kw:
+ for key in kw.keys():
for i in range(1, naxis+1):
si = str(i)
kw_comm1[key+si] = kw[key]
@@ -255,9 +255,9 @@ class DET2IMCorr(object):
'CCDCHIP': ccdchip,
}
cdl = []
- for key in kw_comm0:
+ for key in kw_comm0.keys():
cdl.append((key, kw_val0[key], kw_comm0[key]))
- for key in kw_comm1:
+ for key in kw_comm1.keys():
cdl.append((key, kw_val1[key], kw_comm1[key]))
# Now add keywords from NPOLFILE header to document source of calibration
# include all keywords after and including 'FILENAME' from header
diff --git a/lib/stwcs/updatewcs/npol.py b/lib/stwcs/updatewcs/npol.py
index 4e109ae..2f8d836 100644
--- a/lib/stwcs/updatewcs/npol.py
+++ b/lib/stwcs/updatewcs/npol.py
@@ -266,7 +266,7 @@ class NPOLCorr(object):
kw_comm1 = {}
kw_val1 = {}
- for key in kw:
+ for key in kw.keys():
for i in range(1, naxis+1):
si = str(i)
kw_comm1[key+si] = kw[key]
@@ -299,9 +299,9 @@ class NPOLCorr(object):
'CCDCHIP': ccdchip,
}
cdl = []
- for key in kw_comm0:
+ for key in kw_comm0.keys():
cdl.append((key, kw_val0[key], kw_comm0[key]))
- for key in kw_comm1:
+ for key in kw_comm1.keys():
cdl.append((key, kw_val1[key], kw_comm1[key]))
# Now add keywords from NPOLFILE header to document source of calibration
# include all keywords after and including 'FILENAME' from header
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]