HPCA Ion Composition Overview#

author: Louis Richard
Loads HPCA survey- and burst-mode densities, bulk velocities and differential particle fluxes of H\(^+\), He\(^+\), He\(^{2+}\) and O\(^+\) with the FGM magnetic field, rotates the velocities from DBCS to GSE and averages the fluxes over angle into energy spectrograms. It plots an overview of all species in survey mode and compares the H\(^+\) survey- and burst-mode moments and spectrograms.
[1]:
%matplotlib inline
import numpy as np
import xarray as xr
import matplotlib.pyplot as plt

from pyrfu import mms
from pyrfu.plot import use_pyrfu_style, plot_line, plot_spectr, make_labels
import pyrfu

use_pyrfu_style(usetex=False)

Define spacecraft index, time interval and species#

[2]:
ic = 1
mms.db_init(default="local", local="/data/mms")
tint = ["2017-07-29T09:23:37.103846566", "2017-07-29T09:24:37.103846566"]
species = {
    "hplus": "$H^+$",
    "heplus": "$He^+$",
    "heplusplus": "$He^{2+}$",
    "oplus": "$O^+$",
}
[05-Oct-26 17:57:55] INFO: Updating MMS data access configuration in /homelocal/louisr/.config/pyrfu/mms_config.json...
[05-Oct-26 17:57:55] WARNING: No system keyring available: MMS SDC credentials saved in plain text in /homelocal/louisr/.local/share/python_keyring/keyring_pass.cfg

Load data#

Load HPCA moments#

[3]:
n_hpca = [mms.get_data(f"n{s}_hpca_srvy_l2", tint, ic) for s in species.keys()]
n_hpca_brst = [mms.get_data(f"n{s}_hpca_brst_l2", tint, ic) for s in species.keys()]
v_xyz_hpca = [mms.get_data(f"v{s}_dbcs_hpca_srvy_l2", tint, ic) for s in species.keys()]
ancillary = mms.load_ancillary(product="defatt", tint=tint, mms_id=ic, verbose=False)
v_xyz_hpca = [
    mms.dsl2gse(v_xyz_hpca[i], ancillary, direction=+1) for i in range(len(v_xyz_hpca))
]

v_xyz_hpca_brst = [
    mms.get_data(f"v{s}_dbcs_hpca_brst_l2", tint, ic) for s in species.keys()
]
v_xyz_hpca_brst = [
    mms.dsl2gse(v_xyz_hpca_brst[i], ancillary, direction=+1)
    for i in range(len(v_xyz_hpca_brst))
]
[05-Oct-26 17:57:55] INFO: Loading mms1_hpca_hplus_number_density...
[05-Oct-26 17:57:55] INFO: Loading mms1_hpca_heplus_number_density...
[05-Oct-26 17:57:55] INFO: Loading mms1_hpca_heplusplus_number_density...
[05-Oct-26 17:57:55] INFO: Loading mms1_hpca_oplus_number_density...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_hplus_number_density...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_heplus_number_density...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_heplusplus_number_density...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_oplus_number_density...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_hplus_ion_bulk_velocity...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_heplus_ion_bulk_velocity...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_heplusplus_ion_bulk_velocity...
[05-Oct-26 17:57:56] INFO: Loading mms1_hpca_oplus_ion_bulk_velocity...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_hplus_ion_bulk_velocity...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_heplus_ion_bulk_velocity...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_heplusplus_ion_bulk_velocity...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_oplus_ion_bulk_velocity...

Load HPCA differential particle fluxes#

[4]:
flux_hpca = [mms.get_data(f"dpf{s}_hpca_srvy_l2", tint, ic) for s in species.keys()]
flux_hpca_brst = [
    mms.get_data(f"dpf{s}_hpca_brst_l2", tint, ic) for s in species.keys()
]
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_hplus_flux...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_heplus_flux...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_heplusplus_flux...
[05-Oct-26 17:58:00] INFO: Loading mms1_hpca_oplus_flux...
[05-Oct-26 17:58:01] INFO: Loading mms1_hpca_hplus_flux...
[05-Oct-26 17:58:01] INFO: Loading mms1_hpca_heplus_flux...
[05-Oct-26 17:58:01] INFO: Loading mms1_hpca_heplusplus_flux...
[05-Oct-26 17:58:01] INFO: Loading mms1_hpca_oplus_flux...

Load magnetic field#

[5]:
b_xyz = mms.get_data("b_gse_fgm_srvy_l2", tint, ic)
b_xyz_brst = mms.get_data("b_gse_fgm_brst_l2", tint, ic)
[05-Oct-26 17:58:01] INFO: Loading mms1_fgm_b_gse_srvy_l2...
[05-Oct-26 17:58:01] INFO: Loading mms1_fgm_b_gse_brst_l2...

Compute ion energy spectrograms#

[6]:
def calc_hpca_flux(flux):
    flux.data[flux.data <= 0] = np.nan
    coords = [flux.time.data, flux.ccomp.data]
    dims = ["time", "energy"]

    out = xr.DataArray(
        np.nanmean(flux.data, axis=1), coords=coords, dims=dims, attrs=flux.attrs
    )
    return out


flux_hpca = [calc_hpca_flux(flux) for flux in flux_hpca]
flux_hpca_brst = [calc_hpca_flux(flux) for flux in flux_hpca_brst]
/tmp/ipykernel_503395/1029720784.py:7: RuntimeWarning: Mean of empty slice
  np.nanmean(flux.data, axis=1), coords=coords, dims=dims, attrs=flux.attrs

Plot#

