# 带阻Butterworth过滤器

``````fs = 33000
r = 55
ft = 150
rp = 0.3
rs = 55
order = 3
a=1
fc1 = 1750
fc2 = 4100
fc=np.union1d(np.array([1,1750]),([4100,10000]))
wp = (fc1-ft/2) *2/fs

ws = (fc2 + ft/2) *2/fs

N, wn = sp.buttord(wp, ws, rp, rs)

b, a = sp.butter(N, wn , btype = "bandstop")

w,h = sp.freqz(b, a,  worN=512, plot=None)

f=(fs/2)*w/(np.pi)

plt.figure()

plt.plot(f,abs(h))
``````

Please, consider improving your question, since `fc` and its friends could be whatever and therefore it is not clear what are you trying to achieve.
From the point of syntax and signal processing, one needs to define a bandpass/bandstop filter you should specify 4 points, because the filter has bell-like shape. Please, refer to buttord parameters:

`wp`, `ws` : float
bandstop: `wp = [0.1, 0.6]`, `ws = [0.2, 0.5]`

so `wp` and `ws` should have shape of (2,).
To make the syntax in your example correct, change

``````wp = (fc1-ft/2) *2/fs
ws = (fc2 + ft/2) *2/fs
``````

``````wp = [(fc1-ft/2) *2/fs, (fc2 + ft) *2/fs]
ws = [(fc1+ft) *2/fs, (fc2 + ft/2) *2/fs]
``````

The frequencies, of course, are chosen arbitrarily, but keep in mind that it must be `wp_low < ws_low < ws_high < wp_high` so pass range includes stop range entirely.