pyrfu.mms.psd_moments#

pyrfu.mms.psd_moments(vdf, sc_pot, **kwargs)[source]#

Computes moments from the FPI particle phase-space densities.

Parameters:
  • vdf (xarray.Dataset) – 3D skymap velocity distribution. The angular widths are taken from the optional attributes delta_phi_minus/delta_phi_plus (time, phi) and delta_theta_minus/delta_theta_plus (theta), in degrees, or else from the spacing of the phi and theta grids.

  • sc_pot (xarray.DataArray) – Time series of the spacecraft potential.

  • energy_range (array_like or xarray.DataArray) –

    Energy range in eV to integrate over, strictly within (instrument energies, before the spacecraft potential correction):

    • [E_min, E_max]: applied to the energy table of the first time step, and the same channels are used at all times, to ensure that the same number of points are integrated over with alternating tables.

    • time dependent (E_min, E_max): an array of shape (n_t, 2) at the times of vdf, or a DataArray with a time coordinate and 2 columns, resampled to the times of vdf. At each time step, the channels of its energy table within its range are integrated over; time steps without channel get NaN moments.

    Can’t be used with en_channels.

  • no_sc_pot (bool) – Set to 1 to set spacecraft potential to zero. Calculates moments without correcting for spacecraft potential.

  • en_channels (array_like) – Energy channels to integrate over, [start, stop) 0-based indices as a Python slice (default [0, 32], all the channels; unlike irfu-matlab’s 1-based inclusive [min max]). Can’t be used with energy_range.

  • partial_moments (numpy.ndarray or xarray.DataArray) – Use a binary array to select which psd points are used in the moments calculation. partial_moments must be a binary array (1s and 0s, 1s correspond to points used). Array (or data of Dataarray) must be the same size as vdf.data.

  • inner_electron ({"on", "off"}) – inner_electrontron potential for electron moments.

Returns:

  • n_psd (xarray.DataArray) – Time series of the number density (1rst moment).

  • v_psd (xarray.DataArray) – Time series of the bulk velocity (2nd moment).

  • p_psd (xarray.DataArray) – Time series of the pressure tensor (3rd moment).

  • p2_psd (xarray.DataArray) – Time series of the pressure tensor.

  • t_psd (xarray.DataArray) – Time series of the temperature tensor.

  • h_psd (xarray.DataArray) – Time series of the heat flux vector

Raises:

ValueError – If energy_range has no channel (fixed range) or a wrong shape, or if both energy_range and en_channels are given.

Notes

The speed widths of the energy channels follow irfu-matlab mms.psd_moments: the channel edges are E + delta_energy_plus and E - delta_energy_minus (attributes) when there is one energy table, and the midpoints between the channels of each table otherwise. The spacecraft potential is subtracted from the edges (pyrfu < 2.5 used the uncorrected edges, which underestimates the density of cold electrons, by 10-30 % for 10-20 eV and 10 V). The phase-space density is not corrected for spacecraft photoelectrons, unlike the FPI moments: use inner_electron="on" or an energy range above the spacecraft potential to compare the electron moments with them.

Examples

>>> from pyrfu import mms

Define time interval

>>> tint_brst = ["2015-10-30T05:15:20.000", "2015-10-30T05:16:20.000"]

Load magnetic field and spacecraft potential

>>> scpot = mms.get_data("V_edp_brst_l2", tint_brst, 1)

Load electron velocity distribution function

>>> vdf_e = mms.get_data("pde_fpi_brst_l2", tint_brst, 1)

Compute moments

>>> options = dict(energy_range=[1, 1000])
>>> moments_e = mms.psd_moments(vdf_e, scpot, **options)