Ion Distribution From MMS
This notebook shows how to create 2D slices of 3D particle data from FPI using PySPEDAS. pyspedas
is the Python implementation of SPEDAS orginally coded in IDL. It is not as feature-complete as the IDL version.
Obtaining MMS FPI Data
Here is a recorded bi-directional field-aligned beam of 0-300 eV ions observed by FPI. Due to a bug in the time
argument of mms_part_slice2d
, we currently need to specify the start and end time of the interval as a list.
from pytplot import time_double, time_string
time = "2017-09-10/09:32:20"
window = 4.
trange = [time_double(time)-window/2, time_double(time)+window/2]
time_string(trange)
['2017-09-10 09:32:18.000000', '2017-09-10 09:32:22.000000']
The data is downloaded automatically to the pydata
folder under the current directory if not found.
from pyspedas.mms.particles.mms_part_slice2d import mms_part_slice2d
mms_part_slice2d(
time=time,
instrument="fpi",
species="i",
rotation="bv",
erange=[0, 300],
cmap="turbo",
)
31-Dec-24 02:46:52: Error while reading SDC username/password; defaulting to public user...
31-Dec-24 02:46:53: Downloading mms1_fpi_fast_l2_dis-dist_20170910080000_v3.4.0.cdf to pydata/mms1/fpi/fast/l2/dis-dist/2017/09
31-Dec-24 02:46:55: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:46:55: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:46:55: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:46:55: Downloading mms1_fgm_srvy_l2_20170910_v5.104.0.cdf to pydata/mms1/fgm/srvy/l2/2017/09
31-Dec-24 02:47:01: Downloading mms1_fpi_fast_l2_dis-moms_20170910080000_v3.4.0.cdf to pydata/mms1/fpi/fast/l2/dis-moms/2017/09
31-Dec-24 02:47:02: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:02: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:02: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:02: Averaging mms1_fgm_b_gse_srvy_l2_bvec
31-Dec-24 02:47:02: Averaging mms1_dis_bulkv_gse_fast
31-Dec-24 02:47:02: Aligning slice plane to: bv
31-Dec-24 02:47:03: Finished slice at 2017-09-10 09:32:19.446664

Basic operations
To return the slice data structure instead of plotting, set the return_slice
keyword to True
:
the_slice = mms_part_slice2d(
return_slice=True,
time=time,
instrument="fpi",
species="i",
rotation="bv",
erange=[0, 300],
)
31-Dec-24 02:47:04: Loading pydata/mms1/fpi/fast/l2/dis-dist/2017/09/mms1_fpi_fast_l2_dis-dist_20170910080000_v3.4.0.cdf
31-Dec-24 02:47:05: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:05: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:05: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:05: Loading pydata/mms1/fgm/srvy/l2/2017/09/mms1_fgm_srvy_l2_20170910_v5.104.0.cdf
31-Dec-24 02:47:10: Loading pydata/mms1/fpi/fast/l2/dis-moms/2017/09/mms1_fpi_fast_l2_dis-moms_20170910080000_v3.4.0.cdf
31-Dec-24 02:47:10: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:10: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:10: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:10: Averaging mms1_fgm_b_gse_srvy_l2_bvec
31-Dec-24 02:47:10: Averaging mms1_dis_bulkv_gse_fast
31-Dec-24 02:47:10: Aligning slice plane to: bv
31-Dec-24 02:47:11: Finished slice at 2017-09-10 09:32:19.446664
The slice is stored as a dictionary:
the_slice.keys()
dict_keys(['project_name', 'spacecraft', 'data_name', 'units_name', 'species', 'xyunits', 'rotation', 'energy', 'trange', 'zrange', 'rrange', 'rlog', 'interpolation', 'n_samples', 'data', 'xgrid', 'ygrid'])
We can create 1D cuts through the 2D slice by specifying the velocity range:
(hyzhou: why is the unit still the same as in 2D/3D?)
from pyspedas.particles.spd_slice2d.slice1d_plot import plot
plot(the_slice, 'x', [-100, 100]) # summed from Vv=[-100, 100]

FPI ions with 2D interpolation
The data are rotated such that the x axis is parallel to B field and the bulk velocity defines the x-y plane, and plotted using 2D interpolation (data points within the specified theta or z-axis range are projected onto the slice plane and linearly interpolated onto a regular 2D grid). The default theta range is [-20, +20].
mms_part_slice2d(interpolation="2d", time=time, instrument="fpi", species="i", rotation="bv", erange=[0, 300], cmap="turbo")
31-Dec-24 02:47:12: Loading pydata/mms1/fpi/fast/l2/dis-dist/2017/09/mms1_fpi_fast_l2_dis-dist_20170910080000_v3.4.0.cdf
31-Dec-24 02:47:13: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:13: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:13: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:13: Loading pydata/mms1/fgm/srvy/l2/2017/09/mms1_fgm_srvy_l2_20170910_v5.104.0.cdf
31-Dec-24 02:47:17: Loading pydata/mms1/fpi/fast/l2/dis-moms/2017/09/mms1_fpi_fast_l2_dis-moms_20170910080000_v3.4.0.cdf
31-Dec-24 02:47:17: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:17: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:17: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:17: Averaging mms1_fgm_b_gse_srvy_l2_bvec
31-Dec-24 02:47:17: Averaging mms1_dis_bulkv_gse_fast
31-Dec-24 02:47:17: Aligning slice plane to: bv
31-Dec-24 02:47:18: Finished slice at 2017-09-10 09:32:19.446664

slicemms2d = mms_part_slice2d(return_slice=True, interpolation="2d", time=time, instrument="fpi", species="i", rotation="bv", erange=[0, 300])
31-Dec-24 02:47:18: Loading pydata/mms1/fpi/fast/l2/dis-dist/2017/09/mms1_fpi_fast_l2_dis-dist_20170910080000_v3.4.0.cdf
31-Dec-24 02:47:19: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:19: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:19: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:19: Loading pydata/mms1/fgm/srvy/l2/2017/09/mms1_fgm_srvy_l2_20170910_v5.104.0.cdf
31-Dec-24 02:47:24: Loading pydata/mms1/fpi/fast/l2/dis-moms/2017/09/mms1_fpi_fast_l2_dis-moms_20170910080000_v3.4.0.cdf
31-Dec-24 02:47:24: The name mms1_dis_pitchangdist_lowen_fast is currently not in pytplot
31-Dec-24 02:47:24: The name mms1_dis_pitchangdist_miden_fast is currently not in pytplot
31-Dec-24 02:47:24: The name mms1_dis_pitchangdist_highen_fast is currently not in pytplot
31-Dec-24 02:47:24: Averaging mms1_fgm_b_gse_srvy_l2_bvec
31-Dec-24 02:47:24: Averaging mms1_dis_bulkv_gse_fast
31-Dec-24 02:47:24: Aligning slice plane to: bv
31-Dec-24 02:47:24: Finished slice at 2017-09-10 09:32:19.446664
import matplotlib.pyplot as plt
import matplotlib.colors as colors
import numpy as np
plt.pcolormesh(slicemms2d["xgrid"], slicemms2d["ygrid"], slicemms2d["data"].T,
norm=colors.LogNorm(1e-24, np.nanmax(slicemms2d["data"])),
cmap="turbo")
plt.colorbar()
plt.show()
