Demonstration of AOBxFAC_2F
product.
Feel free to change the SPACECRAFT
, START_TIME
, and END_TIME
paramteres and re-run the notebook.
The notebook retrieves and displays data for the selected satellite and time range.
#------------------------------------------------------------------------------
# User input:
SPACECRAFT = 'A'
START_TIME='2015-05-01T00:00:00Z'
END_TIME='2015-07-31T00:00:00Z'
SERVER_URL = 'https://staging.viresdisc.vires.services/ows'
#------------------------------------------------------------------------------
from viresclient import SwarmRequest
PI_START = +1
PI_STOP = -1
SwarmRequest.COLLECTIONS.update({
'AOB_FAC': ['SW_OPER_AOB{}FAC_2F'.format(x) for x in 'ABC'],
})
SwarmRequest.PRODUCT_VARIABLES.update({
'AOB_FAC': [
'Latitude_QD', 'Longitude_QD', 'MLT_QD',
'Boundary_Flag', 'Quality', 'Pair_Indicator'
],
})
try:
request = SwarmRequest(SERVER_URL)
request.set_collection('SW_OPER_AOB%sFAC_2F' % SPACECRAFT)
request.set_products(
measurements=[
'Latitude_QD', 'Longitude_QD', 'MLT_QD', 'Boundary_Flag',
'Quality', 'Pair_Indicator',
],
auxiliaries=['QDOrbitDirection', 'OrbitNumber', 'Kp'],
)
response = request.get_between(
start_time=START_TIME,
end_time=END_TIME,
)
print('Sources:\n\t%s' % '\n\t'.join(response.sources))
boundaries = response.as_xarray()
except Exception as error:
print('ERROR: ', error)
else:
print(boundaries)
[1/2] Processing: 100%|██████████| [ Elapsed: 00:01, Remaining: 00:00 ] Downloading: 100%|██████████| [ Elapsed: 00:00, Remaining: 00:00 ] (0.485MB) [2/2] Processing: 100%|██████████| [ Elapsed: 00:01, Remaining: 00:00 ] Downloading: 100%|██████████| [ Elapsed: 00:00, Remaining: 00:00 ] (0.414MB)
Sources: SW_OPER_AOBAFAC_2F_20150101T000000_20151231T235959_0102 SW_OPER_AUXAORBCNT_20131122T000000_20200625T000000_0001 SW_OPER_AUX_KP__2__19980101T013000_20200625T043000_0001 SW_OPER_MAGA_LR_1B_20150501T000000_20150501T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150502T000000_20150502T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150503T000000_20150503T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150504T000000_20150504T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150505T000000_20150505T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150506T000000_20150506T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150507T000000_20150507T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150508T000000_20150508T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150509T000000_20150509T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150510T000000_20150510T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150511T000000_20150511T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150512T000000_20150512T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150513T000000_20150513T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150514T000000_20150514T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150515T000000_20150515T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150516T000000_20150516T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150517T000000_20150517T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150518T000000_20150518T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150519T000000_20150519T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150520T000000_20150520T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150521T000000_20150521T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150522T000000_20150522T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150523T000000_20150523T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150524T000000_20150524T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150525T000000_20150525T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150526T000000_20150526T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150527T000000_20150527T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150528T000000_20150528T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150529T000000_20150529T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150530T000000_20150530T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150531T000000_20150531T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150601T000000_20150601T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150602T000000_20150602T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150603T000000_20150603T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150604T000000_20150604T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150605T000000_20150605T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150606T000000_20150606T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150607T000000_20150607T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150608T000000_20150608T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150609T000000_20150609T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150610T000000_20150610T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150611T000000_20150611T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150612T000000_20150612T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150613T000000_20150613T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150614T000000_20150614T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150615T000000_20150615T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150616T000000_20150616T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150617T000000_20150617T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150618T000000_20150618T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150619T000000_20150619T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150620T000000_20150620T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150621T000000_20150621T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150622T000000_20150622T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150623T000000_20150623T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150624T000000_20150624T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150625T000000_20150625T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150626T000000_20150626T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150627T000000_20150627T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150628T000000_20150628T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150629T000000_20150629T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150630T000000_20150630T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150701T000000_20150701T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150702T000000_20150702T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150703T000000_20150703T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150704T000000_20150704T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150705T000000_20150705T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150706T000000_20150706T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150707T000000_20150707T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150708T000000_20150708T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150709T000000_20150709T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150710T000000_20150710T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150711T000000_20150711T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150712T000000_20150712T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150713T000000_20150713T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150714T000000_20150714T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150715T000000_20150715T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150716T000000_20150716T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150717T000000_20150717T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150718T000000_20150718T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150719T000000_20150719T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150720T000000_20150720T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150721T000000_20150721T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150722T000000_20150722T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150723T000000_20150723T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150724T000000_20150724T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150725T000000_20150725T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150726T000000_20150726T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150727T000000_20150727T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150728T000000_20150728T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150729T000000_20150729T235959_0505_MDR_MAG_LR SW_OPER_MAGA_LR_1B_20150730T000000_20150730T235959_0505_MDR_MAG_LR <xarray.Dataset> Dimensions: (Quality_dim1: 2, Timestamp: 9587) Coordinates: * Timestamp (Timestamp) datetime64[ns] 2015-05-01T00:31:06.500000 ... 2015-07-30T23:34:18.500000 Dimensions without coordinates: Quality_dim1 Data variables: Spacecraft (Timestamp) object 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' Latitude_QD (Timestamp) float64 -67.57 -70.48 -67.4 ... -69.03 -62.87 QDOrbitDirection (Timestamp) int8 -1 1 1 1 1 -1 -1 -1 ... 1 1 -1 -1 -1 -1 1 Kp (Timestamp) float64 1.3 1.3 1.3 1.3 ... 3.3 3.3 3.3 3.3 Pair_Indicator (Timestamp) int8 0 1 -1 1 -1 1 -1 1 ... 0 1 -1 1 -1 1 -1 0 OrbitNumber (Timestamp) int32 8036 8036 8036 8037 ... 9434 9434 9434 MLT_QD (Timestamp) float64 1.761 18.4 17.97 ... 19.84 20.14 7.146 Boundary_Flag (Timestamp) uint8 1 2 1 1 2 2 1 1 2 ... 2 1 1 2 2 1 1 2 1 Latitude (Timestamp) float64 -65.76 -77.0 -73.17 ... -83.53 -49.33 Longitude_QD (Timestamp) float64 88.6 -24.22 -30.89 ... 22.76 -175.2 Radius (Timestamp) float64 6.841e+06 6.841e+06 ... 6.838e+06 Quality (Timestamp, Quality_dim1) float64 1.79 0.1768 ... 0.2688 Longitude (Timestamp) float64 52.71 -147.2 -144.7 ... -34.41 115.3 Attributes: Sources: ['SW_OPER_AOBAFAC_2F_20150101T000000_20151231T235959_010... MagneticModels: [] RangeFilters: []
from numpy import stack
from matplotlib.pyplot import figure, subplot, show
%matplotlib inline
def _orbit_lat(latitude, orbit_direction):
orbit_latitude = latitude.copy()
mask = orbit_direction == -1
orbit_latitude[mask] = 180 - latitude[mask]
orbit_latitude[orbit_latitude > 180] -= 360
return orbit_latitude
def _get_pair_indices(time, pair_indicator):
idx_start = (pair_indicator == PI_START).nonzero()[0]
idx_stop = (pair_indicator == PI_STOP).nonzero()[0]
if idx_start.size > 0 and idx_stop.size > 0:
if time[idx_start[0]] > time[idx_stop[0]]:
idx_stop = idx_stop[1:]
if time[idx_start[-1]] > time[idx_stop[-1]]:
idx_start = idx_start[:-1]
assert idx_start.size == idx_start.size
return stack((idx_start, idx_stop), axis=1)
def plot_aob(ax, is_north=True):
b_time = boundaries['Timestamp'].values
b_pair_indicator = boundaries['Pair_Indicator'].values
b_lat_qd = _orbit_lat(
boundaries['Latitude_QD'].values,
boundaries['QDOrbitDirection'].values
)
idx = _get_pair_indices(b_time, b_pair_indicator)
l_ao = ax.plot(b_time[idx].transpose(), b_lat_qd[idx].transpose(), '-', c='tab:blue', ms=3)
l_aob = ax.plot(b_time, b_lat_qd, '+', c='tab:red', ms=3)
if is_north:
ylim = [45, 135]
yticks = [45, 60, 75, 90, 105, 120, 135]
ylabels = ['+45\u00B0\u2191', '+60\u00B0\u2191', '+75\u00B0\u2191', '+90\u00B0', '+75\u00B0\u2193', '+60\u00B0\u2193', '+45\u00B0\u2193']
else:
ylim = [-135, -45]
yticks = [-135, -120, -105, -90, -75, -60, -45]
ylabels = ['\u221245\u00B0\u2193', '\u221260\u00B0\u2193', '\u221275\u00B0\u2193', '\u221290\u00B0', '\u221275\u00B0\u2191', '\u221260\u00B0\u2191', '\u221245\u00B0\u2191']
ax.legend((l_ao[0], l_aob[0]), ('Auroral Oval', 'Auroral Boundary'))
ax.set_ylim(ylim)
ax.set_yticks(yticks)
ax.set_yticklabels(ylabels)
ax.grid()
ax.set_ylabel('QD-latitude')
def plot_kp(ax, is_north=True):
b_time = boundaries['Timestamp'].values
b_kp = boundaries['Kp'].values
ax.plot(b_time, b_kp)
ax.grid()
ax.set_yticks(range(0, 10))
ax.set_ylim([-0.5, 9.5])
ax.set_ylabel('Kp index')
fig = figure(figsize=(18, 12), dpi=100)
plot_aob(subplot(311), is_north=True)
plot_aob(subplot(312), is_north=False)
plot_kp(subplot(313))
/opt/conda/lib/python3.7/site-packages/pandas/plotting/_matplotlib/converter.py:103: FutureWarning: Using an implicitly registered datetime converter for a matplotlib plotting method. The converter was registered by pandas on import. Future versions of pandas will require you to explicitly register matplotlib converters. To register the converters: >>> from pandas.plotting import register_matplotlib_converters >>> register_matplotlib_converters() warnings.warn(msg, FutureWarning)