示例#1
0
def test_radesys_defaults():
    w = _wcs.Wcsprm()
    w.ctype = ['RA---TAN', 'DEC--TAN']
    w.set()
    assert w.radesys == "ICRS"
示例#2
0
def test_lattyp():
    w = _wcs.Wcsprm()
    print(repr(w.lattyp))
    assert w.lattyp == "    "
示例#3
0
def test_lngtyp():
    w = _wcs.Wcsprm()
    assert w.lngtyp == "    "
示例#4
0
def test_imgpix_matrix2():
    w = _wcs.Wcsprm()
    with pytest.raises(AttributeError):
        w.imgpix_matrix = None
示例#5
0
def test_lat():
    w = _wcs.Wcsprm()
    assert w.lat == -1
示例#6
0
def test_fix4():
    w = _wcs.Wcsprm()
    with pytest.raises(ValueError):
        w.fix('X')
示例#7
0
def test_get_pv():
    # TODO: We need some data with PVi_ma keywords
    w = _wcs.Wcsprm()
    assert len(w.get_pv()) == 0
示例#8
0
def test_crota_missing():
    w = _wcs.Wcsprm()
    assert w.has_crota() is False
    with pytest.raises(AttributeError):
        w.crota
示例#9
0
def test_ctype_repr():
    w = _wcs.Wcsprm()
    assert list(w.ctype) == ['', '']
    w.ctype = [b'RA-\t--TAN', 'DEC-\n-TAN']
    assert repr(w.ctype == '["RA-\t--TAN", "DEC-\n-TAN"]')
示例#10
0
def test_cname_invalid():
    w = _wcs.Wcsprm()
    with pytest.raises(TypeError):
        w.cname = [42, 54]
示例#11
0
def test_colnum_invalid():
    w = _wcs.Wcsprm()
    with pytest.raises(TypeError):
        w.colnum = 'foo'
示例#12
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 = _wcs.Wcsprm()
    assert w.celfix() == -1
示例#13
0
def test_cdelt_delete():
    w = _wcs.Wcsprm()
    with pytest.raises(TypeError):
        del w.cdelt
示例#14
0
def test_radesys_defaults_full():

    # As described in Section 3.1 of the FITS standard "Equatorial and ecliptic
    # coordinates", for those systems the RADESYS keyword can be used to
    # indicate the equatorial/ecliptic frame to use. From the standard:

    # "For RADESYSa values of FK4 and FK4-NO-E, any stated equinox is Besselian
    # and, if neither EQUINOXa nor EPOCH are given, a default of 1950.0 is to
    # be taken. For FK5, any stated equinox is Julian and, if neither keyword
    # is given, it defaults to 2000.0.

    # "If the EQUINOXa keyword is given it should always be accompanied by
    # RADESYS a. However, if it should happen to ap- pear by itself then
    # RADESYSa defaults to FK4 if EQUINOXa < 1984.0, or to FK5 if EQUINOXa
    # 1984.0. Note that these defaults, while probably true of older files
    # using the EPOCH keyword, are not required of them.

    # By default RADESYS is empty
    w = _wcs.Wcsprm(naxis=2)
    assert w.radesys == ''
    assert np.isnan(w.equinox)

    # For non-ecliptic or equatorial systems it is still empty
    w = _wcs.Wcsprm(naxis=2)
    for ctype in [('GLON-CAR', 'GLAT-CAR'), ('SLON-SIN', 'SLAT-SIN')]:
        w.ctype = ctype
        w.set()
        assert w.radesys == ''
        assert np.isnan(w.equinox)

    for ctype in [('RA---TAN', 'DEC--TAN'), ('ELON-TAN', 'ELAT-TAN'),
                  ('DEC--TAN', 'RA---TAN'), ('ELAT-TAN', 'ELON-TAN')]:

        # Check defaults for RADESYS
        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.set()
        assert w.radesys == 'ICRS'

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.equinox = 1980
        w.set()
        assert w.radesys == 'FK4'

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.equinox = 1984
        w.set()
        assert w.radesys == 'FK5'

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.radesys = 'foo'
        w.set()
        assert w.radesys == 'foo'

        # Check defaults for EQUINOX
        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.set()
        assert np.isnan(w.equinox)  # frame is ICRS, no equinox

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.radesys = 'ICRS'
        w.set()
        assert np.isnan(w.equinox)

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.radesys = 'FK5'
        w.set()
        assert w.equinox == 2000.

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.radesys = 'FK4'
        w.set()
        assert w.equinox == 1950

        w = _wcs.Wcsprm(naxis=2)
        w.ctype = ctype
        w.radesys = 'FK4-NO-E'
        w.set()
        assert w.equinox == 1950
示例#15
0
def test_alt_invalid2():
    w = _wcs.Wcsprm()
    with pytest.raises(ValueError):
        w.alt = "  "
示例#16
0
def test_cubeface():
    w = _wcs.Wcsprm()
    assert w.cubeface == -1
    w.cubeface = 0
    with pytest.raises(OverflowError):
        w.cubeface = -1
示例#17
0
def test_axis_types():
    w = _wcs.Wcsprm()
    assert_array_equal(w.axis_types, [0, 0])
示例#18
0
def test_cunit():
    w = _wcs.Wcsprm()
    assert list(w.cunit) == [u.Unit(''), u.Unit('')]
    w.cunit = [u.m, 'km']
    assert w.cunit[0] == u.m
    assert w.cunit[1] == u.km
示例#19
0
def test_fix5():
    w = _wcs.Wcsprm()
    with pytest.raises(ValueError):
        w.fix(naxis=[0, 1, 2])
示例#20
0
def test_cunit_invalid():
    w = _wcs.Wcsprm()
    with pytest.warns(u.UnitsWarning, match='foo') as warns:
        w.cunit[0] = 'foo'
    assert len(warns) == 1
示例#21
0
def test_imgpix_matrix():
    w = _wcs.Wcsprm()
    with pytest.raises(AssertionError):
        w.imgpix_matrix
示例#22
0
def test_unitfix():
    w = _wcs.Wcsprm()
    w.unitfix()
示例#23
0
def test_isunity():
    w = _wcs.Wcsprm()
    assert(w.is_unity())
示例#24
0
def test_dateavg():
    w = _wcs.Wcsprm()
    assert w.dateavg == ''
示例#25
0
def test_lat_set():
    w = _wcs.Wcsprm()
    with pytest.raises(AttributeError):
        w.lat = 0
示例#26
0
def test_dateobs():
    w = _wcs.Wcsprm()
    assert w.dateobs == ''
示例#27
0
def test_lng():
    w = _wcs.Wcsprm()
    assert w.lng == -1
示例#28
0
def test_datfix():
    w = _wcs.Wcsprm()
    w.dateobs = '31/12/99'
    assert w.datfix() == 0
    assert w.dateobs == '1999-12-31'
    assert w.mjdobs == 51543.0
示例#29
0
def test_lngtyp_set():
    w = _wcs.Wcsprm()
    with pytest.raises(AttributeError):
        w.lngtyp = 0
示例#30
0
def test_wcs_sub_error_message():
    # Issue #1587
    w = _wcs.Wcsprm()
    with pytest.raises(TypeError) as e:
        w.sub('latitude')
    assert e.match("axes must None, a sequence or an integer$")