Beispiel #1
0
def test__geo2apex_longitude():
    A = Apex(date=2000, refh=300)
    assert_allclose(A._geo2apex(60, 180, 100), fa.apxg2all(60, 180, 100, 300, 0)[2:4])
    assert_allclose(A._geo2apex(60, -180, 100), fa.apxg2all(60, -180, 100, 300, 0)[2:4])
    assert_allclose(A._geo2apex(60, -180, 100), A._geo2apex(60, 180, 100))
    for i in range(-5, 5):
        for lat in [0, 30, 60, 90]:
            assert_allclose(A._geo2apex(lat, 15+i*360, 100), fa.apxg2all(lat, 15, 100, 300, 0)[2:4])
Beispiel #2
0
def test_set_refh():
    A = Apex(date=2000, refh=300)
    assert A.refh, 300
    ret_300 = A._geo2apex(60, 15, 100)
    A.set_refh(500)
    assert A.refh == 500
    ret_500 = A._geo2apex(60, 15, 100)

    assert_allclose(ret_300, fa.apxg2all(60, 15, 100, 300, 0)[2:4])
    assert_allclose(ret_500, fa.apxg2all(60, 15, 100, 500, 0)[2:4])
Beispiel #3
0
def test_set_refh():
    apex_out = Apex(date=2000, refh=300)
    assert apex_out.refh, 300
    ret_300 = apex_out._geo2apex(60, 15, 100)
    apex_out.set_refh(500)
    assert apex_out.refh == 500
    ret_500 = apex_out._geo2apex(60, 15, 100)

    assert_allclose(ret_300, fa.apxg2all(60, 15, 100, 300, 0)[2:4])
    assert_allclose(ret_500, fa.apxg2all(60, 15, 100, 500, 0)[2:4])
Beispiel #4
0
def test_set_refh():
    A = Apex(date=2000, refh=300)
    assert A.refh, 300
    ret_300 = A._geo2apex(60, 15, 100)
    A.set_refh(500)
    assert A.refh == 500
    ret_500 = A._geo2apex(60, 15, 100)

    assert_allclose(ret_300, fa.apxg2all(60, 15, 100, 300, 0)[2:4])
    assert_allclose(ret_500, fa.apxg2all(60, 15, 100, 500, 0)[2:4])
Beispiel #5
0
def test__geo2apex_longitude():
    A = Apex(date=2000, refh=300)
    assert_allclose(A._geo2apex(60, 180, 100),
                    fa.apxg2all(60, 180, 100, 300, 0)[2:4])
    assert_allclose(A._geo2apex(60, -180, 100),
                    fa.apxg2all(60, -180, 100, 300, 0)[2:4])
    assert_allclose(A._geo2apex(60, -180, 100), A._geo2apex(60, 180, 100))
    for i in range(-5, 5):
        for lat in [0, 30, 60, 90]:
            assert_allclose(A._geo2apex(lat, 15 + i * 360, 100),
                            fa.apxg2all(lat, 15, 100, 300, 0)[2:4])
