diff options
author | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-10 17:39:25 -0400 |
---|---|---|
committer | Nadia Dencheva <nadia.dencheva@gmail.com> | 2016-08-10 17:39:25 -0400 |
commit | 40b2c248505f2dbf707912b12d4fac3d4e5f25f0 (patch) | |
tree | 9e4026d2e4f524cdfb3c9bac148baf4086db33a2 /stwcs | |
parent | af56b9ad582ac0fe25ef7e941fbec4309906f7f5 (diff) | |
download | stwcs_hcf-40b2c248505f2dbf707912b12d4fac3d4e5f25f0.tar.gz |
fix failing tests
Diffstat (limited to 'stwcs')
-rw-r--r-- | stwcs/tests/test_altwcs.py | 51 | ||||
-rw-r--r-- | stwcs/tests/test_headerlet.py | 8 | ||||
-rw-r--r-- | stwcs/tests/test_updatewcs.py | 12 | ||||
-rw-r--r-- | stwcs/updatewcs/__init__.py | 8 | ||||
-rw-r--r-- | stwcs/updatewcs/makewcs.py | 6 | ||||
-rw-r--r-- | stwcs/wcsutil/getinput.py | 15 | ||||
-rw-r--r-- | stwcs/wcsutil/hstwcs.py | 8 |
7 files changed, 61 insertions, 47 deletions
diff --git a/stwcs/tests/test_altwcs.py b/stwcs/tests/test_altwcs.py index 86d100f..d646106 100644 --- a/stwcs/tests/test_altwcs.py +++ b/stwcs/tests/test_altwcs.py @@ -1,11 +1,14 @@ +from __future__ import absolute_import, division, print_function + import shutil import os from astropy.io import fits as pyfits -from stwcs.wcsutil import altwcs -from stwcs import updatewcs -from stwcs.wcsutil import HSTWCS +from ..wcsutil import altwcs +from .. import updatewcs +from .. import wcsutil import numpy as np from numpy.testing import utils +import pytest from . import data data_path = os.path.split(os.path.abspath(data.__file__))[0] @@ -70,25 +73,25 @@ class TestAltWCS(object): updatewcs.updatewcs(acs_file) self.acs_file = acs_file self.simplefits = simple_file - self.ww = HSTWCS(self.acs_file, ext=1) + self.ww = wcsutil.HSTWCS(self.acs_file, ext=1) def test_archive(self): altwcs.archiveWCS(self.acs_file, ext=1, wcskey='Z', wcsname='ZTEST', reusekey=False) - w1 = HSTWCS(self.acs_file, ext=1) - w1z = HSTWCS(self.acs_file, ext=1, wcskey='Z') + w1 = wcsutil.HSTWCS(self.acs_file, ext=1) + w1z = wcsutil.HSTWCS(self.acs_file, ext=1, wcskey='Z') compare_wcs(w1, w1z) def test_archive_clobber(self): altwcs.archiveWCS(self.acs_file, ext=1, wcskey='Z', wcsname='ZTEST', reusekey=True) - w1 = HSTWCS(self.acs_file, ext=1) - w1z = HSTWCS(self.acs_file, ext=1, wcskey='Z') + w1 = wcsutil.HSTWCS(self.acs_file, ext=1) + w1z = wcsutil.HSTWCS(self.acs_file, ext=1, wcskey='Z') compare_wcs(w1, w1z) def test_restore_wcs(self): # test restore on a file altwcs.restoreWCS(self.acs_file, ext=1, wcskey='O') - w1o = HSTWCS(self.acs_file, ext=1, wcskey='O') - w1 = HSTWCS(self.acs_file, ext=1) + w1o = wcsutil.HSTWCS(self.acs_file, ext=1, wcskey='O') + w1 = wcsutil.HSTWCS(self.acs_file, ext=1) compare_wcs(w1, w1o, exclude_keywords=['ctype']) def test_restore_wcs_mem(self): @@ -99,8 +102,8 @@ class TestAltWCS(object): f = pyfits.open(self.acs_file, mode='update') altwcs.restoreWCS(f, ext=1, wcskey='T') f.close() - w1o = HSTWCS(self.acs_file, ext=1, wcskey='T') - w1 = HSTWCS(self.acs_file, ext=1) + w1o = wcsutil.HSTWCS(self.acs_file, ext=1, wcskey='T') + w1 = wcsutil.HSTWCS(self.acs_file, ext=1) compare_wcs(w1, w1o) def test_restore_simple(self): @@ -108,8 +111,8 @@ class TestAltWCS(object): altwcs.archiveWCS(self.simplefits, ext=0, wcskey='R') pyfits.setval(self.simplefits, ext=0, keyword='CRVAL1R', value=1) altwcs.restoreWCS(self.simplefits, ext=0, wcskey='R') - wo = HSTWCS(self.simplefits, ext=0, wcskey='R') - ws = HSTWCS(self.simplefits, ext=0) + wo = wcsutil.HSTWCS(self.simplefits, ext=0, wcskey='R') + ws = wcsutil.HSTWCS(self.simplefits, ext=0) compare_wcs(ws, wo) def test_restore_wcs_from_to(self): @@ -121,25 +124,27 @@ class TestAltWCS(object): altwcs.restore_from_to(f, fromext='SCI', toext=['SCI', 'ERR', 'DQ'], wcskey='T') f.close() - w1o = HSTWCS(self.acs_file, ext=('SCI', 1), wcskey='T') - w1 = HSTWCS(self.acs_file, ext=('SCI', 1)) + w1o = wcsutil.HSTWCS(self.acs_file, ext=('SCI', 1), wcskey='T') + w1 = wcsutil.HSTWCS(self.acs_file, ext=('SCI', 1)) compare_wcs(w1, w1o) - w2 = HSTWCS(self.acs_file, ext=('ERR', 1)) + w2 = wcsutil.HSTWCS(self.acs_file, ext=('ERR', 1)) compare_wcs(w2, w1o, exclude_keywords=['ctype']) - w3 = HSTWCS(self.acs_file, ext=('DQ', 1)) + w3 = wcsutil.HSTWCS(self.acs_file, ext=('DQ', 1)) compare_wcs(w3, w1o, exclude_keywords=['ctype']) - w4o = HSTWCS(self.acs_file, ext=4, wcskey='T') - w4 = HSTWCS(self.acs_file, ext=('SCI', 2)) + w4o = wcsutil.HSTWCS(self.acs_file, ext=4, wcskey='T') + w4 = wcsutil.HSTWCS(self.acs_file, ext=('SCI', 2)) compare_wcs(w4, w4o) - w5 = HSTWCS(self.acs_file, ext=('ERR', 2)) + w5 = wcsutil.HSTWCS(self.acs_file, ext=('ERR', 2)) compare_wcs(w5, w4o, exclude_keywords=['ctype']) - w6 = HSTWCS(self.acs_file, ext=('DQ', 2)) + w6 = wcsutil.HSTWCS(self.acs_file, ext=('DQ', 2)) compare_wcs(w3, w1o, exclude_keywords=['ctype']) def test_delete_wcs(self): #altwcs.archiveWCS(self.acs_file, ext=1, wcskey='Z') altwcs.deleteWCS(self.acs_file, ext=1, wcskey='Z') - utils.assert_raises(KeyError, HSTWCS, self.acs_file, ext=1, wcskey='Z') + #utils.assert_raises(KeyError, wcsutil.HSTWCS, self.acs_file, ext=1, wcskey='Z') + with pytest.raises(KeyError): + wcsutil.HSTWCS(self.acs_file, ext=1, wcskey='Z') def test_pars_file_mode1(self): assert(not altwcs._parpasscheck(self.acs_file, ext=1, wcskey='Z')) diff --git a/stwcs/tests/test_headerlet.py b/stwcs/tests/test_headerlet.py index 48fb470..f4fa050 100644 --- a/stwcs/tests/test_headerlet.py +++ b/stwcs/tests/test_headerlet.py @@ -1,9 +1,11 @@ +from __future__ import absolute_import, division, print_function + import shutil import os from astropy.io import fits -from stwcs import updatewcs -from stwcs.wcsutil import headerlet, wcsdiff -from stwcs.wcsutil import HSTWCS +from .. import updatewcs +from ..wcsutil import headerlet, wcsdiff +from ..wcsutil import HSTWCS import numpy as np from numpy.testing import utils from nose.tools import * diff --git a/stwcs/tests/test_updatewcs.py b/stwcs/tests/test_updatewcs.py index dc5a34f..b7e75c8 100644 --- a/stwcs/tests/test_updatewcs.py +++ b/stwcs/tests/test_updatewcs.py @@ -1,12 +1,14 @@ +from __future__ import absolute_import, division, print_function + import shutil import os from astropy import wcs from astropy.io import fits -from stwcs import updatewcs -from stwcs.updatewcs import apply_corrections -from stwcs.distortion import utils as dutils -from stwcs.wcsutil import HSTWCS +from .. import updatewcs +from ..updatewcs import apply_corrections +from ..distortion import utils as dutils +from ..wcsutil import HSTWCS import numpy as np from numpy.testing import utils import pytest @@ -111,7 +113,7 @@ class TestStwcs(object): #print('outwcs.wcs.crval = {0}'.format(outwcs.wcs.crval)) utils.assert_allclose( - outwcs.wcs.crval, np.array([5.65109952, -72.0674181]), rtol=1e-7) + outwcs.wcs.crval, np.array([5.65109952, -72.0674181]), atol=1e-7) utils.assert_almost_equal(outwcs.wcs.crpix, np.array([2107.0, 2118.5])) utils.assert_almost_equal( diff --git a/stwcs/updatewcs/__init__.py b/stwcs/updatewcs/__init__.py index 72d2961..a59f106 100644 --- a/stwcs/updatewcs/__init__.py +++ b/stwcs/updatewcs/__init__.py @@ -1,8 +1,10 @@ from __future__ import absolute_import, division, print_function + import atexit from astropy.io import fits from .. import wcsutil -from ..wcsutil import HSTWCS +#from ..wcsutil.hwstwcs import HSTWCS + from .. import __version__ from astropy import wcs as pywcs @@ -115,7 +117,7 @@ def makecorr(fname, allowed_corr): # Determine the reference chip and create the reference HSTWCS object nrefchip, nrefext = getNrefchip(f) wcsutil.restoreWCS(f, nrefext, wcskey='O') - rwcs = HSTWCS(fobj=f, ext=nrefext) + rwcs = wcsutil.HSTWCS(fobj=f, ext=nrefext) rwcs.readModel(update=True, header=f[nrefext].header) if 'DET2IMCorr' in allowed_corr: @@ -133,7 +135,7 @@ def makecorr(fname, allowed_corr): sciextver = extn.header['extver'] ref_wcs = rwcs.deepcopy() hdr = extn.header - ext_wcs = HSTWCS(fobj=f, ext=i) + ext_wcs = wcsutil.HSTWCS(fobj=f, ext=i) # check if it exists first!!! # 'O ' can be safely archived again because it has been restored first. wcsutil.archiveWCS(f, ext=i, wcskey="O", wcsname="OPUS", reusekey=True) diff --git a/stwcs/updatewcs/makewcs.py b/stwcs/updatewcs/makewcs.py index 8dbcd85..4c6b3df 100644 --- a/stwcs/updatewcs/makewcs.py +++ b/stwcs/updatewcs/makewcs.py @@ -204,8 +204,8 @@ class MakeWCS(object): alpha = 0.0 beta = 0.0 v23_corr = np.array([[0.], [0.]]) - logger.debug("TDD Zero point correction for chip {0} defaulted to: {1}".format((hwcs.chip, - v23_corr))) + logger.debug("TDD Zero point correction for chip" + "{0} defaulted to: {1}".format(hwcs.chip, v23_corr)) return v23_corr tdd = np.array([[beta, alpha], [alpha, -beta]]) @@ -213,7 +213,7 @@ class MakeWCS(object): xy0 = np.array([[cls.tdd_xyref[hwcs.chip][0] - 2048.], [cls.tdd_xyref[hwcs.chip][1] - 2048.]]) v23_corr = np.dot(mrotp, np.dot(tdd, xy0)) * 0.05 - logger.debug("TDD Zero point correction for chip {0}: {1}".format((hwcs.chip, v23_corr))) + logger.debug("TDD Zero point correction for chip {0}: {1}".format(hwcs.chip, v23_corr)) return v23_corr zero_point_corr = classmethod(zero_point_corr) diff --git a/stwcs/wcsutil/getinput.py b/stwcs/wcsutil/getinput.py index da52970..c8b3b1b 100644 --- a/stwcs/wcsutil/getinput.py +++ b/stwcs/wcsutil/getinput.py @@ -1,13 +1,14 @@ from __future__ import absolute_import, division, print_function + from astropy.io import fits from stsci.tools import irafglob, fileutil, parseinput -from .hstwcs import HSTWCS +#from . import HSTWCS def parseSingleInput(f=None, ext=None): if isinstance(f, str): # create an HSTWCS object from a filename - if ext is None: + if ext is not None: filename = f if isinstance(ext, tuple): if ext[0] == '': @@ -57,9 +58,9 @@ def parseMultipleInput(input): filelist, output = parseinput.parseinput(input) except IOError: raise elif isinstance(input, list): - if isinstance(input[0], HSTWCS): - # a list of HSTWCS objects - return input - else: - filelist = input[:] + #if isinstance(input[0], HSTWCS): + ## a list of HSTWCS objects + #return input + #else: + filelist = input[:] return filelist diff --git a/stwcs/wcsutil/hstwcs.py b/stwcs/wcsutil/hstwcs.py index 81e1432..27f6467 100644 --- a/stwcs/wcsutil/hstwcs.py +++ b/stwcs/wcsutil/hstwcs.py @@ -3,15 +3,17 @@ from __future__ import absolute_import, division, print_function import os from astropy.wcs import WCS from astropy.io import fits -from stwcs.distortion import models, coeff_converter +from ..distortion import models, coeff_converter import numpy as np from stsci.tools import fileutil -from . import altwcs +from . import pc2cd from . import getinput from . import instruments from .mappings import inst_mappings, ins_spec_kw +__all__ = ['HSTWCS'] + def extract_rootname(kwvalue, suffix=""): """ Returns the rootname from a full reference filename @@ -384,7 +386,7 @@ class HSTWCS(WCS): if not wcskey: wcskey = self.wcs.alt if self.wcs.has_cd(): - h = altwcs.pc2cd(h, key=wcskey) + h = pc2cd(h, key=wcskey) if 'wcsname' not in h: if self.idctab is not None: |