pyrfu.pyrf.movmean module#
- pyrfu.pyrf.movmean.movmean(inp: DataArray, window_size: int | None = None) DataArray[source]#
Computes running average of the inp over npts points.
- Parameters:
inp (DataArray) – Time series of the input variable.
window_size (int, Optional) – Number of points to average over. Default is a 4-point running average.
- Returns:
Time series of the input variable averaged over npts points.
- Return type:
DataArray
- Raises:
TypeError – If inp is not a DataArray.
ValueError – If window_size is smaller than 2 or larger than the length of the data.
Notes
Works also with 3D skymap distribution.
Examples
>>> from pyrfu import mms, pyrf
Time interval
>>> tint = ["2019-09-14T07:54:00.000","2019-09-14T08:11:00.000"]
Spacecraft index
>>> mms_id = 1
Load ion pressure tensor
>>> p_xyz_i = mms.get_data("Pi_gse_fpi_brst_l2", tint, mms_id)
Running average the pressure tensor over 10s
>>> fs = pyrf.calc_fs(p_xyz_i) >>> p_xyz_i = pyrf.movmean(p_xyz_i, int(10 * fs))