Пример #1
0
def test__geo2qd_longitude():
    A = Apex(date=2000, refh=300)
    assert_allclose(A._geo2qd(60, 180, 100), fa.apxg2q(60, 180, 100, 0)[:2])
    assert_allclose(A._geo2qd(60, -180, 100), fa.apxg2q(60, -180, 100, 0)[:2])
    assert_allclose(A._geo2qd(60, -180, 100), A._geo2qd(60, 180, 100))
    for i in range(-5, 5):
        for lat in [0, 30, 60, 90]:
            assert_allclose(A._geo2qd(lat, 15+i*360, 100), fa.apxg2q(lat, 15, 100, 0)[:2])
Пример #2
0
def test__basevec_longitude():
    A = Apex(date=2000, refh=300)
    assert_allclose(A._basevec(60, 180, 100), fa.apxg2q(60, 180, 100, 1)[2:4])
    assert_allclose(A._basevec(60, -180, 100), fa.apxg2q(60, -180, 100, 1)[2:4])
    assert_allclose(A._basevec(60, -180, 100), A._basevec(60, 180, 100))
    for i in range(-5, 5):
        for lat in [0, 30, 60, 90]:
            assert_allclose(A._basevec(lat, 15+i*360, 100), fa.apxg2q(lat, 15, 100, 1)[2:4])
Пример #3
0
def test__geo2qd_array():
    A = Apex(date=2000, refh=300)
    lats, lons = A._geo2qd([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    lat1, lon1 = fa.apxg2q(0, 15, 100, 0)[:2]
    lat2, lon2 = fa.apxg2q(30, 15, 200, 0)[:2]
    lat3, lon3 = fa.apxg2q(60, 15, 300, 0)[:2]
    lat4, lon4 = fa.apxg2q(90, 15, 400, 0)[:2]
    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))
Пример #4
0
def test__geo2qd_longitude():
    A = Apex(date=2000, refh=300)
    assert_allclose(A._geo2qd(60, 180, 100), fa.apxg2q(60, 180, 100, 0)[:2])
    assert_allclose(A._geo2qd(60, -180, 100), fa.apxg2q(60, -180, 100, 0)[:2])
    assert_allclose(A._geo2qd(60, -180, 100), A._geo2qd(60, 180, 100))
    for i in range(-5, 5):
        for lat in [0, 30, 60, 90]:
            assert_allclose(A._geo2qd(lat, 15 + i * 360, 100),
                            fa.apxg2q(lat, 15, 100, 0)[:2])
Пример #5
0
def test__basevec_longitude():
    A = Apex(date=2000, refh=300)
    assert_allclose(A._basevec(60, 180, 100), fa.apxg2q(60, 180, 100, 1)[2:4])
    assert_allclose(A._basevec(60, -180, 100),
                    fa.apxg2q(60, -180, 100, 1)[2:4])
    assert_allclose(A._basevec(60, -180, 100), A._basevec(60, 180, 100))
    for i in range(-5, 5):
        for lat in [0, 30, 60, 90]:
            assert_allclose(A._basevec(lat, 15 + i * 360, 100),
                            fa.apxg2q(lat, 15, 100, 1)[2:4])
Пример #6
0
def test__geo2qd_array():
    A = Apex(date=2000, refh=300)
    lats, lons = A._geo2qd([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    lat1, lon1 = fa.apxg2q(0, 15, 100, 0)[:2]
    lat2, lon2 = fa.apxg2q(30, 15, 200, 0)[:2]
    lat3, lon3 = fa.apxg2q(60, 15, 300, 0)[:2]
    lat4, lon4 = fa.apxg2q(90, 15, 400, 0)[:2]
    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))
