本文整理汇总了Python中apexpy.Apex类的典型用法代码示例。如果您正苦于以下问题:Python Apex类的具体用法?Python Apex怎么用?Python Apex使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Apex类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plot_ion_drift
def plot_ion_drift(show=True,save=True):
apex = Apex(date=2003)
qlat, qlon = apex.convert(-90, 0, source='apex', dest='geo', height=400)
g = g2a
plt.close('all')
plt.figure(figsize=(7.26, 9.25))
for ialt, alt in enumerate([130, 200, 300, 400, 500, 600]):
alt_ind = np.argmin(np.abs(g['Altitude'][0, 0, :]/1000-alt))
alt_str = '%6.2f' % (g['Altitude'][0, 0, alt_ind]/1000)
ax, projection = gcc.create_map(
3, 2, ialt+1, 'polar', nlat=nlat, slat=slat, dlat=10,
centrallon=g3ca.calculate_centrallon(g, 'polar', useLT=True),
coastlines=False)
lon0, lat0, ewind, nwind = g3ca.vector_data(g, 'ion', alt=alt)
lon0, lat0, ewind, nwind = g3ca.convert_vector(
lon0, lat0, ewind, nwind, plot_type='polar',
projection=projection)
hq = ax.quiver(
lon0, lat0, ewind, nwind, scale=1500, scale_units='inches',
regrid_shape=20, headwidth=5)
ax.quiverkey(hq, 0.93, -0.1, 1000, '1000 m/s')
ax.scatter(qlon, qlat, color='k', transform=ccrs.PlateCarree())
plt.title('%s km' % alt_str, y=1.05)
plt.text(0.5, 0.95, 'Time: '+tstring, fontsize=15,
horizontalalignment='center', transform=plt.gcf().transFigure)
if show:
plt.show()
if save:
plt.savefig(spath+'03_ion_drift_%s%s.pdf' % (tstrday,tstring))
return
示例2: test_qd2apex
def test_qd2apex():
A = Apex(date=2000, refh=300)
lat, lon = A.qd2apex(60, 15, 100)
assert_allclose((lat, lon),
[59.491381, 15])
assert type(lat) != np.ndarray
assert type(lon) != np.ndarray
示例3: satellite_position_lt_lat
def satellite_position_lt_lat(self, mag=False, ns='N'):
""" Show the lt and lat positions of the satellite in a polar
coordinate.
Input:
mag: if True, for MLT and Mlat position
ns: N or S for North and South hemispheres, respectively
Output:
hcup, hcdown: scatter handles for the up and down orbits,
respectively.
"""
if self.empty:
return
lt = self['LT']
lat = self['lat']
if mag:
from apexpy import Apex
gm = Apex()
mlat,mlt = gm.convert(
self['lat'], self['long'], 'geo', 'mlt', datetime=self.index)
lt, lat = mlt, mlat
ct = lat>0 if ns is 'N' else lat<0
theta = lt[ct]/12*np.pi
r = 90 - abs(lat[ct])
hc = plt.scatter(theta, r, linewidths=0)
return hc
示例4: func4
def func4():
"""
Test (lat, lt) to (mlat, mlt) conversions.
1, Use a = Apex(date=...); "date" determines which IGRF coefficients are
used in conversions. Uses current date as default.
2, height is needed for better conversion.
champ and grace files use qd coordinates.
3, mlt in qd and apex coordinates are the same.
"""
import champ_grace as cg
from apexpy import Apex as Apex
import matplotlib.pyplot as plt
a = cg.ChampDensity('2005-1-1', '2005-1-2')
b = Apex(date=2005)
mlatt, mlt = b.convert(
lat=a.lat, lon=a.long, source='geo', dest='mlt',
datetime=a.index, height=a.height)
mlat, mlongt = b.convert(
lat=a.lat, lon=a.long, source='geo', dest='qd',
height=a.height)
mlat2 = np.array(a.Mlat)
mlt2 = np.array(a.MLT)
plt.plot(mlat-mlat2)
plt.plot(abs(mlt-mlt2) % 24, '.')
plt.show()
return
示例5: test_basevectors_apex_scalar_shape
def test_basevectors_apex_scalar_shape():
A = Apex(date=2000, refh=300)
ret = A.basevectors_apex(60, 15, 100, precision=1e-2)
for r in ret[:2]:
assert r.shape == (2,)
for r in ret[2:]:
assert r.shape == (3,)
示例6: test_mlon2mlt_range
def test_mlon2mlt_range():
A = Apex(date=2000, refh=300)
assert_allclose(A.mlon2mlt(range(0, 361, 30), dt.datetime(2000, 2, 3, 4, 5, 6)),
[23.01963, 1.01963, 3.01963, 5.01963, 7.01963,
9.01963, 11.01963, 13.01963, 15.01963, 17.01963,
19.01963, 21.01963, 23.01963],
rtol=1e-4)
示例7: test_mlt2mlon_range
def test_mlt2mlon_range():
A = Apex(date=2000, refh=300)
assert_allclose(A.mlt2mlon(range(0, 25, 2), dt.datetime(2000, 2, 3, 4, 5, 6)),
[14.705551, 44.705551, 74.705551, 104.705551, 134.705551,
164.705551, 194.705551, 224.705551, 254.705551, 284.705551,
314.705551, 344.705551, 14.705551],
rtol=1e-4)
示例8: test_basevectors_apex_vectorization_height
def test_basevectors_apex_vectorization_height():
A = Apex(date=2000, refh=0)
f1, f2, f3, g1, g2, g3, d1, d2, d3, e1, e2, e3 = A.basevectors_apex(60, 15, [200, 400], coords='geo')
_, _, _, _, f1_1, f2_1, _, d1_1, d2_1, d3_1, _, e1_1, e2_1, e3_1 = A._geo2apexall(60, 15, 200)
_, _, _, _, f1_2, f2_2, _, d1_2, d2_2, d3_2, _, e1_2, e2_2, e3_2 = A._geo2apexall(60, 15, 400)
assert_allclose(f1[:, 0], f1_1)
assert_allclose(f2[:, 0], f2_1)
assert_allclose(d1[:, 0], d1_1)
assert_allclose(d2[:, 0], d2_1)
assert_allclose(d3[:, 0], d3_1)
assert_allclose(e1[:, 0], e1_1)
assert_allclose(e2[:, 0], e2_1)
assert_allclose(e3[:, 0], e3_1)
assert_allclose(f3[:, 0], np.array([-0.088671, -0.018272, 0.993576]), rtol=1e-4)
assert_allclose(g1[:, 0], np.array([0.903098, 0.245273, 0.085107]), rtol=1e-4)
assert_allclose(g2[:, 0], np.array([-0.103495, 1.072078, 0.01048]), rtol=1e-4)
assert_allclose(g3[:, 0], np.array([0, 0, 1.006465]), rtol=1e-4)
assert_allclose(f1[:, 1], f1_2)
assert_allclose(f2[:, 1], f2_2)
assert_allclose(d1[:, 1], d1_2)
assert_allclose(d2[:, 1], d2_2)
assert_allclose(d3[:, 1], d3_2)
assert_allclose(e1[:, 1], e1_2)
assert_allclose(e2[:, 1], e2_2)
assert_allclose(e3[:, 1], e3_2)
assert_allclose(f3[:, 1], np.array([-0.085415, -0.021176, 0.989645]), rtol=1e-4)
assert_allclose(g1[:, 1], np.array([0.902695, 0.246919, 0.083194]), rtol=1e-4)
assert_allclose(g2[:, 1], np.array([-0.11051, 1.066094, 0.013274]), rtol=1e-4)
assert_allclose(g3[:, 1], np.array([0, 0, 1.010463]), rtol=1e-4)
示例9: test_basevectors_apex_array
def test_basevectors_apex_array():
A = Apex(date=2000, refh=300)
f1, f2, f3, g1, g2, g3, d1, d2, d3, e1, e2, e3 = A.basevectors_apex([0, 30], 15, 100, coords='geo')
_, _, _, _, f1_1, f2_1, _, d1_1, d2_1, d3_1, _, e1_1, e2_1, e3_1 = A._geo2apexall(0, 15, 100)
_, _, _, _, f1_2, f2_2, _, d1_2, d2_2, d3_2, _, e1_2, e2_2, e3_2 = A._geo2apexall(30, 15, 100)
assert_allclose(f1[:, 0], f1_1)
assert_allclose(f2[:, 0], f2_1)
assert_allclose(d1[:, 0], d1_1)
assert_allclose(d2[:, 0], d2_1)
assert_allclose(d3[:, 0], d3_1)
assert_allclose(e1[:, 0], e1_1)
assert_allclose(e2[:, 0], e2_1)
assert_allclose(e3[:, 0], e3_1)
assert_allclose(f3[:, 0], np.array([0.092637, -0.245951, 0.938848]), rtol=1e-4)
assert_allclose(g1[:, 0], np.array([0.939012, 0.073416, -0.07342]), rtol=1e-4)
assert_allclose(g2[:, 0], np.array([0.055389, 1.004155, 0.257594]), rtol=1e-4)
assert_allclose(g3[:, 0], np.array([0, 0, 1.065135]), rtol=1e-4)
assert_allclose(f1[:, 1], f1_2)
assert_allclose(f2[:, 1], f2_2)
assert_allclose(d1[:, 1], d1_2)
assert_allclose(d2[:, 1], d2_2)
assert_allclose(d3[:, 1], d3_2)
assert_allclose(e1[:, 1], e1_2)
assert_allclose(e2[:, 1], e2_2)
assert_allclose(e3[:, 1], e3_2)
assert_allclose(f3[:, 1], np.array([-0.036618, -0.071019, 0.861604]), rtol=1e-4)
assert_allclose(g1[:, 1], np.array([0.844391, 0.015353, 0.037152]), rtol=1e-4)
assert_allclose(g2[:, 1], np.array([0.050808, 1.02131, 0.086342]), rtol=1e-4)
assert_allclose(g3[:, 1], np.array([0, 0, 1.160625]), rtol=1e-4)
示例10: test_qd2geo
def test_qd2geo():
A = Apex(date=2000, refh=300)
lat, lon, error = A.qd2geo(60, 15, 100, precision=1e-2)
assert_allclose((lat, lon, error), A._qd2geo(60, 15, 100, 1e-2))
assert type(lat) != np.ndarray
assert type(lon) != np.ndarray
assert type(error) != np.ndarray
示例11: test_apex2qd
def test_apex2qd():
A = Apex(date=2000, refh=300)
lat, lon = A.apex2qd(60, 15, 100)
assert_allclose((lat, lon),
[60.498401, 15])
assert type(lat) != np.ndarray
assert type(lon) != np.ndarray
示例12: plot_temperature
def plot_temperature():
apex = Apex(date=2003)
qlat, qlon = apex.convert(-90, 0, source='apex', dest='geo', height=400)
plt.close('all')
plt.figure(figsize=(7.26, 9.25))
g = g2a
alts = [130, 400]
for ialt, alt in enumerate(alts):
alt_ind = np.argmin(np.abs(g['Altitude'][0, 0, 2:-2]/1000-alt))+2
alt_str = '%6.2f' % (g['Altitude'][0, 0, alt_ind]/1000)
ax, projection = gcc.create_map(
1, 2, ialt+1, 'polar', nlat=nlat, slat=slat, dlat=10,
centrallon=g3ca.calculate_centrallon(g, 'polar', useLT=True),
coastlines=False)
lon0, lat0, zdata0 = g3ca.contour_data('Temperature', g, alt=alt)
fp = (lat0[:,0]>slat) & (lat0[:,0]<nlat)
lon0, lat0, zdata0 = lon0[fp, :], lat0[fp,:], zdata0[fp,:]
hc = ax.contourf(lon0, lat0, zdata0, 21,
transform=ccrs.PlateCarree(), cmap='jet',
extend='both')
hc = plt.colorbar(hc, pad=0.17)
hc.set_label('Temperature (K)')
ax.scatter(qlon, qlat, color='k', transform=ccrs.PlateCarree())
plt.title('%s km' % alt_str, y=1.05)
plt.text(0.5, 0.95, 'Time: '+titletime, fontsize=15,
horizontalalignment='center', transform=plt.gcf().transFigure)
plt.show()
return
示例13: test__geo2qd_longitude
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])
示例14: test__basevec_longitude
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])
示例15: test__qd2geo_longitude
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))