lupy.signalutils.sosfilt¶
- lupy.signalutils.sosfilt.validate_sos(sos: ndarray[tuple[int, int], dtype[float64]]) ndarray[tuple[int, Literal[6]], dtype[float64]][source]¶
Helper to validate a SOS input
- lupy.signalutils.sosfilt.sosfilt(sos: ndarray[tuple[int, Literal[6]], dtype[float64]], x: ndarray[tuple[int, int], dtype[float64]], zi: ndarray[tuple[int, int, Literal[2]], dtype[float64]], axis: int = -1) tuple[ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[int, int, Literal[2]], dtype[float64]]][source]¶
Filter data along one dimension using cascaded second-order sections.
Filter a data sequence, x, using a digital IIR filter defined by sos.
Note
This is a stripped down version of
scipy.signal.sosfilt()to reduce overhead in repeated calls. It removes input validation and assumes 2D input of typefloat64.It also requires the initial conditions zi to be provided and always returns the final conditions zf.
- Parameters:
sos (ndarray) – 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.x (ndarray) – A 2-dimensional input array of dtype
float64.zi (ndarray) – Initial conditions for the cascaded filter delays. It is a (at least 2D) array of shape
(n_sections, ..., 2, ...), where..., 2, ...denotes the shape of x, but withx.shape[axis]replaced by 2. Note that these initial conditions are not the same as the initial conditions given by lfiltic or lfilter_zi.axis (int, optional) – The axis of the input data array along which to apply the linear filter. The filter is applied to each subarray along this axis. Default is -1.
- Returns:
y (ndarray) – The output of the digital filter.
zf (ndarray) – The final filter delay values.
- Return type:
tuple[ndarray[tuple[int, int], dtype[float64]], ndarray[tuple[int, int, Literal[2]], ~numpy.dtype[~numpy.float64]]]