xarray_lowpass

PlasmaCalcs.tools.fft_tools.xarray_fft.xarray_lowpass(array, dim=None, keep=UNSET, *, keep_r=UNSET, ds=None, real=None, return_fft=False)

return array after putting it through a lowpass filter using fft & ifft.

This is equivalent to ifft(fft(array) * filter), where filter is 0 at all “large” frequency values.
“large” is determined by keep & r; see below.
dim: None or iterable or strs
coordinates to apply lowpass filter over. If None, use all array.dims.
promote_dim(array, coord) for any non-dimension coordinates, as needed.
keep: UNSET, True, dict, or number between 0 < keep <= 1
fraction of frequencies to keep, along each dim.
(Must provide this or keep_r but not both.)
True –> use DEFAULTS.FFT_LOWPASS_KEEP.
number –> use this value for all dims.
keep_r: UNSET, True, or number between 0 < keep <= 1
radius of N-sphere to keep in normalized frequency-space,
normalized such that max(frequencies)==1 along each dim.
All values outside of this N-sphere will be set to 0.
Similar to keep, but here use an N-sphere instead of an N-cube.
(Must provide this or keep but not both.)
True –> use DEFAULTS.FFT_LOWPASS_KEEP.
[TODO] more options than just spherical? (e.g. ellipsoid)
ds: None, number, or dict of {dim: d}
spacing between elements of array along each dim.
number –> use the same value for all dims.
None –> infer via array.coords[dim].diff(dim) for each dim
(requires evenly-spaced coordinates in dim; spacing checked with np.allclose)
real: None or bool
whether to return np.real(ifft) instead of just ifft (which might have imaginary part)
None –> infer from array. Use True if np.all(np.isreal(array)), else False.
return_fft: bool
whether to return (result, masked fft) instead of just result.
mainly intended for debugging purposes.