EFIxTCT (Cross-track ion flow)#
Abstract: Access to the 2Hz & 16Hz cross-track ion flow data derived from the Thermal Ion Imager (TII), part of the Electric Field Instrument package (EFI).
For more information about this product, see the release notes.
SERVER_URL = 'https://vires.services/ows'
# Display important package versions used
%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.3
pandas : 2.1.3
xarray : 2023.12.0
matplotlib : 3.8.2
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import xarray as xr
# Control the HTML display of the datasets
xr.set_options(display_expand_attrs=False, display_expand_coords=True, display_expand_data=True)
from viresclient import SwarmRequest
request = SwarmRequest(SERVER_URL)
What data is available?#
There are two sets of collections available, one for 2Hz and one for 16Hz, and for each there are three collections, one for each Swarm spacecraft.
request.available_collections("EFI_TCT02", details=False)
{'EFI_TCT02': ['SW_EXPT_EFIA_TCT02',
'SW_EXPT_EFIB_TCT02',
'SW_EXPT_EFIC_TCT02']}
request.available_collections("EFI_TCT16", details=False)
{'EFI_TCT16': ['SW_EXPT_EFIA_TCT16',
'SW_EXPT_EFIB_TCT16',
'SW_EXPT_EFIC_TCT16']}
print(request.available_measurements("EFI_TCT02"))
['VsatC', 'VsatE', 'VsatN', 'Bx', 'By', 'Bz', 'Ehx', 'Ehy', 'Ehz', 'Evx', 'Evy', 'Evz', 'Vicrx', 'Vicry', 'Vicrz', 'Vixv', 'Vixh', 'Viy', 'Viz', 'Vixv_error', 'Vixh_error', 'Viy_error', 'Viz_error', 'Latitude_QD', 'MLT_QD', 'Calibration_flags', 'Quality_flags']
print(request.available_measurements("EFI_TCT16"))
['VsatC', 'VsatE', 'VsatN', 'Bx', 'By', 'Bz', 'Ehx', 'Ehy', 'Ehz', 'Evx', 'Evy', 'Evz', 'Vicrx', 'Vicry', 'Vicrz', 'Vixv', 'Vixh', 'Viy', 'Viz', 'Vixv_error', 'Vixh_error', 'Viy_error', 'Viz_error', 'Latitude_QD', 'MLT_QD', 'Calibration_flags', 'Quality_flags']
As seen above, the variables available for both the 2Hz and 16Hz datasets are the same. Here is a short description for each variable:
tct_vars = [
# Satellite velocity in NEC frame
"VsatC", "VsatE", "VsatN",
# Geomagnetic field components derived from 1Hz product
# (in satellite-track coordinates)
"Bx", "By", "Bz",
# Electric field components derived from -VxB with along-track ion drift
# (in satellite-track coordinates)
# Eh: derived from horizontal sensor
# Ev: derived from vertical sensor
"Ehx", "Ehy", "Ehz",
"Evx", "Evy", "Evz",
# Ion drift corotation signal, removed from ion drift & electric field
# (in satellite-track coordinates)
"Vicrx", "Vicry", "Vicrz",
# Ion drifts along-track from vertical (..v) and horizontal (..h) TII sensor
"Vixv", "Vixh",
# Ion drifts cross-track (y from horizontal sensor, z from vertical sensor)
# (in satellite-track coordinates)
"Viy", "Viz",
# Random error estimates for the above
# (Negative value indicates no estimate available)
"Vixv_error", "Vixh_error", "Viy_error", "Viz_error",
# Quasi-dipole magnetic latitude and local time
# redundant with VirES auxiliaries, QDLat & MLT
"Latitude_QD", "MLT_QD",
# Refer to release notes link above for details:
"Calibration_flags", "Quality_flags",
]
Fetching and plotting data#
For demonstration, we will fetch the 2Hz data from Swarm Alpha (SW_EXPT_EFIA_TCT02
)
start = "2018-07-17T11:00:00"
end = "2018-07-17T16:00:00"
request = SwarmRequest(SERVER_URL)
request.set_collection("SW_EXPT_EFIA_TCT02")
request.set_products(measurements=tct_vars)
data = request.get_between(start, end)
Data can be loaded as either a pandas datframe or a xarray dataset.
df = data.as_dataframe()
df.head()
Ehz | VsatC | Vixh_error | Vixh | Latitude_QD | Vixv_error | Vicrx | Viz | Evy | Ehy | ... | By | Bx | Bz | Calibration_flags | Viz_error | Evz | Viy | Vixv | Ehx | VsatN | |
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Timestamp | |||||||||||||||||||||
2018-07-17 11:28:49.225250048 | -35.943443 | 5.364018 | -14.849242 | -14747.417969 | 75.208305 | -14.849242 | -19.133307 | -268.333466 | -866.204529 | -705.941589 | ... | -2032.778809 | -1941.897339 | 47833.539062 | 50529027 | -14.849242 | -42.754105 | 3072.314697 | -18097.832031 | -146.413574 | -7367.462402 |
2018-07-17 11:28:49.725250048 | -34.868401 | 5.379858 | -14.849242 | -14475.270508 | 75.179535 | -14.849242 | -19.120062 | -455.484985 | -848.451111 | -693.349854 | ... | -2032.832520 | -1947.693359 | 47837.632812 | 50529027 | -14.849242 | -41.459320 | 2794.406982 | -17717.505859 | -132.751846 | -7369.250000 |
2018-07-17 11:28:50.225250048 | -34.975639 | 5.395653 | -14.849242 | -14559.314453 | 75.150764 | -14.849242 | -19.106810 | -273.931030 | -868.396301 | -697.077820 | ... | -2033.323975 | -1954.192383 | 47841.683594 | 50529027 | -14.849242 | -42.256802 | 2748.852295 | -18140.265625 | -130.952698 | -7371.019043 |
2018-07-17 11:28:50.725250048 | -34.792419 | 5.411411 | -14.849242 | -14442.468750 | 75.121979 | -14.849242 | -19.093546 | -566.669189 | -868.061523 | -692.121216 | ... | -2034.150879 | -1961.238281 | 47845.691406 | 50529027 | -14.849242 | -42.272465 | 2760.554688 | -18119.716797 | -130.928070 | -7372.773438 |
2018-07-17 11:28:51.225250048 | -34.930099 | 5.427133 | -14.849242 | -14607.324219 | 75.093193 | -14.849242 | -19.080286 | -533.720764 | -864.288635 | -700.008362 | ... | -2032.240967 | -1969.732666 | 47849.765625 | 50529027 | -14.849242 | -41.907967 | 2662.979004 | -18040.589844 | -126.337891 | -7374.509277 |
5 rows × 31 columns
ds = data.as_xarray()
ds
<xarray.Dataset> Dimensions: (Timestamp: 32535) Coordinates: * Timestamp (Timestamp) datetime64[ns] 2018-07-17T11:28:49.2252500... Data variables: (12/31) Spacecraft (Timestamp) object 'A' 'A' 'A' 'A' ... 'A' 'A' 'A' 'A' Ehz (Timestamp) float32 -35.94 -34.87 -34.98 ... 50.68 49.6 VsatC (Timestamp) float32 5.364 5.38 5.396 ... -11.04 -11.03 Vixh (Timestamp) float32 -1.475e+04 -1.448e+04 ... -1.474e+04 Vicrx (Timestamp) float32 -19.13 -19.12 ... -24.47 -24.46 Viz (Timestamp) float32 -268.3 -455.5 ... -1.527e+03 ... ... Bx (Timestamp) float32 -1.942e+03 -1.948e+03 ... 9.496e+03 Bz (Timestamp) float32 4.783e+04 4.784e+04 ... 4.539e+04 Calibration_flags (Timestamp) uint32 50529027 50529027 ... 50529027 Viy (Timestamp) float32 3.072e+03 2.794e+03 ... 1.919e+03 Vixv (Timestamp) float32 -1.81e+04 -1.772e+04 ... -1.609e+04 Latitude (Timestamp) float32 80.1 80.07 80.04 ... 64.75 64.78 Attributes: (3)
An example plot:
fig, axes = plt.subplots(nrows=4, sharex=True, figsize=(10, 7))
# Plot velocities with left axis
ds.plot.scatter(x="Timestamp", y="Vixv", ax=axes[0], s=1, linewidths=0)
ds.plot.scatter(x="Timestamp", y="Vixh", ax=axes[1], s=1, linewidths=0)
ds.plot.scatter(x="Timestamp", y="Viy", ax=axes[2], s=1, linewidths=0)
ds.plot.scatter(x="Timestamp", y="Viz", ax=axes[3], s=1, linewidths=0, label="Velocities")
# Plot velocities with right axis
axes_r = [ax.twinx() for ax in axes]
ds.plot.scatter(x="Timestamp", y="Vixv_error", ax=axes_r[0], s=0.1, color="tab:orange")
ds.plot.scatter(x="Timestamp", y="Vixh_error", ax=axes_r[1], s=0.1, color="tab:orange")
ds.plot.scatter(x="Timestamp", y="Viy_error", ax=axes_r[2], s=0.1, color="tab:orange")
ds.plot.scatter(x="Timestamp", y="Viz_error", ax=axes_r[3], s=0.1, color="tab:orange")
fig.subplots_adjust(hspace=0)
# Add legend to identify each side
blue = mpl.patches.Patch(color="tab:blue", label="Velocities")
orange = mpl.patches.Patch(color="tab:orange", label="Errors")
axes[0].legend(handles=[blue, orange])
# # Generate additional ticklabels for x-axis
# Use time xticks to get dataset vars at those xticks
locx = axes[-1].get_xticks()
times = mpl.dates.num2date(locx)
times = [t.replace(tzinfo=None) for t in times]
_ds_xticks = ds.reindex({"Timestamp": times}, method="nearest")
# Build ticklabels from dataset vars
xticklabels = np.stack([
_ds_xticks["Timestamp"].dt.strftime("%H:%M").values,
np.round(_ds_xticks["Latitude"].values, 2).astype(str),
np.round(_ds_xticks["Longitude"].values, 2).astype(str),
])
xticklabels = ["\n".join(row) for row in xticklabels.T]
# Add labels to first xtick
_xt0 = xticklabels[0].split("\n")
xticklabels[0] = f"Time: {_xt0[0]}\nLat: {_xt0[1]}\nLon: {_xt0[2]}"
axes[-1].set_xticks(axes[-1].get_xticks())
axes[-1].set_xticklabels(xticklabels)
axes[-1].set_xlabel("")
# Adjust title
title = "".join([
f"Swarm {ds['Spacecraft'].data[0]} 2Hz ion flow, ",
ds["Timestamp"].dt.date.data[0].isoformat(),
f"\n{ds.attrs['Sources']}"
])
fig.suptitle(title);

Due to contamination in the instrument, great care must be taken to use these data correctly. Check the release notes and make use of the Quality_flags
variable to identify valid data periods.
TODO: use section 3.4.1.1 to identify untrusty periods (bitx = 0) and shade them grey?