def test_radesys_defaults(): w = _wcs.Wcsprm() w.ctype = ['RA---TAN', 'DEC--TAN'] w.set() assert w.radesys == "ICRS"
def test_lattyp(): w = _wcs.Wcsprm() print(repr(w.lattyp)) assert w.lattyp == " "
def test_lngtyp(): w = _wcs.Wcsprm() assert w.lngtyp == " "
def test_imgpix_matrix2(): w = _wcs.Wcsprm() with pytest.raises(AttributeError): w.imgpix_matrix = None
def test_lat(): w = _wcs.Wcsprm() assert w.lat == -1
def test_fix4(): w = _wcs.Wcsprm() with pytest.raises(ValueError): w.fix('X')
def test_get_pv(): # TODO: We need some data with PVi_ma keywords w = _wcs.Wcsprm() assert len(w.get_pv()) == 0
def test_crota_missing(): w = _wcs.Wcsprm() assert w.has_crota() is False with pytest.raises(AttributeError): w.crota
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"]')
def test_cname_invalid(): w = _wcs.Wcsprm() with pytest.raises(TypeError): w.cname = [42, 54]
def test_colnum_invalid(): w = _wcs.Wcsprm() with pytest.raises(TypeError): w.colnum = 'foo'
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
def test_cdelt_delete(): w = _wcs.Wcsprm() with pytest.raises(TypeError): del w.cdelt
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
def test_alt_invalid2(): w = _wcs.Wcsprm() with pytest.raises(ValueError): w.alt = " "
def test_cubeface(): w = _wcs.Wcsprm() assert w.cubeface == -1 w.cubeface = 0 with pytest.raises(OverflowError): w.cubeface = -1
def test_axis_types(): w = _wcs.Wcsprm() assert_array_equal(w.axis_types, [0, 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
def test_fix5(): w = _wcs.Wcsprm() with pytest.raises(ValueError): w.fix(naxis=[0, 1, 2])
def test_cunit_invalid(): w = _wcs.Wcsprm() with pytest.warns(u.UnitsWarning, match='foo') as warns: w.cunit[0] = 'foo' assert len(warns) == 1
def test_imgpix_matrix(): w = _wcs.Wcsprm() with pytest.raises(AssertionError): w.imgpix_matrix
def test_unitfix(): w = _wcs.Wcsprm() w.unitfix()
def test_isunity(): w = _wcs.Wcsprm() assert(w.is_unity())
def test_dateavg(): w = _wcs.Wcsprm() assert w.dateavg == ''
def test_lat_set(): w = _wcs.Wcsprm() with pytest.raises(AttributeError): w.lat = 0
def test_dateobs(): w = _wcs.Wcsprm() assert w.dateobs == ''
def test_lng(): w = _wcs.Wcsprm() assert w.lng == -1
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
def test_lngtyp_set(): w = _wcs.Wcsprm() with pytest.raises(AttributeError): w.lngtyp = 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$")