def test_basevectors_qd_vectorization(): apex_out = Apex(date=2000, refh=300) ret = apex_out.basevectors_qd([60, 60, 60, 60], 15, 100, coords='geo') for r in ret: assert r.shape == (2, 4) ret = apex_out.basevectors_qd(60, [15, 15, 15, 15], 100, coords='geo') for r in ret: assert r.shape == (2, 4) ret = apex_out.basevectors_qd(60, 15, [100, 100, 100, 100], coords='geo') for r in ret: assert r.shape == (2, 4)
def test_basevectors_qd_vectorization(): A = Apex(date=2000, refh=300) ret = A.basevectors_qd([60, 60, 60, 60], 15, 100, coords='geo') for r in ret: assert r.shape == (2, 4) ret = A.basevectors_qd(60, [15, 15, 15, 15], 100, coords='geo') for r in ret: assert r.shape == (2, 4) ret = A.basevectors_qd(60, 15, [100, 100, 100, 100], coords='geo') for r in ret: assert r.shape == (2, 4)
def test_basevectors_qd_array(): A = Apex(date=2000, refh=300) f1, f2 = A.basevectors_qd([0, 30], 15, 100, coords='geo') f1_lat0, f2_lat0 = A._basevec(0, 15, 100) f1_lat30, f2_lat30 = A._basevec(30, 15, 100) assert_allclose(f1[:, 0], f1_lat0) assert_allclose(f2[:, 0], f2_lat0) assert_allclose(f1[:, 1], f1_lat30) assert_allclose(f2[:, 1], f2_lat30)
def test_basevectors_qd_array(): apex_out = Apex(date=2000, refh=300) f1, f2 = apex_out.basevectors_qd([0, 30], 15, 100, coords='geo') f1_lat0, f2_lat0 = apex_out._basevec(0, 15, 100) f1_lat30, f2_lat30 = apex_out._basevec(30, 15, 100) assert_allclose(f1[:, 0], f1_lat0) assert_allclose(f2[:, 0], f2_lat0) assert_allclose(f1[:, 1], f1_lat30) assert_allclose(f2[:, 1], f2_lat30)
for i in range(3) ] for ax in axes_curl: ax.coastlines() axes_curl[0].set_title('Magnetic Field') axes_curl[1].set_title('Pole Amplitude') axes_curl[2].set_title('Ionospheric Currents') for ax in axes_div: ax.coastlines() fig.text(0, 0.75, 'Curl-Free') fig.text(0, 0.25, 'Divergence-Free') cax_curl = fig.add_subplot(gs[1, 4]) caxes_div = [fig.add_subplot(gs[3, 3 * (i) + 1]) for i in range(3)] """Grid""" A = Apex(date=dt.datetime(2008, 6, 1, 0, 0, 0)) f1, f2 = A.basevectors_qd(lat_centre, lon_centre, 0, coords='geo') qd_north = f2 / np.linalg.norm(f2) East, North = qd_north[0], qd_north[1] Gridproj = CS.CSprojection((lon_centre, lat_centre), [East, North]) node_grid = CS.CSgrid(Gridproj, 3700, 2200, 50., 50.) Evalproj = CS.CSprojection((lon_centre - 0.23, lat_centre + 0.23), [East, North]) eval_grid = CS.CSgrid(Evalproj, 3300, 1800, 50., 50.) node_lons, node_lats = node_grid.lon.flatten(), node_grid.lat.flatten() lat, lon = eval_grid.lat.flatten(), eval_grid.lon.flatten() min_lon = min(node_lons) - 5 max_lon = max(node_lons) + 5 min_lat = min(node_lats) - 5 # max_lat= max(node_lats) max_lat = 90
def test_basevectors_qd_scalar_shape(): A = Apex(date=2000, refh=300) ret = A.basevectors_qd(60, 15, 100) for r in ret: assert r.shape == (2,)
def test_basevectors_qd_scalar_qd(): A = Apex(date=2000, refh=300) glat, glon, _ = A.qd2geo(60, 15, 100, precision=1e-2) assert_allclose(A.basevectors_qd(60, 15, 100, coords='qd', precision=1e-2), A._basevec(glat, glon, 100))
def test_basevectors_qd_scalar_geo(): A = Apex(date=2000, refh=300) assert_allclose(A.basevectors_qd(60, 15, 100, coords='geo'), A._basevec(60, 15, 100))
vmax=np.max(M)) ax2.set_ylim(ax.get_ylim()) ax2.set_xlim(ax.get_xlim()) cbar = fig.colorbar(s, ax=ax) cbar2 = fig.colorbar(s2, ax=ax2) #%% Cubed Sphere Example if __name__ == '__main__': from SECpy import SECS, Example import cubedsphere as CS from apexpy import Apex import datetime as dt """Grid""" lon_centre = 17.7 lat_centre = 68.1 A = Apex(date=dt.datetime(2008, 6, 1, 0, 0, 0)) f1, f2 = A.basevectors_qd(lat_centre, lon_centre, 0, coords='geo') qd_north = f2 / np.linalg.norm(f2) East, North = qd_north[0], qd_north[1] Gridproj = CS.CSprojection((lon_centre, lat_centre), [East, North]) node_grid = CS.CSgrid(Gridproj, 3700, 2200, 50., 50.) Evalproj = CS.CSprojection((lon_centre - 0.23, lat_centre + 0.23), [East, North]) eval_grid = CS.CSgrid(Evalproj, 3300, 1800, 50., 50.) x, y = node_grid.xi, node_grid.eta xeval, yeval = eval_grid.xi, eval_grid.eta node_lons, node_lats = node_grid.lon.flatten(), node_grid.lat.flatten() lat, lon = eval_grid.lat.flatten(), eval_grid.lon.flatten() """Interpolate""" Btheta, Bphi, Br, MagLon, MagLat = Example.ExampleData() poles = SECS(node_lons, node_lats, lon, lat) poles.Fitting_Matrix(MagLon, MagLat)
def test_basevectors_qd_scalar_shape(): apex_out = Apex(date=2000, refh=300) ret = apex_out.basevectors_qd(60, 15, 100) for r in ret: assert r.shape == (2, )
def test_basevectors_qd_scalar_qd(): apex_out = Apex(date=2000, refh=300) glat, glon, _ = apex_out.qd2geo(60, 15, 100, precision=1e-2) assert_allclose( apex_out.basevectors_qd(60, 15, 100, coords='qd', precision=1e-2), apex_out._basevec(glat, glon, 100))
def test_basevectors_qd_scalar_geo(): apex_out = Apex(date=2000, refh=300) assert_allclose(apex_out.basevectors_qd(60, 15, 100, coords='geo'), apex_out._basevec(60, 15, 100))
def test_basevectors_qd_scalar_apex(): A = Apex(date=2000, refh=300) glat, glon, _ = A.apex2geo(60, 15, 100, precision=1e-2) assert_allclose( A.basevectors_qd(60, 15, 100, coords='apex', precision=1e-2), A._basevec(glat, glon, 100))