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__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 #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_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 #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__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 #8
0
def test__geo2apexall_array():
    A = Apex(date=2000, refh=300)
    ret = A._geo2apexall([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    ret1 = fa.apxg2all(0, 15, 100, 300, 1)
    ret2 = fa.apxg2all(30, 15, 200, 300, 1)
    ret3 = fa.apxg2all(60, 15, 300, 300, 1)
    ret4 = fa.apxg2all(90, 15, 400, 300, 1)
    for i in range(len(ret)):
        try:
            # ret[i] is array of floats
            assert_allclose(ret[i].astype(float), np.array([[ret1[i], ret2[i]], [ret3[i], ret4[i]]], dtype=float))
        except:
            # ret[i] is array of arrays
            assert_allclose(ret[i][0, 0], ret1[i])
            assert_allclose(ret[i][0, 1], ret2[i])
            assert_allclose(ret[i][1, 0], ret3[i])
            assert_allclose(ret[i][1, 1], ret4[i])
Beispiel #9
0
def test__geo2apexall_scalar():
    A = Apex(date=2000, refh=300)
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 180]:
            ret1 = A._geo2apexall(lat, lon, 100)
            ret2 = fa.apxg2all(lat, lon, 100, 300, 1)
            for r1, r2 in zip(ret1, ret2):
                assert_allclose(r1, r2)
Beispiel #10
0
def test__geo2apexall_scalar():
    apex_out = Apex(date=2000, refh=300)
    for lat in [0, 30, 60, 89]:
        for lon in [-179, -90, 0, 90, 180]:
            ret1 = apex_out._geo2apexall(lat, lon, 100)
            ret2 = fa.apxg2all(lat, lon, 100, 300, 1)
            for r1, r2 in zip(ret1, ret2):
                assert_allclose(r1, r2)
Beispiel #11
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 #12
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 #13
0
def test__geo2apexall_array():
    A = Apex(date=2000, refh=300)
    ret = A._geo2apexall([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]])
    ret1 = fa.apxg2all(0, 15, 100, 300, 1)
    ret2 = fa.apxg2all(30, 15, 200, 300, 1)
    ret3 = fa.apxg2all(60, 15, 300, 300, 1)
    ret4 = fa.apxg2all(90, 15, 400, 300, 1)
    for i in range(len(ret)):
        try:
            # ret[i] is array of floats
            assert_allclose(
                ret[i].astype(float),
                np.array([[ret1[i], ret2[i]], [ret3[i], ret4[i]]],
                         dtype=float))
        except:
            # ret[i] is array of arrays
            assert_allclose(ret[i][0, 0], ret1[i])
            assert_allclose(ret[i][0, 1], ret2[i])
            assert_allclose(ret[i][1, 0], ret3[i])
            assert_allclose(ret[i][1, 1], ret4[i])
Beispiel #14
0
def test_apxg2all():
    qlat, qlon, mlat, mlon, f1, f2, f, d1, d2, d3, d, e1, e2, e3 = fa.apxg2all(60, 15, 100, 300, 1)
    assert_allclose(qlat, 56.531288146972656)
    assert_allclose(qlon, 94.1068344116211)
    assert_allclose(mlat, 55.94841766357422)
    assert_allclose(mlon, 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)
    assert_allclose(d1, [0.94957006, 0.2569305, 0.09049489], rtol=1e-6)
    assert_allclose(d2, [0.10011058, -1.07805467, -0.33892459], rtol=1e-6)
    assert_allclose(d3, [0.00865366, 0.27327025, -0.86666465], rtol=1e-6)
    assert_allclose(d, 1.1003910303115845)
    assert_allclose(e1, [1.02692986, 0.08382936, 0.03668636], rtol=1e-6)
    assert_allclose(e2, [0.24740215, -0.82374191, -0.25726584], rtol=1e-6)
    assert_allclose(e3, [0.01047837, 0.33089212, -1.04940987], rtol=1e-6)
Beispiel #15
0
def test_apxg2all():
    qlat, qlon, mlat, mlon, f1, f2, f, d1, d2, d3, d, e1, e2, e3 = fa.apxg2all(
        60, 15, 100, 300, 1)
    assert_allclose(qlat, 56.531288146972656)
    assert_allclose(qlon, 94.1068344116211)
    assert_allclose(mlat, 55.94841766357422)
    assert_allclose(mlon, 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)
    assert_allclose(d1, [0.94957006, 0.2569305, 0.09049489], rtol=1e-6)
    assert_allclose(d2, [0.10011058, -1.07805467, -0.33892459], rtol=1e-6)
    assert_allclose(d3, [0.00865366, 0.27327025, -0.86666465], rtol=1e-6)
    assert_allclose(d, 1.1003910303115845)
    assert_allclose(e1, [1.02692986, 0.08382936, 0.03668636], rtol=1e-6)
    assert_allclose(e2, [0.24740215, -0.82374191, -0.25726584], rtol=1e-6)
    assert_allclose(e3, [0.01047837, 0.33089212, -1.04940987], rtol=1e-6)
Beispiel #16
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 #17
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])