[7]:
legend_options = dict(
    ncol=1, frameon=False, loc="upper left", bbox_to_anchor=(1.0, 1.0)
)
[8]:
f, axs = plt.subplots(6, sharex="all", figsize=(9, 13))
f.subplots_adjust(hspace=0, left=0.1, right=0.82, bottom=0.05, top=0.95)


plot_line(axs[0], b_xyz)
axs[0].set_ylabel("$B_{GSE}$" + "\n" + "[nT]")
axs[0].legend(["$B_{x}$", "$B_{y}$", "$B_{z}$"], **legend_options)

labels = []
for n, s in zip(n_hpca, species.keys()):
    plot_line(axs[1], n, linestyle="-", marker="o")
    labels.append(species[s])

axs[1].set_yscale("log")
axs[1].set_ylabel("$n$" + "\n" + "[cm$^{-3}$]")
axs[1].legend(labels, **legend_options)

caxs = [None] * len(species)
for s, ax, cax, flux in zip(species.keys(), axs[2:], caxs, flux_hpca):
    ax, cax = plot_spectr(ax, flux, yscale="log", cmap="viridis")
    ax.set_ylabel("$E$" + "\n" + "[eV]")
    cax.set_ylabel("flux" + "\n" + "[1/cc s sr eV]")
    ax.text(0.05, 0.1, species[s], transform=ax.transAxes)

f.align_ylabels(axs)
make_labels(axs, [0.02, 0.85])
[8]:
array([<Axes: ylabel='$B_{GSE}$\n[nT]'>,
       <Axes: ylabel='$n$\n[cm$^{-3}$]'>, <Axes: ylabel='$E$\n[eV]'>,
       <Axes: ylabel='$E$\n[eV]'>, <Axes: ylabel='$E$\n[eV]'>,
       <Axes: ylabel='$E$\n[eV]'>], dtype=object)
../../_images/examples_01_mms_example_mms_hpca_15_1.png
[9]:
fig, axs = plt.subplots(5, sharex="all", figsize=(9, 9))
fig.subplots_adjust(hspace=0, left=0.1, right=0.82, bottom=0.05, top=0.95)
fig.suptitle(f"MMS{ic}")
plot_line(axs[0], b_xyz_brst)
axs[0].set_ylabel("$B_{GSE}$" + "\n" + "[nT]")
axs[0].legend(["$B_{x}$", "$B_{y}$", "$B_{z}$"], **legend_options)

plot_line(axs[1], n_hpca[0], linestyle="-", color="black", marker="o")
plot_line(axs[1], n_hpca_brst[0], linestyle="--", color="black", marker="o")
axs[1].set_ylabel("$n$" + "\n" + "[cm$^{-3}$]")
axs[1].legend(["$H^+$ (survey)", "$H^+$ (burst)"], **legend_options)

plot_line(
    axs[2],
    v_xyz_hpca[0],
    linestyle="-",
    label=["$V_{srvy, x}$", "$V_{srvy,y}$", "$V_{srvy,z}$"],
    marker="o",
)
plot_line(
    axs[2],
    v_xyz_hpca_brst[0],
    linestyle="--",
    label=["$V_{brst,x}$", "$V_{brst,y}$", "$V_{brst,z}$"],
    marker="o",
)
axs[2].set_ylabel("$V_{GSE}$" + "\n" + "[km/s]")
axs[2].legend(**legend_options)

axs[3], caxs = plot_spectr(
    axs[3], np.log10(flux_hpca[0]), yscale="log", cmap="Spectral_r", clim=[0.7, 3.1]
)
axs[3].set_ylabel("$E$" + "\n" + "[eV]" + "\n" + "(survey)")
caxs.set_ylabel("$\log_{10}$\nDPF" + "\n" + "[1/cc s sr eV]")

axs[4], caxs = plot_spectr(
    axs[4],
    np.log10(flux_hpca_brst[0]),
    yscale="log",
    cmap="Spectral_r",
    clim=[0.7, 3.1],
)
axs[4].set_ylabel("$E$" + "\n" + "[eV]" + "\n" + "(burst)")
caxs.set_ylabel(
    "$\log_{10}$\nDPF" + "\n" + "[$\mathrm{cm^{-3}~s^{-1}~sr^{-1}~eV^{-1}}$]"
)
make_labels(axs, [0.013, 0.87], bbox=dict(facecolor="white", edgecolor="black"))
fig.savefig("hpca_hp_burst_survey.png", dpi=300, bbox_inches="tight")
<>:34: SyntaxWarning: invalid escape sequence '\l'
<>:45: SyntaxWarning: invalid escape sequence '\l'
<>:45: SyntaxWarning: invalid escape sequence '\m'
<>:34: SyntaxWarning: invalid escape sequence '\l'
<>:45: SyntaxWarning: invalid escape sequence '\l'
<>:45: SyntaxWarning: invalid escape sequence '\m'
/tmp/ipykernel_503395/165401954.py:34: SyntaxWarning: invalid escape sequence '\l'
  caxs.set_ylabel("$\log_{10}$\nDPF" + "\n" + "[1/cc s sr eV]")
/tmp/ipykernel_503395/165401954.py:45: SyntaxWarning: invalid escape sequence '\l'
  "$\log_{10}$\nDPF" + "\n" + "[$\mathrm{cm^{-3}~s^{-1}~sr^{-1}~eV^{-1}}$]"
/tmp/ipykernel_503395/165401954.py:45: SyntaxWarning: invalid escape sequence '\m'
  "$\log_{10}$\nDPF" + "\n" + "[$\mathrm{cm^{-3}~s^{-1}~sr^{-1}~eV^{-1}}$]"
../../_images/examples_01_mms_example_mms_hpca_16_1.png
[ ]:

[ ]: