MAGxHR_1B (Magnetic field 50Hz)

Abstract: Access to the high rate (50Hz) magnetic data (level 1b 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 matplotlib.pyplot as plt
request = SwarmRequest()

Product information

The 50Hz measurements of the magnetic field vector (B_NEC) and total intensity (F).

Documentation:

Measurements are available through VirES as part of collections with names containing MAGx_HR, for each Swarm spacecraft:

request.available_collections("MAG_HR", details=False)
{'MAG_HR': ['SW_OPER_MAGA_HR_1B', 'SW_OPER_MAGB_HR_1B', 'SW_OPER_MAGC_HR_1B']}

The measurements can be used together with geomagnetic model evaluations as shall be shown below.

Check what “MAG_HR” data variables are available

request.available_measurements("MAG_HR")
['F',
 'B_VFM',
 'B_NEC',
 'dB_Sun',
 'dB_AOCS',
 'dB_other',
 'B_error',
 'q_NEC_CRF',
 'Att_error',
 'Flags_B',
 'Flags_q',
 'Flags_Platform']

Fetch and load data

request = SwarmRequest()
request.set_collection("SW_OPER_MAGA_HR_1B")
request.set_products(
   measurements=["B_NEC"],
)
data = request.get_between(
   start_time="2015-06-21T12:00:00Z", 
   end_time="2015-06-21T12:01:00Z",
   asynchronous=False
)
data.sources
['SW_OPER_MAGA_HR_1B_20150621T000000_20150621T235959_0505_MDR_MAG_HR']
ds = data.as_xarray()
ds
<xarray.Dataset>
Dimensions:     (Timestamp: 3000, NEC: 3)
Coordinates:
  * Timestamp   (Timestamp) datetime64[ns] 2015-06-21T12:00:00.007250176 ... ...
  * NEC         (NEC) <U1 'N' 'E' 'C'
Data variables:
    Spacecraft  (Timestamp) object 'A' 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' 'A'
    Latitude    (Timestamp) float64 -41.84 -41.83 -41.83 ... -38.01 -38.01
    Longitude   (Timestamp) float64 -17.17 -17.17 -17.17 ... -17.12 -17.12
    Radius      (Timestamp) float64 6.837e+06 6.837e+06 ... 6.836e+06 6.836e+06
    B_NEC       (Timestamp, NEC) float64 9.677e+03 -3.495e+03 ... -1.817e+04
Attributes:
    Sources:         ['SW_OPER_MAGA_HR_1B_20150621T000000_20150621T235959_050...
    MagneticModels:  []
    RangeFilters:    []

Visualisation of data

fig, axes = plt.subplots(figsize=(20, 3), ncols=3, sharex=True)
for i in range(3):
    axes[i].plot(ds["Timestamp"], ds["B_NEC"][:, i])
    axes[i].set_ylabel("NEC"[i])
    axes[i].set_xlabel("Time")
fig.suptitle("B_NEC components [nT]");
../_images/03a2_Demo-MAGx_HR_1B_14_0.png
fig, ax = plt.subplots(figsize=(20, 3))
dBdt = np.diff(ds["B_NEC"], axis=0) * (1/50)
ax.plot(ds["Timestamp"][1:], dBdt[:, 2])
ax.set_ylabel("nT / s")
ax.set_xlabel("Time")
ax.set_title("Vertical component (C) first differences");
../_images/03a2_Demo-MAGx_HR_1B_15_0.png