xdas.signal.sosfilt#
- xdas.signal.sosfilt(sos, da, dim='last', zi=None, parallel=None)[source]#
Filter data along one dimension using cascaded second-order sections.
Filter a data sequence, da, using a digital IIR filter defined by sos.
- Parameters:
sos (array_like) – Array of second-order filter coefficients, must have shape
(n_sections, 6). Each row corresponds to a second-order section, with the first three columns providing the numerator coefficients and the last three providing the denominator coefficients.da (DataArray) – An N-dimensional input dataarray.
dim (str, optional) – The dimension of the input dataarray along which to apply the linear filter. Default is -1.
zi (array_like or str, optional) – Initial conditions for the cascaded filter delays. It is a (at least 2D) vector of shape
(n_sections, ..., 2, ...), where..., 2, ...denotes the shape of da, but withda.sizes[dim]replaced by 2. If zi is None,… , or is not given then initial rest (i.e. all zeros) 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:
y (DataArray) – The output of the digital filter.
zi (ndarray, optional) – If zi is None, this is not returned. If zi is given or is … 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() >>> sos = sp.iirfilter(4, 0.5, btype="low", output="sos") >>> xs.sosfilt(sos, 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