(我也貼了SciPy的郵件列表如下。)
當你設計一個巴特沃斯濾波器buttord,沒有足夠的 自由度,以滿足所有的設計約束完全相同。因此 是過渡區域的哪一端碰到約束 以及哪一端是「過度設計」的選擇。在scipy 0.14.0中做出的改變將該選擇從阻帶邊緣切換到通帶邊緣。
一張照片會說清楚。下面的腳本生成以下圖。 (我將Rp從3改爲1.5,-3 dB與Wn的增益一致,這就是爲什麼你的Wn與Wp相同。)使用舊約定或新約定生成的濾波器都滿足設計約束條件。隨着新公約的出現,這種反應恰好與通帶末端的約束相抵觸。
import numpy as np
from scipy.signal import buttord, butter, freqs
import matplotlib.pyplot as plt
# Design results for:
Wp = 2*np.pi*10
Ws = 2*np.pi*100
Rp = 1.5 # instead of 3
Rs = 80
n_old = 5
wn_old = 99.581776302787929
n_new, wn_new = buttord(Wp, Ws, Rp, Rs, analog=True)
b_old, a_old = butter(n_old, wn_old, analog=True)
w_old, h_old = freqs(b_old, a_old)
b_new, a_new = butter(n_new, wn_new, analog=True)
w_new, h_new = freqs(b_new, a_new)
db_old = 20*np.log10(np.abs(h_old))
db_new = 20*np.log10(np.abs(h_new))
plt.semilogx(w_old, db_old, 'b--', label='old')
plt.axvline(wn_old, color='b', alpha=0.25)
plt.semilogx(w_new, db_new, 'g', label='new')
plt.axvline(wn_new, color='g', alpha=0.25)
plt.axhline(-3, color='k', ls=':', alpha=0.5, label='-3 dB')
plt.xlim(40, 1000)
plt.ylim(-100, 5)
xbounds = plt.xlim()
ybounds = plt.ylim()
rect = plt.Rectangle((Wp, ybounds[0]), Ws - Wp, ybounds[1] - ybounds[0],
facecolor="#000000", edgecolor='none', alpha=0.1, hatch='//')
plt.gca().add_patch(rect)
rect = plt.Rectangle((xbounds[0], -Rp), Wp - xbounds[0], 2*Rp,
facecolor="#FF0000", edgecolor='none', alpha=0.25)
plt.gca().add_patch(rect)
rect = plt.Rectangle((Ws, ybounds[0]), xbounds[1] - Ws, -Rs - ybounds[0],
facecolor="#FF0000", edgecolor='none', alpha=0.25)
plt.gca().add_patch(rect)
plt.annotate("Pass", (0.5*(xbounds[0] + Wp), Rp+0.5), ha='center')
plt.annotate("Stop", (0.5*(Ws + xbounds[1]), -Rs+0.5), ha='center')
plt.annotate("Don't Care", (0.1*(8*Wp + 2*Ws), -Rs+10), ha='center')
plt.legend(loc='best')
plt.xlabel('Frequency [rad/s]')
plt.ylabel('Gain [dB]')
plt.show()
Matlab的信號處理工具通常需要頻率相關參數被表示爲相對於該奈奎斯特歸一化頻率。也就是說,Wp = Fp/Fn和Ws = Fs/Fn,其中Fn是奈奎斯特頻率。 – Juderb 2015-01-21 04:58:55
@Juderb我正在使用奈奎斯特頻率無關緊要的模擬濾波器。從SciPy的文檔中,對於模擬濾波器,wp和ws是角頻率(例如rad/s)._ – Renan 2015-01-21 11:18:12