Demo EFIx_LP_1B (langmuir probe 2Hz)

Authors: Ashley Smith

Abstract: Access to the electric field instrument langmuir probe data (2Hz) (level 1b product).

%load_ext watermark
%watermark -i -v -p viresclient,pandas,xarray,matplotlib
2021-01-24T15:45:39+00:00

CPython 3.7.6
IPython 7.11.1

viresclient 0.7.1
pandas 0.25.3
xarray 0.15.0
matplotlib 3.1.2
from viresclient import SwarmRequest
import datetime as dt
import matplotlib.pyplot as plt

request = SwarmRequest()

EFIx_LP_1B product information

Measurements from the Langmuir Probe (LP) of the Electric Field Instrument (EFI) at 2Hz, for each Swarm spacecraft.

Documentation:

  • https://earth.esa.int/web/guest/missions/esa-eo-missions/swarm/data-handbook/level-1b-product-definitions#EFIX_LP_1B_Product

Check what “EFI” data variables are available

request.available_collections("EFI", details=False)
{'EFI': ['SW_OPER_EFIA_LP_1B', 'SW_OPER_EFIB_LP_1B', 'SW_OPER_EFIC_LP_1B']}
request.available_measurements("EFI")
['U_orbit',
 'Ne',
 'Ne_error',
 'Te',
 'Te_error',
 'Vs',
 'Vs_error',
 'Flags_LP',
 'Flags_Ne',
 'Flags_Te',
 'Flags_Vs']

Fetch one day of EFI data

request.set_collection("SW_OPER_EFIA_LP_1B")
request.set_products(
    measurements=['U_orbit',
                 'Ne',
                 'Ne_error',
                 'Te',
                 'Te_error',
                 'Vs',
                 'Vs_error',
                 'Flags_LP',
                 'Flags_Ne',
                 'Flags_Te',
                 'Flags_Vs']
)
data = request.get_between(
    dt.datetime(2016,1,1),
    dt.datetime(2016,1,2)
)
[1/1] Processing:  100%|██████████|  [ Elapsed: 00:01, Remaining: 00:00 ]
      Downloading: 100%|██████████|  [ Elapsed: 00:00, Remaining: 00:00 ] (16.076MB)
data.sources
['SW_OPER_EFIA_LP_1B_20160101T000000_20160101T235959_0501_MDR_EFI_LP']

Load and plot using pandas/matplotlib

df = data.as_dataframe()
df.head()
Radius Longitude Flags_Ne Ne Flags_LP Te_error Vs Latitude U_orbit Flags_Te Spacecraft Vs_error Ne_error Te Flags_Vs
Timestamp
2016-01-01 00:00:00.197000027 6833852.72 92.799630 20 126188.4 1 9.999990e+09 -2.201 -72.511716 7604.407 20 A 9.999990e+09 9.999990e+09 2945.20 20
2016-01-01 00:00:00.696000099 6833853.09 92.813944 20 127792.9 1 9.999990e+09 -2.193 -72.543238 7604.398 20 A 9.999990e+09 9.999990e+09 2891.97 20
2016-01-01 00:00:01.197000027 6833853.91 92.828370 20 132515.3 1 9.999990e+09 -2.200 -72.574886 7604.389 20 A 9.999990e+09 9.999990e+09 2921.96 20
2016-01-01 00:00:01.696000099 6833854.27 92.842799 20 137933.0 1 9.999990e+09 -2.194 -72.606406 7604.380 20 A 9.999990e+09 9.999990e+09 2936.74 20
2016-01-01 00:00:02.197000027 6833855.09 92.857342 20 138913.8 1 9.999990e+09 -2.190 -72.638051 7604.371 20 A 9.999990e+09 9.999990e+09 2870.09 20
df.plot(y=["Ne", "Te", "Vs"], subplots=True, figsize=(20,5));
../_images/03b__Demo-EFIx_LP_1B_12_0.png
df.plot(x="Latitude", y="Ne");
../_images/03b__Demo-EFIx_LP_1B_13_0.png

Load as xarray

ds = data.as_xarray()
ds
<xarray.Dataset>
Dimensions:     (Timestamp: 172776)
Coordinates:
  * Timestamp   (Timestamp) datetime64[ns] 2016-01-01T00:00:00.197000027 ... 2016-01-01T23:59:59.696000099
Data variables:
    Spacecraft  (Timestamp) object 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' 'A'
    Radius      (Timestamp) float64 6.834e+06 6.834e+06 ... 6.823e+06 6.823e+06
    Longitude   (Timestamp) float64 92.8 92.81 92.83 ... -95.37 -95.37 -95.37
    Te          (Timestamp) float64 2.945e+03 2.892e+03 ... 2.527e+03 2.545e+03
    Flags_Ne    (Timestamp) uint8 20 20 20 20 20 20 20 ... 20 20 20 20 20 20 20
    Ne          (Timestamp) float64 1.262e+05 1.278e+05 ... 6.485e+04 6.43e+04
    Flags_LP    (Timestamp) uint8 1 1 1 1 1 1 1 1 1 1 1 ... 1 1 1 1 1 1 1 1 1 1
    Te_error    (Timestamp) float64 1e+10 1e+10 1e+10 ... 1e+10 1e+10 1e+10
    Vs          (Timestamp) float64 -2.201 -2.193 -2.2 ... -2.244 -2.239 -2.243
    Latitude    (Timestamp) float64 -72.51 -72.54 -72.57 ... 31.65 31.69 31.72
    U_orbit     (Timestamp) float64 7.604e+03 7.604e+03 ... 7.634e+03 7.634e+03
    Flags_Te    (Timestamp) uint8 20 20 20 20 20 20 20 ... 20 20 20 20 20 20 20
    Vs_error    (Timestamp) float64 1e+10 1e+10 1e+10 ... 1e+10 1e+10 1e+10
    Ne_error    (Timestamp) float64 1e+10 1e+10 1e+10 ... 1e+10 1e+10 1e+10
    Flags_Vs    (Timestamp) uint8 20 20 20 20 20 20 20 ... 20 20 20 20 20 20 20
Attributes:
    Sources:         ['SW_OPER_EFIA_LP_1B_20160101T000000_20160101T235959_050...
    MagneticModels:  []
    RangeFilters:    []
fig, (ax1, ax2) = plt.subplots(figsize=(10, 5), nrows=2, sharex=True)
def subplot(_ax, da):
    """Plot a given DataArray on a given axes"""
    _ax.plot(da)
    _ax.set_ylabel(f"{da.name} [{da.units}]")
for var, ax in zip(("Ne", "Te"), (ax1, ax2)):
    subplot(ax, ds[var])
../_images/03b__Demo-EFIx_LP_1B_16_0.png