def _decimate(x, q):
"""
Downsample the signal after low-pass filtering to avoid aliasing.
An order 16 Chebyshev type I filter is used.
Parameters
----------
x : ndarray
The signal to be downsampled, as an N-dimensional array.
q : int
The downsampling factor.
Returns
-------
y : ndarray
The down-sampled signal.
"""
if not isinstance(q, int):
raise TypeError("q must be an integer")
b, a = signal.filter_design.cheby1(16, 0.025, 0.98 / q)
y = signal.filtfilt(b, a, x, axis=-1)
sl = [slice(None)] * y.ndim
sl[-1] = slice(None, None, q)
return y[sl]
评论列表
文章目录