---
title: MMS Science event
subtitle: Electron-scale measurements of magnetic reconnection in space
engine: julia
---
> Obtain and analyze plasma data, including spectra, for the first MMS Science event (Burch et al., Science 2016, link here) showing magnetopause reconnection at the electron diffusion region on 2016/10/16 13:07:02.2 UT. Start by using Hwk06_mpause_RX.pro, provided. The objective of this exercise is to introduce plasma distributions from MMS (electrons and ions) and create burst spectra. In the process also create plasma moments and the plasma current and plot these along E and B. You are requested to create Figure 2 of Burch et al. plus the 3 bottom (electron) spectrograms from Figure 3 of the same paper (panels 3G, 3H and 3I). Your figure should look like the one shown on the next page, but using burst mode data in order to make it look like in Burch et al. You are requested to plot this figure at 2 time scales: the overview (2 min) timescale as in Fig. 2 of Burch et al. [‘13:05:30’,’13:07:30’] and the zoom-in (3 sec) timescale as in Fig. 3 of Burch et al. ['13:07:00.5','13:07:03.5']. Notice that the clean and fast m’pause crossing was at 13:05:40UT, and this is used to determine N. In Fig. 2K of Burch et al. (the right-hand side of Fig. 2, the pictorial view of the MMS trajectory for the 2min interval) this initial m’pause crossing was near the start of the trajectory. The trajectory crosses the X-point at the 3 seconds of the zoom-in interval.
```{julia}
using Speasy
using DimensionalData
using SPEDAS
using SPEDAS.MMS
using CairoMakie, SpacePhysicsMakie
using Unitful
using Dates
update_theme!(colormap=:rainbow1)
SpacePhysicsMakie.DEFAULTS.add_title = true;
```
## Overview plot
### Minimum Variance Analysis
```{julia}
trange = DateTime.(("2015-10-16T13:05:35", "2015-10-16T13:07:25"))
tr_mpause = DateTime.(("2015-10-16T13:05:40", "2015-10-16T13:06:09"))
probe = 2
tvars = (
"cda/MMS2_FGM_SRVY_L2/mms2_fgm_b_gse_srvy_l2_clean",
"cda/MMS2_EDP_FAST_L2_DCE/mms2_edp_dce_gse_fast_l2",
)
B_gse, edp_dce_gse = get_data(tvars, trange) .|> DimArray
rotMat = mva_eigen(tview(B_gse[:, 1:3], tr_mpause))
B_LMN = rotate(B_gse[:, 1:3], rotMat) |> set_coord("LMN") |> set_coord("Boundary-normal coordinates"; old_coords=["Geocentric Solar Ecliptic"])
E_LMN = rotate(edp_dce_gse, rotMat) |> set_coord("LMN")
rotMat
```
The direction obtained from the Minimum Variance Analysis (MVA) in our study closely aligns with the direction reported in the literature.
> The (x, y, z) GSE components of the L, M, and N axes are L = (0.3665, –0.1201, 0.9226) GSE, M = (0.5694, –0.7553, –0.3245) GSE, and N = (0.7358, 0.6443, –0.2084) GSE
### Plasma data
```{julia}
data_rate = "brst"
fpi_des_ds = FPIDataSet(; probe, data_rate, data_type="des")
fpi_dis_ds = FPIDataSet(; probe, data_rate, data_type="dis")
func = x -> begin
out = unit(x) * DimArray(x)
out.metadata["DEPEND_1"] = x.dims[2] # a temporary fix for `SpacePhysicsMakie`
out
end
des_data = map(func, get_data(NamedTuple, fpi_des_ds, trange))
dis_data = map(func, get_data(NamedTuple, fpi_dis_ds, trange))
des_n = setmeta(des_data.numberdensity[:, 1], labels="Ne")
dis_bulkv_lmn = rotate(dis_data.bulkv_gse, rotMat) |> set_coord("LMN")
des_bulkv_lmn = rotate(des_data.bulkv_gse, rotMat) |> set_coord("LMN")
dis_n = setmeta(dis_data.numberdensity[:, 1], labels="Ni")
```
### Magnitudes of electron and ion convection velocities
```{julia}
Vi_perp_mag, Ve_perp_mag = let Vi = dis_data.bulkv_gse, Ve = des_data.bulkv_gse, B = B_gse
tr = timerange(B)
Vi_clip = tview(Vi, tr)
Ve_clip = tview(Ve, tr)
B_int_Vi = tinterp(B, Vi_clip)[:, 1:3]
B_int_Ve = tinterp(B, Ve_clip)[:, 1:3]
Vi_perp_mag = toproj(Vi_clip, B_int_Vi) |> tnorm
Ve_perp_mag = toproj(Ve_clip, B_int_Ve) |> tnorm
setmeta(Vi_perp_mag, labels="Viper_t"), setmeta(Ve_perp_mag, labels="Veper_t")
end
```
### Current density
```{julia}
J = begin
Vi = dis_bulkv_lmn
Ve = des_bulkv_lmn
n = dis_n
Ve_clip = tclip(Ve, timerange(Vi))
Vi_interp = tinterp(Vi, Ve_clip)
n_interp = tinterp(n, Ve_clip)
J = mapslices(Vi_interp - Ve_clip; dims=Ti) do V_diff_i
@. Unitful.q * V_diff_i * n_interp |> u"μA*m^-2"
end
setmeta(J, labels=["j_L", "j_M", "j_N"])
end
```
### Para, perp and anti-parallel spectra of electrons
```{julia}
des_energyspectr_tvars = [
"cda/MMS2_FPI_BRST_L2_DES-MOMS/mms$(probe)_des_energyspectr_par_$(data_rate)",
"cda/MMS2_FPI_BRST_L2_DES-MOMS/mms$(probe)_des_energyspectr_perp_$(data_rate)",
"cda/MMS2_FPI_BRST_L2_DES-MOMS/mms$(probe)_des_energyspectr_anti_$(data_rate)"
]
des_energyspectr = get_data(des_energyspectr_tvars, trange) .|> func
replace!.(des_energyspectr, 0 => NaN)
des_energyspectr_ratio = des_energyspectr[1] ./ des_energyspectr[2]
des_energyspectr = setmeta.(des_energyspectr, colorrange=(1e5, 1e9))
des_energyspectr_ratio = setmeta(des_energyspectr_ratio,
colorrange=(1e-1, 1e1), title="Ratio (Para/Perp)"
)
```
### Summary data plot
> In 1 paragraph (10 lines) explain what each panel represents for this reconnection interval.
From top to bottom, the panels represent the following:
1. the magnetic field vectors in LMN coordinate system;
2. energy times spectrogram of ion energy flux;
3. energy times spectrogram of electron energy flux;
4. plasma density (ion and electron);
5. ion flow velocity vectors in LMN coordinate system;
6. magnitudes of electron and ion convection velocities;
7. current density;
8. electron parallel and perpendicular temperatures;
9. electric field vectors in LMN coordinate system;
10-12. electron spectrograms (parallel, perpendicular, anti-parallel);
13. electron spectrogram ratio (para/perp).
```{julia}
tvars2plot = (
B_LMN,
[dis_n, des_n],
setmeta(dis_data.energyspectr_omni, colorrange=(1e3, 1e9)),
setmeta(des_data.energyspectr_omni, colorrange=(1e3, 1e9)),
dis_bulkv_lmn,
[Vi_perp_mag, Ve_perp_mag],
E_LMN,
des_energyspectr...,
des_energyspectr_ratio
)
faxes = tplot(tvars2plot)
tlines!(faxes, "2015-10-16T13:05:52")
tlines!(faxes, ["2015-10-16T13:05:44", "2015-10-16T13:06:00"])
tlines!(faxes, ["2015-10-16T13:06:46", "2015-10-16T13:07:12"])
ylims!.(faxes.axes[end-3:end], 0.9e1, 1.2e3)
faxes
```
## Reproducibility
::: {.callout-note collapse="true"}
## This tutorial was built using these direct dependencies
```{julia}
using Pkg
Pkg.status()
```
:::
::: {.callout-note collapse="true"}
## Machine and Julia version information
```{julia}
using InteractiveUtils # hide
versioninfo()
```
:::