def test__qd2geo_longitude(): A = Apex(date=2000, refh=300) assert_allclose(A._qd2geo(60, 180, 100, 1e-2), fa.apxq2g(60, 180, 100, 1e-2)) assert_allclose(A._qd2geo(60, -180, 100, 1e-2), fa.apxq2g(60, -180, 100, 1e-2)) assert_allclose(A._qd2geo(60, -180, 100, 1e-2), A._qd2geo(60, 180, 100, 1e-2)) for i in range(-5, 5): for lat in [0, 30, 60, 90]: assert_allclose(A._qd2geo(lat, 15+i*360, 100, 1e-2), fa.apxq2g(lat, 15, 100, 1e-2))
def test__qd2geo_array(): A = Apex(date=2000, refh=300) lats, lons, errs = A._qd2geo([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]], 1e-2) lat1, lon1, err1 = fa.apxq2g(0, 15, 100, 1e-2) lat2, lon2, err2 = fa.apxq2g(30, 15, 200, 1e-2) lat3, lon3, err3 = fa.apxq2g(60, 15, 300, 1e-2) lat4, lon4, err4 = fa.apxq2g(90, 15, 400, 1e-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)) assert_allclose(errs.astype(float), np.array([[err1, err2], [err3, err4]], dtype=float))
def test__qd2geo_longitude(): apex_out = Apex(date=2000, refh=300) assert_allclose(apex_out._qd2geo(60, 180, 100, 1e-2), fa.apxq2g(60, 180, 100, 1e-2)) assert_allclose(apex_out._qd2geo(60, -180, 100, 1e-2), fa.apxq2g(60, -180, 100, 1e-2)) assert_allclose(apex_out._qd2geo(60, -180, 100, 1e-2), apex_out._qd2geo(60, 180, 100, 1e-2)) for i in range(-5, 5): for lat in [0, 30, 60, 90]: assert_allclose(apex_out._qd2geo(lat, 15 + i * 360, 100, 1e-2), fa.apxq2g(lat, 15, 100, 1e-2))
def test__qd2geo_array(): apex_out = Apex(date=2000, refh=300) lats, lons, errs = apex_out._qd2geo([[0, 30], [60, 90]], 15, [[100, 200], [300, 400]], 1e-2) lat1, lon1, err1 = fa.apxq2g(0, 15, 100, 1e-2) lat2, lon2, err2 = fa.apxq2g(30, 15, 200, 1e-2) lat3, lon3, err3 = fa.apxq2g(60, 15, 300, 1e-2) lat4, lon4, err4 = fa.apxq2g(90, 15, 400, 1e-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)) assert_allclose(errs.astype(float), np.array([[err1, err2], [err3, err4]], dtype=float))
def test_apxq2g_lowprecision(): fa.loadapxsh(os.path.join(os.path.dirname(apexpy.__file__), 'apexsh.dat'), 2000) glat, glon, error = fa.apxq2g(60, 15, 100, -1) assert_allclose(glat, 51.00891876220703) assert_allclose(glon, -66.11973571777344) assert_allclose(error, -9999.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)
def test__qd2geo_scalar(): apex_out = Apex(date=2000, refh=300) for lat in [0, 30, 60, 89]: for lon in [-179, -90, 0, 90, 180]: for prec in [-1, 1e-2, 1e-10]: assert_allclose(apex_out._qd2geo(lat, lon, 100, prec), fa.apxq2g(lat, lon, 100, prec))
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)
def test_apxq2g(): """ Test fortran quasi-dipole to geographic """ fa.loadapxsh(os.path.join(os.path.dirname(apexpy.__file__), 'apexsh.dat'), 2000) glat, glon, error = fa.apxq2g(60, 15, 100, 1e-2) assert_allclose( [glat, glon, error], [50.97946548461914, -66.16902923583984, 0.00010020843910751864], atol=1e-6)
def test__qd2geo_scalar(): A = Apex(date=2000, refh=300) for lat in [0, 30, 60, 89]: for lon in [-179, -90, 0, 90, 180]: for prec in [-1, 1e-2, 1e-10]: assert_allclose(A._qd2geo(lat, lon, 100, prec), fa.apxq2g(lat, lon, 100, prec))
def test_apxq2g_lowprecision(): glat, glon, error = fa.apxq2g(60, 15, 100, -1) assert_allclose(glat, 51.00891876220703) assert_allclose(glon, -66.11973571777344) assert_allclose(error, -9999.0)
def test_apxq2g(): glat, glon, error = fa.apxq2g(60, 15, 100, 1e-2) assert_allclose(glat, 50.97946548461914) assert_allclose(glon, -66.16902923583984) assert_allclose(error, 0.00010020843910751864)