Пример #7
0
def test__basevec_array():
    A = Apex(date=2000, refh=300)
    f1s, f2s = A._basevec([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    f11, f21 = fa.apxg2q(0, 15, 100, 1)[2:4]
    f12, f22 = fa.apxg2q(30, 15, 200, 1)[2:4]
    f13, f23 = fa.apxg2q(60, 15, 300, 1)[2:4]
    f14, f24 = fa.apxg2q(90, 15, 400, 1)[2:4]
    assert_allclose(f1s[0, 0], f11)
    assert_allclose(f1s[0, 1], f12)
    assert_allclose(f1s[1, 0], f13)
    assert_allclose(f1s[1, 1], f14)
    assert_allclose(f2s[0, 0], f21)
    assert_allclose(f2s[0, 1], f22)
    assert_allclose(f2s[1, 0], f23)
    assert_allclose(f2s[1, 1], f24)
Пример #8
0
def test__basevec_array():
    A = Apex(date=2000, refh=300)
    f1s, f2s = A._basevec([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    f11, f21 = fa.apxg2q(0, 15, 100, 1)[2:4]
    f12, f22 = fa.apxg2q(30, 15, 200, 1)[2:4]
    f13, f23 = fa.apxg2q(60, 15, 300, 1)[2:4]
    f14, f24 = fa.apxg2q(90, 15, 400, 1)[2:4]
    assert_allclose(f1s[0, 0], f11)
    assert_allclose(f1s[0, 1], f12)
    assert_allclose(f1s[1, 0], f13)
    assert_allclose(f1s[1, 1], f14)
    assert_allclose(f2s[0, 0], f21)
    assert_allclose(f2s[0, 1], f22)
    assert_allclose(f2s[1, 0], f23)
    assert_allclose(f2s[1, 1], f24)
Пример #9
0
def test_g2q2d():
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 179]:
            qlat, qlon, _, _, _ = fa.apxg2q(lat, lon, 100, 0)
            glat, glon, _ = fa.apxq2g(qlat, qlon, 100, 1e-10)
            assert_allclose(glat, lat, atol=0.01)
            assert_allclose(glon, lon, atol=0.01)
Пример #10
0
def test_g2q2d():
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 179]:
            qlat, qlon, _, _, _ = fa.apxg2q(lat, lon, 100, 0)
            glat, glon, _ = fa.apxq2g(qlat, qlon, 100, 1e-10)
            assert_allclose(glat, lat, atol=0.01)
            assert_allclose(glon, lon, atol=0.01)
Пример #11
0
def test_apxg2q():

    qlat, qlon, f1, f2, f = fa.apxg2q(60, 15, 100, 1)
    assert_allclose(qlat, 56.531288146972656)
    assert_allclose(qlon, 94.1068344116211)
    assert_allclose(f1, [1.07978308, 0.10027108], rtol=1e-6)
    assert_allclose(f2, [-0.24546318, 0.90718889], rtol=1e-6)
    assert_allclose(f, 1.0041800737380981)
Пример #12
0
def test_apxg2q():

    qlat, qlon, f1, f2, f = fa.apxg2q(60, 15, 100, 1)
    assert_allclose(qlat, 56.531288146972656)
    assert_allclose(qlon, 94.1068344116211)
    assert_allclose(f1, [1.07978308, 0.10027108], rtol=1e-6)
    assert_allclose(f2, [-0.24546318, 0.90718889], rtol=1e-6)
    assert_allclose(f, 1.0041800737380981)
Пример #13
0
def test_g2q2d():
    fa.loadapxsh(os.path.join(os.path.dirname(apexpy.__file__), 'apexsh.dat'),
                 2000)
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 179]:
            qlat, qlon, _, _, _ = fa.apxg2q(lat, lon, 100, 0)
            glat, glon, _ = fa.apxq2g(qlat, qlon, 100, 1e-10)
            assert_allclose(glat, lat, atol=0.01)
            assert_allclose(glon, lon, atol=0.01)
Пример #14
0
def test_apxg2q():
    """Test fortran apex geographic to quasi-dipole
    """
    fa.loadapxsh(os.path.join(os.path.dirname(apexpy.__file__), 'apexsh.dat'),
                 2000)
    qlat, qlon, f1, f2, f = fa.apxg2q(60, 15, 100, 1)
    assert_allclose(qlat, 56.531288146972656)
    assert_allclose(qlon, 94.1068344116211)
    assert_allclose(f1, [1.07978308, 0.10027108], rtol=1e-6)
    assert_allclose(f2, [-0.24546318, 0.90718889], rtol=1e-6)
    assert_allclose(f, 1.0041800737380981)
Пример #15
0
def test__geo2qd_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._geo2qd(lat, lon, 100),
                            fa.apxg2q(lat, lon, 100, 0)[:2])
Пример #16
0
def test__basevec_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._basevec(lat, lon, 100),
                            fa.apxg2q(lat, lon, 100, 1)[2:4])
Пример #17
0
def test__geo2qd_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._geo2qd(lat, lon, 100), fa.apxg2q(lat, lon, 100, 0)[:2])
Пример #18
0
def test__basevec_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._basevec(lat, lon, 100), fa.apxg2q(lat, lon, 100, 1)[2:4])