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.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()

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',
  'SW_FAST_MAGA_HR_1B',
  'SW_FAST_MAGB_HR_1B',
  'SW_FAST_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_0602_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'
    Radius      (Timestamp) float64 6.837e+06 6.837e+06 ... 6.836e+06 6.836e+06
    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
    B_NEC       (Timestamp, NEC) float64 9.677e+03 -3.496e+03 ... -1.817e+04
Attributes:
    Sources:         ['SW_OPER_MAGA_HR_1B_20150621T000000_20150621T235959_060...
    MagneticModels:  []
    AppliedFilters:  []

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/d2ed9dcd69d4fcf1084161ea919fae03478f15dc37cc5a2af083557b2842f23e.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/5973da3a01b835c66ece8f64e38357c37d53e4ac569964b79f67456b2ce2b263.png