本文簡要介紹 python 語言中 scipy.signal.sosfilt
的用法。
用法:
scipy.signal.sosfilt(sos, x, axis=-1, zi=None)#
使用級聯二階部分沿一維過濾數據。
使用由 sos 定義的數字 IIR 濾波器對數據序列 x 進行濾波。
- sos: array_like
二階濾波器係數數組,必須具有形狀
(n_sections, 6)
。每行對應一個二階部分,前三列提供分子係數,後三列提供分母係數。- x: array_like
一個 N 維輸入數組。
- axis: 整數,可選
沿其應用線性濾波器的輸入數據數組的軸。過濾器沿該軸應用於每個子陣列。默認值為 -1。
- zi: 數組,可選
級聯濾波器延遲的初始條件。它是形狀的(至少 2D)向量
(n_sections, ..., 2, ...)
,其中..., 2, ...
表示形狀x,但與x.shape[axis]
替換為 2。如果子為 None 或未給出,則假定初始休息(即全零)。請注意,這些初始條件是不是與給出的初始條件相同lfiltic
或者scipy.signal.lfilter_zi.
- y: ndarray
數字濾波器的輸出。
- zf: ndarray,可選
如果 zi 為 None,則不返回,否則,zf 保存最終的濾波器延遲值。
參數 ::
返回 ::
注意:
濾波器函數由一係列具有direct-form II 轉置結構的二階濾波器實現。它旨在最大限度地減少高階濾波器的數值精度誤差。
例子:
使用
lfilter
和sosfilt
繪製 13th-order 濾波器的脈衝響應,顯示嘗試在單級中執行 13th-order 濾波器所導致的不穩定性(數值誤差將某些極點推到單位圓之外) ):>>> import matplotlib.pyplot as plt >>> from scipy import signal >>> b, a = signal.ellip(13, 0.009, 80, 0.05, output='ba') >>> sos = signal.ellip(13, 0.009, 80, 0.05, output='sos') >>> x = signal.unit_impulse(700) >>> y_tf = signal.lfilter(b, a, x) >>> y_sos = signal.sosfilt(sos, x) >>> plt.plot(y_tf, 'r', label='TF') >>> plt.plot(y_sos, 'k', label='SOS') >>> plt.legend(loc='best') >>> plt.show()
相關用法
- Python SciPy signal.sosfiltfilt用法及代碼示例
- Python SciPy signal.sosfilt_zi用法及代碼示例
- Python SciPy signal.sosfreqz用法及代碼示例
- Python SciPy signal.sos2tf用法及代碼示例
- Python SciPy signal.step2用法及代碼示例
- Python SciPy signal.spectrogram用法及代碼示例
- Python SciPy signal.square用法及代碼示例
- Python SciPy signal.step用法及代碼示例
- Python SciPy signal.sweep_poly用法及代碼示例
- Python SciPy signal.savgol_coeffs用法及代碼示例
- Python SciPy signal.symiirorder1用法及代碼示例
- Python SciPy signal.sawtooth用法及代碼示例
- Python SciPy signal.symiirorder2用法及代碼示例
- Python SciPy signal.stft用法及代碼示例
- Python SciPy signal.ss2tf用法及代碼示例
- Python SciPy signal.savgol_filter用法及代碼示例
- Python SciPy signal.spline_filter用法及代碼示例
- Python SciPy signal.czt_points用法及代碼示例
- Python SciPy signal.chirp用法及代碼示例
- Python SciPy signal.residue用法及代碼示例
- Python SciPy signal.iirdesign用法及代碼示例
- Python SciPy signal.max_len_seq用法及代碼示例
- Python SciPy signal.kaiser_atten用法及代碼示例
- Python SciPy signal.oaconvolve用法及代碼示例
- Python SciPy signal.hilbert用法及代碼示例
注:本文由純淨天空篩選整理自scipy.org大神的英文原創作品 scipy.signal.sosfilt。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。