TECxTMS_2F (Total electron content)

Abstract: Access to the total electric contents (level 2 product).

%load_ext watermark
%watermark -i -v -p viresclient,pandas,xarray,matplotlib
Python implementation: CPython
Python version       : 3.9.7
IPython version      : 8.3.0

viresclient: 0.10.3
pandas     : 1.4.1
xarray     : 0.21.1
matplotlib : 3.5.1
from viresclient import SwarmRequest
import datetime as dt
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt

request = SwarmRequest()

TECxTMS_2F product information

Derived total electron content (TEC)

Documentation:

Check what “TEC” data variables are available

request.available_collections("IPD", details=False)
{'IPD': ['SW_OPER_IPDAIRR_2F', 'SW_OPER_IPDBIRR_2F', 'SW_OPER_IPDCIRR_2F']}
request.available_measurements("TEC")
['GPS_Position',
 'LEO_Position',
 'PRN',
 'L1',
 'L2',
 'P1',
 'P2',
 'S1',
 'S2',
 'Elevation_Angle',
 'Absolute_VTEC',
 'Absolute_STEC',
 'Relative_STEC',
 'Relative_STEC_RMS',
 'DCB',
 'DCB_Error']

Fetch one day of TEC data

request.set_collection("SW_OPER_TECATMS_2F")
request.set_products(measurements=request.available_measurements("TEC"))
data = request.get_between(dt.datetime(2014,1,1),
                           dt.datetime(2014,1,2))

Loading as pandas

df = data.as_dataframe()
df.head()
GPS_Position L2 Latitude P1 S1 LEO_Position PRN Elevation_Angle Relative_STEC Radius P2 Relative_STEC_RMS DCB_Error S2 Absolute_STEC DCB Longitude Absolute_VTEC L1 Spacecraft
Timestamp
2014-01-01 00:00:04 [22448765.690377887, 5421379.431197803, -13409... -6.261989e+06 -1.482419 2.182913e+07 36.83 [6668214.544000001, -1677732.674, -177943.9959... 15 39.683333 24.041127 6.878338e+06 2.182914e+07 0.555675 0.832346 36.83 16.429938 -11.446853 -14.122572 10.894886 -6.261986e+06 A
2014-01-01 00:00:04 [16113499.491062254, -16306172.004347403, -126... -1.466568e+07 -1.482419 2.135749e+07 34.75 [6668214.544000001, -1677732.674, -177943.9959... 18 37.478137 22.754795 6.878338e+06 2.135749e+07 0.488000 0.832346 34.75 16.456409 -11.446853 -14.122572 10.461554 -1.466568e+07 A
2014-01-01 00:00:04 [10823457.339250825, -24014739.352816023, -248... -5.455454e+06 -1.482419 2.277638e+07 30.90 [6668214.544000001, -1677732.674, -177943.9959... 22 24.681787 15.585271 6.878338e+06 2.277638e+07 1.313984 0.832346 30.90 20.434286 -11.446853 -14.122572 9.529846 -5.455452e+06 A
2014-01-01 00:00:04 [20631539.59055339, 13441368.439225309, 100505... -3.402821e+06 -1.482419 2.298846e+07 29.87 [6668214.544000001, -1677732.674, -177943.9959... 24 24.647445 52.291341 6.878338e+06 2.298847e+07 0.899036 0.832346 29.87 20.085094 -11.446853 -14.122572 9.357587 -3.402816e+06 A
2014-01-01 00:00:04 [16637723.905075422, -10692759.977004562, 1761... -2.285986e+06 -1.482419 2.229899e+07 30.88 [6668214.544000001, -1677732.674, -177943.9959... 25 30.753636 52.672067 6.878338e+06 2.229900e+07 0.546729 0.832346 30.88 15.676947 -11.446853 -14.122572 8.597559 -2.285981e+06 A

NB: The time interval is not always the same:

times = df.index
np.unique(np.sort(np.diff(times.to_pydatetime())))
array([datetime.timedelta(0), datetime.timedelta(seconds=10)],
      dtype=object)
len(df), 60*60*24
(49738, 86400)

Loading and plotting as xarray

ds = data.as_xarray()
ds
<xarray.Dataset>
Dimensions:            (Timestamp: 49738, WGS84: 3)
Coordinates:
  * Timestamp          (Timestamp) datetime64[ns] 2014-01-01T00:00:04 ... 201...
  * WGS84              (WGS84) <U1 'X' 'Y' 'Z'
Data variables: (12/20)
    Spacecraft         (Timestamp) object 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A'
    GPS_Position       (Timestamp, WGS84) float64 2.245e+07 ... -2.111e+07
    L2                 (Timestamp) float64 -6.262e+06 -1.467e+07 ... -3.41e+06
    Latitude           (Timestamp) float64 -1.482 -1.482 -1.482 ... -81.7 -81.7
    P1                 (Timestamp) float64 2.183e+07 2.136e+07 ... 2.171e+07
    S1                 (Timestamp) float64 36.83 34.75 30.9 ... 23.03 37.73 37.5
    ...                 ...
    S2                 (Timestamp) float64 36.83 34.75 30.9 ... 23.03 37.73 37.5
    Absolute_STEC      (Timestamp) float64 16.43 16.46 20.43 ... 10.77 10.78
    DCB                (Timestamp) float64 -11.45 -11.45 ... -11.45 -11.45
    Longitude          (Timestamp) float64 -14.12 -14.12 -14.12 ... 1.559 1.559
    Absolute_VTEC      (Timestamp) float64 10.89 10.46 9.53 ... 8.365 7.912
    L1                 (Timestamp) float64 -6.262e+06 -1.467e+07 ... -3.41e+06
Attributes:
    Sources:         ['SW_OPER_TECATMS_2F_20140101T000000_20140101T235959_0301']
    MagneticModels:  []
    RangeFilters:    []
fig, axes = plt.subplots(nrows=2, ncols=1, figsize=(15,5), sharex=True)
ds["Absolute_VTEC"].plot.line(x="Timestamp", ax=axes[0])
ds["Absolute_STEC"].plot.line(x="Timestamp", ax=axes[1]);
fig.subplots_adjust(hspace=0)
../_images/03d__Demo-TECxTMS_2F_16_0.png