예제 #1
0
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
예제 #2
0
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
예제 #3
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)
예제 #4
0
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
예제 #5
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)
예제 #6
0
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)
예제 #7
0
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))
예제 #8
0
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)
예제 #9
0
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)
예제 #10
0
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)
예제 #11
0
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
예제 #12
0
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
예제 #13
0
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)
예제 #14
0
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
예제 #15
0
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)
예제 #16
0
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(" ")
예제 #17
0
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
예제 #18
0
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
예제 #19
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)
예제 #20
0
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
예제 #21
0
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)
예제 #22
0
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)
예제 #23
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)
예제 #24
0
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)
예제 #25
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)
예제 #26
0
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
예제 #27
0
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
예제 #28
0
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)
예제 #29
0
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)
예제 #30
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)
예제 #31
0
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(" ")
예제 #32
0
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
예제 #33
0
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))
예제 #34
0
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
예제 #35
0
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)
예제 #36
0
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])
예제 #37
0
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])
예제 #38
0
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])
예제 #39
0
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
예제 #40
0
def test_fix():
    w = _pywcs._Wcsprm()
    assert w.fix() == {
        'cylfix': 'No change',
        'datfix': 'No change',
        'spcfix': 'No change',
        'unitfix':'No change',
        'celfix': 'No change'}
예제 #41
0
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])
예제 #42
0
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])
예제 #43
0
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
예제 #44
0
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
예제 #45
0
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])
예제 #46
0
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')]
예제 #47
0
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')]
예제 #48
0
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
예제 #49
0
def test_fix():
    w = _pywcs._Wcsprm()
    assert w.fix() == {
        'cylfix': 'No change',
        'datfix': 'No change',
        'spcfix': 'No change',
        'unitfix': 'No change',
        'celfix': 'No change'
    }
예제 #50
0
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]])
예제 #51
0
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]])
예제 #52
0
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
예제 #53
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)
예제 #54
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)
예제 #55
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
예제 #56
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
예제 #57
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')
예제 #58
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')
예제 #59
0
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
예제 #60
0
def test_cdelt_delete():
    w = _pywcs._Wcsprm()
    del w.cdelt