---
title: MMS Science event
subtitle: Electron-scale measurements of magnetic reconnection in space
engine: julia
---
On 2015-10-16 around 13:07:02 UT, MMS2 crossed an electron diffusion region (EDR) of magnetopause reconnection, the first such crossing reported by [Burch et al. (2016)](https://doi.org/10.1126/science.aaf2939). This tutorial rebuilds the core of their Figure 2 from burst-mode CDAWeb data: fields and moments in boundary-normal (LMN) coordinates, energy spectrograms, and the current density from the plasma moments, then zooms in on the EDR with the electron energy spectrograms parallel, perpendicular and antiparallel to B of their Figure 3.
Data are read into `DataVariable`s, which keep the CDF coordinates, such as the time-varying energy bins of FPI spectra.
```{julia}
using CDAWeb, SPEDAS
using SpaceDataModel: DataVariable
using Dates, LinearAlgebra, Unitful
using CairoMakie, SpacePhysicsMakie
t0, t1 = DateTime("2015-10-16T13:05:30"), DateTime("2015-10-16T13:07:30")
B = DataVariable(cda"MMS2_FGM_BRST_L2/mms2_fgm_b_gse_brst_l2"(t0, t1))[1:3, :] # drop |B|
E = DataVariable(cda"MMS2_EDP_BRST_L2_DCE/mms2_edp_dce_gse_brst_l2"(t0, t1))
Ni, Vi, Si = DataVariable.(getdata.(cda"MMS2_FPI_BRST_L2_DIS-MOMS/mms2_dis_numberdensity_brst,mms2_dis_bulkv_gse_brst,mms2_dis_energyspectr_omni_brst", t0, t1))
Ne, Ve, Se = DataVariable.(getdata.(cda"MMS2_FPI_BRST_L2_DES-MOMS/mms2_des_numberdensity_brst,mms2_des_bulkv_gse_brst,mms2_des_energyspectr_omni_brst", t0, t1))
```
## Boundary-normal coordinates
Minimum variance analysis of the magnetic field across the clean magnetopause crossing at 13:05:40 gives the LMN frame: L along the reconnecting field, N normal to the boundary.
```{julia}
F = mva_eigen(tview(B, DateTime("2015-10-16T13:05:40"), DateTime("2015-10-16T13:06:09")))
F.vectors # columns: L, M, N in GSE
```
These match the axes of Burch et al.: L = (0.3665, −0.1201, 0.9226), M = (0.5694, −0.7553, −0.3245), N = (0.7358, 0.6443, −0.2084) GSE.
`mva(x, F)` rotates any vector series into this frame; `setcoord` updates its coordinate metadata.
```{julia}
lmn(x, sym) = setmeta(setcoord(mva(x, F), "LMN"), "LABLAXIS" => sym, "LABL_PTR_1" => ["$(sym)_$c" for c in "LMN"])
B_lmn = lmn(B, "B")
Vi_lmn = lmn(Vi, "Vi")
E_lmn = lmn(tresample(E, Millisecond(30)), "E") # 8192 S/s is more than a 2-minute panel can show
```
## Current density
The current carried by the plasma is $\mathbf{J} = e\,n\,(\mathbf{V}_i - \mathbf{V}_e)$, evaluated at the electron cadence (30 ms) with the ion velocity (150 ms) interpolated onto it.
```{julia}
Ve_s, Vi_s, Ne_s = tsync(Ve, Vi, Ne)
J = uconvert.(u"μA/m^2", Unitful.q .* parent(Ne_s)' .* (Vi_s .- Ve_s) .* u"cm^-3 * km/s")
J_lmn = lmn(J, "J")
```
## Convection speeds
The perpendicular (convection) speed is $|\mathbf{V} \times \mathbf{B}| / |\mathbf{B}|$, with B interpolated onto the velocity samples. Electrons and ions convect together where the plasma is frozen-in; their speeds separate where the ions decouple from the field.
```{julia}
vperp(V, sym) = setmeta(mapsamples((v, b) -> norm(v × b) / norm(b), tsync(V, B)...), "LABLAXIS" => sym)
Vperp = [vperp(Vi, "|Vi⊥|"), vperp(Ve, "|Ve⊥|")]
```
## Overview
```{julia}
#| fig-height: 14
density = [setmeta(Ni, "LABLAXIS" => "Ni"), setmeta(Ne, "LABLAXIS" => "Ne")]
f = tplot((B_lmn, density, Si, Se, Vi_lmn, Vperp, J_lmn, E_lmn))
tlines!(f, DateTime("2015-10-16T13:07:02.2"))
f
```
From top: B_L reverses across the magnetopause at 13:05:40 and again near the EDR; magnetosheath ions (~1 keV) and electrons (~100 eV) replace the hot, tenuous magnetospheric plasma; the ion jet in −L marks the reconnection exhaust; electrons convect far faster than ions (|Ve⊥| ≫ |Vi⊥|) as the spacecraft approaches the EDR; J_M peaks at the EDR (vertical line), where E also spikes.
## Electron diffusion region
Over three seconds around the EDR, B_L reverses sign, J_M and E peak, and the electron spectra parallel, perpendicular and antiparallel to B change abruptly at 13:07:02.2.
```{julia}
#| fig-height: 10
tz0, tz1 = DateTime("2015-10-16T13:07:00.5"), DateTime("2015-10-16T13:07:03.5")
spectra = DataVariable.(getdata.(cda"MMS2_FPI_BRST_L2_DES-MOMS/mms2_des_energyspectr_par_brst,mms2_des_energyspectr_perp_brst,mms2_des_energyspectr_anti_brst", tz0, tz1))
f = tplot((tview(B_lmn, tz0, tz1), tview(J_lmn, tz0, tz1), lmn(tview(E, tz0, tz1), "E"), spectra...))
tlines!(f, DateTime("2015-10-16T13:07:02.2"))
f
```
## 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()
```
:::