Beispiel #6
0
def test__geo2apex_array():
    A = Apex(date=2000, refh=300)
    lats, lons = A._geo2apex([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    lat1, lon1 = fa.apxg2all(0, 15, 100, 300, 0)[2:4]
    lat2, lon2 = fa.apxg2all(30, 15, 200, 300, 0)[2:4]
    lat3, lon3 = fa.apxg2all(60, 15, 300, 300, 0)[2:4]
    lat4, lon4 = fa.apxg2all(90, 15, 400, 300, 0)[2:4]
    assert_allclose(lats.astype(float), np.array([[lat1, lat2], [lat3, lat4]], dtype=float))
    assert_allclose(lons.astype(float), np.array([[lon1, lon2], [lon3, lon4]], dtype=float))
Beispiel #7
0
def test_set_epoch():
    A = Apex(date=2000.2, refh=300)
    assert_allclose(A.year, 2000.2)
    ret_2000_2_py = A._geo2apex(60, 15, 100)
    A.set_epoch(2000.8)
    assert_allclose(A.year, 2000.8)
    ret_2000_8_py = A._geo2apex(60, 15, 100)

    assert ret_2000_2_py != ret_2000_8_py

    fa.loadapxsh(A.datafile, 2000.2)
    ret_2000_2_apex = fa.apxg2all(60, 15, 100, 300, 0)[2:4]
    fa.loadapxsh(A.datafile, 2000.8)
    ret_2000_8_apex = fa.apxg2all(60, 15, 100, 300, 0)[2:4]

    assert ret_2000_2_apex != ret_2000_8_apex

    assert_allclose(ret_2000_2_py, ret_2000_2_apex)
    assert_allclose(ret_2000_8_py, ret_2000_8_apex)
Beispiel #8
0
def test_set_epoch():
    apex_out = Apex(date=2000.2, refh=300)
    assert_allclose(apex_out.year, 2000.2)
    ret_2000_2_py = apex_out._geo2apex(60, 15, 100)
    apex_out.set_epoch(2000.8)
    assert_allclose(apex_out.year, 2000.8)
    ret_2000_8_py = apex_out._geo2apex(60, 15, 100)

    assert ret_2000_2_py != ret_2000_8_py

    fa.loadapxsh(apex_out.datafile, 2000.2)
    ret_2000_2_apex = fa.apxg2all(60, 15, 100, 300, 0)[2:4]
    fa.loadapxsh(apex_out.datafile, 2000.8)
    ret_2000_8_apex = fa.apxg2all(60, 15, 100, 300, 0)[2:4]

    assert ret_2000_2_apex != ret_2000_8_apex

    assert_allclose(ret_2000_2_py, ret_2000_2_apex)
    assert_allclose(ret_2000_8_py, ret_2000_8_apex)
Beispiel #9
0
def test__geo2apex_array():
    A = Apex(date=2000, refh=300)
    lats, lons = A._geo2apex([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    lat1, lon1 = fa.apxg2all(0, 15, 100, 300, 0)[2:4]
    lat2, lon2 = fa.apxg2all(30, 15, 200, 300, 0)[2:4]
    lat3, lon3 = fa.apxg2all(60, 15, 300, 300, 0)[2:4]
    lat4, lon4 = fa.apxg2all(90, 15, 400, 300, 0)[2:4]
    assert_allclose(lats.astype(float),
                    np.array([[lat1, lat2], [lat3, lat4]], dtype=float))
    assert_allclose(lons.astype(float),
                    np.array([[lon1, lon2], [lon3, lon4]], dtype=float))
Beispiel #10
0
def test__geo2apex_scalar():
    A = Apex(date=2000, refh=300)
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 180]:
            assert_allclose(A._geo2apex(lat, lon, 100), fa.apxg2all(lat, lon, 100, 300, 0)[2:4])
Beispiel #11
0
def test_geo2apex():
    A = Apex(date=2000, refh=300)
    lat, lon = A.geo2apex(60, 15, 100)
    assert_allclose((lat, lon), A._geo2apex(60, 15, 100))
    assert type(lat) != np.ndarray
    assert type(lon) != np.ndarray
Beispiel #12
0
def test__geo2apex_scalar():
    apex_out = Apex(date=2000, refh=300)
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 180]:
            assert_allclose(apex_out._geo2apex(lat, lon, 100),
                            fa.apxg2all(lat, lon, 100, 300, 0)[2:4])
Beispiel #13
0
def test_geo2apex():
    apex_out = Apex(date=2000, refh=300)
    lat, lon = apex_out.geo2apex(60, 15, 100)
    assert_allclose((lat, lon), apex_out._geo2apex(60, 15, 100))
    assert type(lat) != np.ndarray
    assert type(lon) != np.ndarray