def test_spcfix(): # TODO: We need some data with broken spectral headers here to # really test header = open(os.path.join(ROOT_DIR, 'spectra', 'orion-velo-1.hdr'), 'rb').read() w = _pywcs._Wcsprm(header) assert w.spcfix() == -1
def test_latpole(): w = _pywcs._Wcsprm() assert w.latpole == 90.0 w.latpole = 45.0 assert w.latpole == 45.0 del w.latpole assert w.latpole == 90.0
def test_theta0(): w = _pywcs._Wcsprm() assert np.isnan(w.theta0) w.theta0 = 42.0 assert w.theta0 == 42.0 del w.theta0 assert np.isnan(w.theta0)
def test_datfix(): w = _pywcs._Wcsprm() w.dateobs = b('31/12/99') status = w.datfix() assert status == 0 assert w.dateobs == b('1999-12-31') assert w.mjdobs == 51543.0
def test_velangl(): w = _pywcs._Wcsprm() assert w.velangl == 0.0 w.velangl = 42.0 assert w.velangl == 42.0 del w.velangl assert np.isnan(w.velangl)
def test_mjdobs(): w = _pywcs._Wcsprm() assert np.isnan(w.mjdobs) w.mjdobs = 45.0 assert w.mjdobs == 45.0 del w.mjdobs assert np.isnan(w.mjdobs)
def test_obsgeo(): w = _pywcs._Wcsprm() assert np.all(np.isnan(w.obsgeo)) w.obsgeo = [1, 2, 3] assert_array_equal(w.obsgeo, [1, 2, 3]) del w.obsgeo assert np.all(np.isnan(w.obsgeo))
def test_lonpole(): w = _pywcs._Wcsprm() assert np.isnan(w.lonpole) w.lonpole = 45.0 assert w.lonpole == 45.0 del w.lonpole assert np.isnan(w.lonpole)
def test_mjdavg(): w = _pywcs._Wcsprm() assert np.isnan(w.mjdavg) w.mjdavg = 45.0 assert w.mjdavg == 45.0 del w.mjdavg assert np.isnan(w.mjdavg)
def test_velosys(): w = _pywcs._Wcsprm() assert np.isnan(w.velosys) w.velosys = 42.0 assert w.velosys == 42.0 del w.velosys assert np.isnan(w.velosys)
def test_cd_missing2(): w = _pywcs._Wcsprm() w.cd = [[1, 0], [0, 1]] assert w.has_cd() == True del w.cd assert w.has_cd() == False w.cd
def test_zsource(): w = _pywcs._Wcsprm() assert np.isnan(w.zsource) w.zsource = 42.0 assert w.zsource == 42.0 del w.zsource assert np.isnan(w.zsource)
def test_equinox(): w = _pywcs._Wcsprm() assert np.isnan(w.equinox) w.equinox = 0 assert w.equinox == 0 del w.equinox assert np.isnan(w.equinox)
def test_alt(): w = _pywcs._Wcsprm() assert w.alt == b(" ") w.alt = b("X") assert w.alt == b("X") del w.alt assert w.alt == b(" ")
def test_cel_offset(): w = _pywcs._Wcsprm() assert w.cel_offset is False w.cel_offset = 'foo' assert w.cel_offset is True w.cel_offset = 0 assert w.cel_offset is False
def test_csyer(): w = _pywcs._Wcsprm() assert w.crder.dtype == np.float assert np.all(np.isnan(w.crder)) w.crder[0] = 0 assert np.isnan(w.crder[1]) assert w.crder[0] == 0
def test_phi0(): w = _pywcs._Wcsprm() assert np.isnan(w.phi0) w.phi0 = 42.0 assert w.phi0 == 42.0 del w.phi0 assert np.isnan(w.phi0)
def test_crota_missing2(): w = _pywcs._Wcsprm() w.crota = [1, 0] assert w.has_crota() == True del w.crota assert w.has_crota() == False w.crota
def test_obsgeo(): w = _pywcs._Wcsprm() assert np.all(np.isnan(w.obsgeo)) w.obsgeo = [1,2,3] assert_array_equal(w.obsgeo, [1,2,3]) del w.obsgeo assert np.all(np.isnan(w.obsgeo))
def test_crval(): w = _pywcs._Wcsprm() assert w.crval.dtype == np.float assert_array_equal(w.crval, [0, 0]) w.crval = [42, 54] assert_array_equal(w.crval, [42, 54]) w.crval[0] = 0 assert_array_equal(w.crval, [0, 54])
def test_crpix(): w = _pywcs._Wcsprm() assert w.crpix.dtype == np.float assert_array_equal(w.crpix, [0, 0]) w.crpix = [42, 54] assert_array_equal(w.crpix, [42, 54]) w.crpix[0] = 0 assert_array_equal(w.crpix, [0, 54])
def test_crota(): w = _pywcs._Wcsprm() w.crota = [1, 0] assert w.crota.dtype == np.float assert w.has_crota() == True assert_array_equal(w.crota, [1, 0]) del w.crota assert w.has_crota() == False
def test_fix(): w = _pywcs._Wcsprm() assert w.fix() == { 'cylfix': 'No change', 'datfix': 'No change', 'spcfix': 'No change', 'unitfix':'No change', 'celfix': 'No change'}
def test_colax(): w = _pywcs._Wcsprm() assert w.colax.dtype == np.intc assert_array_equal(w.colax, [0, 0]) w.colax = [42, 54] assert_array_equal(w.colax, [42, 54]) w.colax[0] = 0 assert_array_equal(w.colax, [0, 54])
def test_cd(): w = _pywcs._Wcsprm() w.cd = [[1, 0], [0, 1]] assert w.cd.dtype == np.float assert w.has_cd() == True assert_array_equal(w.cd, [[1, 0], [0, 1]]) del w.cd assert w.has_cd() == False
def test_cname(): w = _pywcs._Wcsprm() # Test that this works as an iterator for x in w.cname: assert x == b('') assert list(w.cname) == [b(''), b('')] w.cname = [b('foo'), b('bar')] assert list(w.cname) == [b('foo'), b('bar')]
def test_fix(): w = _pywcs._Wcsprm() assert w.fix() == { 'cylfix': 'No change', 'datfix': 'No change', 'spcfix': 'No change', 'unitfix': 'No change', 'celfix': 'No change' }
def test_pc(): w = _pywcs._Wcsprm() assert w.has_pc() assert_array_equal(w.pc, [[1, 0], [0, 1]]) w.cd = [[1, 0], [0, 1]] assert not w.has_pc() del w.cd assert w.has_pc() assert_array_equal(w.pc, [[1, 0], [0, 1]])
def test_fix2(): w = _pywcs._Wcsprm() w.dateobs = b('31/12/99') assert w.fix() == { 'cylfix': 'No change', 'datfix': 'Success', 'spcfix': 'No change', 'unitfix': 'No change', 'celfix': 'No change'} assert w.dateobs == b('1999-12-31') assert w.mjdobs == 51543.0
def test_fix3(): w = _pywcs._Wcsprm() w.dateobs = b('31/12/F9') assert w.fix() == { 'cylfix': 'No change', 'datfix': "Invalid parameter value: invalid date '31/12/F9'", 'spcfix': 'No change', 'unitfix':'No change', 'celfix': 'No change'} assert w.dateobs == b('31/12/F9') assert np.isnan(w.mjdobs)
def test_fix3(): w = _pywcs._Wcsprm() w.dateobs = b('31/12/F9') assert w.fix() == { 'cylfix': 'No change', 'datfix': "Invalid parameter value: invalid date '31/12/F9'", 'spcfix': 'No change', 'unitfix': 'No change', 'celfix': 'No change' } assert w.dateobs == b('31/12/F9') assert np.isnan(w.mjdobs)
def test_fix2(): w = _pywcs._Wcsprm() w.dateobs = b('31/12/99') status = w.fix() assert status == { 'cylfix': 'No change', 'datfix': "Changed '31/12/99' to '1999-12-31'", 'spcfix': 'No change', 'unitfix': 'No change', 'celfix': 'No change'} assert w.dateobs == b('1999-12-31') assert w.mjdobs == 51543.0
def test_fix2(): w = _pywcs._Wcsprm() w.dateobs = b('31/12/99') status = w.fix() assert status == { 'cylfix': 'No change', 'datfix': "Changed '31/12/99' to '1999-12-31'", 'spcfix': 'No change', 'unitfix': 'No change', 'celfix': 'No change' } assert w.dateobs == b('1999-12-31') assert w.mjdobs == 51543.0
def test_ctype(): w = _pywcs._Wcsprm() assert list(w.ctype) == [b(''), b('')] w.ctype = [b('RA---TAN'), b('DEC--TAN')] assert_array_equal(w.axis_types, [2200, 2201]) assert w.lat == 1 assert w.lng == 0 assert w.lattyp == b('DEC') assert w.lngtyp == b('RA') assert list(w.ctype) == [b('RA---TAN'), b('DEC--TAN')] w.ctype = [b('foo'), b('bar')] assert_array_equal(w.axis_types, [0, 0]) assert list(w.ctype) == [b('foo'), b('bar')] assert w.lat == -1 assert w.lng == -1 assert w.lattyp == b('DEC') assert w.lngtyp == b('RA')
def test_celfix(): # TODO: We need some data with -NCP or -GLS projections to test # with. For now, this is just a smoke test w = _pywcs._Wcsprm() assert w.celfix() == -1
def test_cdelt_delete(): w = _pywcs._Wcsprm() del w.cdelt