xdas.signal.lfilter#

xdas.signal.lfilter(b, a, da, dim='last', zi=None, parallel=None)[source]#

Filter data along one-dimension with an IIR or FIR filter.

Filter a data sequence, da, using a digital filter. The filter is a direct form II transposed implementation of the standard difference equation.

Parameters:
  • b (array_like) – The numerator coefficient vector in a 1-D sequence.

  • a (array_like) – The denominator coefficient vector in a 1-D sequence. If a[0] is not 1, then both a and b are normalized by a[0].

  • da (DataArray) – An N-dimensional input dataarray.

  • dim (str, optional) – The dimension of the input data array along which to apply the linear filter. Default is last.

  • zi (array_like or str, optional) – Initial conditions for the filter delays. If zi is None or … then initial rest is assumed.

  • parallel (bool or int, optional) – Number of threads to use. True uses all cores, False uses one, an int uses that many, None defers to the global xdas configuration. Default is None.

Returns:

  • da (DataArray) – The output of the digital filter.

  • zf (array, optional) – If zi is None, this is not returned. If zi is given or … then zf holds the final filter delay values.

Notes

Splits on data discontinuities along dim.

Examples

>>> import scipy.signal as sp
>>> import xdas.signal as xs
>>> from xdas.synthetics import wavelet_wavefronts
>>> da = wavelet_wavefronts()
>>> b, a = sp.iirfilter(4, 0.5, btype="low")
>>> xs.lfilter(b, a, da, dim='time')
<xdas.DataArray (time: 300, distance: 401)>
[[ 0.004668 -0.005968  0.007386 ... -0.0138    0.01271  -0.026618]
 [ 0.008372 -0.01222   0.022552 ... -0.041387  0.046667 -0.093521]
 [-0.008928  0.002764  0.012621 ... -0.032496  0.039645 -0.076117]
 ...
 [ 0.012576 -0.1661    0.196026 ...  0.048191 -0.014532 -0.033122]
 [-0.06294  -0.092234  0.316862 ...  0.045337 -0.139729  0.094086]
 [-0.035233  0.036613  0.044002 ... -0.053585 -0.121344  0.241415]]
Coordinates:
  * time (time): 2023-01-01T00:00:00.000 to 2023-01-01T00:00:05.980
  * distance (distance): 0.000 to 10000.000