ess.diffraction.lowpass#

ess.diffraction.lowpass(da, *, dim, N, Wn, coord=None)#

Smooth data using a lowpass frequency filter.

Applies a lowpass Butterworth filter to da.data based on the sampling rate defined by coord. See scipp.signal.butter() for information on filter design.

Important

If coord is bin-edges, it is first converted to bin-centers using scipp.midpoints(). This is only valid for linearly-spaced edges.

Parameters
  • da (DataArray) – Data to smoothen.

  • dim (str) – Dimension along which to smooth.

  • coord (Optional[str], default: None) – Name of the coordinate that defines the sampling frequency. Defaults to dim.

  • N (int) – Order of the lowpass filter.

  • Wn (Variable) – Critical frequency of the filter.

Returns

DataArray – Smoothed da.

Examples

>>> x = sc.linspace(dim='x', start=1.1, stop=4.0, num=1000, unit='m')
>>> y = sc.sin(x * sc.scalar(1.0, unit='rad/m'))
>>> y += sc.sin(x * sc.scalar(400.0, unit='rad/m'))
>>> noisy = sc.DataArray(data=y, coords={'x': x})
>>> smooth = lowpass(noisy, dim='x', N=4, Wn=20 / x.unit)