EEFxTMS_2F (Equatorial electric field)#
Abstract: Access to the equatorial electric field (level 2 product).
%load_ext watermark
%watermark -i -v -p viresclient,pandas,xarray,matplotlib
Python implementation: CPython
Python version : 3.11.6
IPython version : 8.18.0
viresclient: 0.12.0
pandas : 2.1.3
xarray : 2023.12.0
matplotlib : 3.8.2
from viresclient import SwarmRequest
import datetime as dt
import numpy as np
import matplotlib.pyplot as plt
request = SwarmRequest()
EEFxTMS_2F product information#
Dayside equatorial electric field, sampled at every dayside equator crossing +- 20mins
Documentation:
Check what “EEF” data variables are available#
request.available_collections("EEF", details=False)
{'EEF': ['SW_OPER_EEFATMS_2F', 'SW_OPER_EEFBTMS_2F', 'SW_OPER_EEFCTMS_2F']}
request.available_measurements("EEF")
['EEF', 'EEJ', 'RelErr', 'Flags']
Fetch all the EEF and EEJ values from Bravo during 2016#
request.set_collection("SW_OPER_EEFBTMS_2F")
request.set_products(measurements=["EEF", "EEJ", "Flags"])
data = request.get_between(
dt.datetime(2016,1,1),
dt.datetime(2017,1,1)
)
# The first three and last three source (daily) files
data.sources[:3], data.sources[-3:]
(['SW_OPER_EEFBTMS_2F_20160101T000000_20160101T235959_0304',
'SW_OPER_EEFBTMS_2F_20160102T000000_20160102T235959_0304',
'SW_OPER_EEFBTMS_2F_20160103T000000_20160103T235959_0304'],
['SW_OPER_EEFBTMS_2F_20161229T000000_20161229T235959_0304',
'SW_OPER_EEFBTMS_2F_20161230T000000_20161230T235959_0304',
'SW_OPER_EEFBTMS_2F_20161231T000000_20161231T235959_0304'])
df = data.as_dataframe()
df.head()
Latitude | EEJ | Spacecraft | Flags | Longitude | EEF | |
---|---|---|---|---|---|---|
Timestamp | ||||||
2016-01-01 00:54:18.582250240 | 7.236889 | [-7.005610363703717, -10.211465121967585, -1.5... | B | 0 | 113.752507 | -1.004339 |
2016-01-01 02:29:05.999242240 | 7.519415 | [7.746360569364575, 7.386407881793424, 5.05754... | B | 0 | 89.978253 | -5.887205 |
2016-01-01 04:03:53.439624960 | 6.901753 | [0.21446887300338907, 11.120236418391087, 10.6... | B | 0 | 66.180580 | -0.402845 |
2016-01-01 05:38:40.856788992 | 7.373078 | [1.4905267368810213, 5.204181317094439, 4.5540... | B | 0 | 42.411229 | -0.183917 |
2016-01-01 07:13:28.198109440 | 10.032836 | [-3.8812386149195732, -1.4826382807601335, 1.2... | B | 0 | 18.698123 | -0.338922 |
ax = df.plot(y="EEF", figsize=(20,10))
ax.set_ylim((-2, 2));
ax.set_ylabel("EEF [mV/m]");
Take a look at the time jumps between entries… Nominally the product should produce one measurement “every dayside equator crossing ±20 minutes”
times = df.index
delta_t_minutes = [t.seconds/60 for t in np.diff(times.to_pydatetime())]
print("Range of time gaps (in minutes) between successive measurements:")
np.unique(np.sort(delta_t_minutes))
Range of time gaps (in minutes) between successive measurements:
array([ 47.3 , 47.46666667, 94.73333333, 94.75 ,
94.76666667, 94.78333333, 142.2 , 189.48333333,
189.5 , 189.51666667, 189.53333333, 189.55 ,
189.56666667, 852.86666667])
Access the EEJ estimate via xarray instead of pandas#
Since the EEJ estimate has both time and latitude dimensions, it is not suited to pandas. Here we load the data as a xarray.Dataset
which better handles n-dimensional data.
ds = data.as_xarray()
ds
<xarray.Dataset> Dimensions: (Timestamp: 5468, EEJ_QDLat: 81) Coordinates: * Timestamp (Timestamp) datetime64[ns] 2016-01-01T00:54:18.582250240 ... ... * EEJ_QDLat (EEJ_QDLat) float64 -20.0 -19.5 -19.0 -18.5 ... 19.0 19.5 20.0 Data variables: Spacecraft (Timestamp) object 'B' 'B' 'B' 'B' 'B' ... 'B' 'B' 'B' 'B' 'B' Latitude (Timestamp) float64 7.237 7.519 6.902 ... -7.72 -4.03 -0.77 Longitude (Timestamp) float64 113.8 89.98 66.18 ... -105.3 -129.1 -153.0 EEJ (Timestamp, EEJ_QDLat) float64 -7.006 -10.21 ... -5.477 -6.955 Flags (Timestamp) uint16 0 0 0 0 0 0 0 0 0 0 0 ... 0 0 0 0 0 0 0 0 0 0 EEF (Timestamp) float64 -1.004 -5.887 -0.4028 ... 0.4715 0.558 Attributes: Sources: ['SW_OPER_EEFBTMS_2F_20160101T000000_20160101T235959_030... MagneticModels: [] AppliedFilters: []
Let’s select a subset (one month) and visualise it:
_ds = ds.sel({"Timestamp": "2016-01"})
fig, ax1 = plt.subplots(nrows=1, figsize=(15,3), sharex=True)
_ds.plot.scatter(x="Timestamp", y="EEJ_QDLat", hue="EEJ", vmax=10, s=1, linewidths=0, ax=ax1)
<matplotlib.collections.PathCollection at 0x7f959ec9ac10>