def firwin_kaiser_bsf(f_stop1, f_pass1, f_pass2, f_stop2, d_stop, <EOL>fs = <NUM_LIT:1.0>, N_bump=<NUM_LIT:0>):
<EOL>f_pass = (f_pass2 - f_pass1)/<NUM_LIT:2><EOL>f_stop = (f_stop2 - f_stop1)/<NUM_LIT:2><EOL>wc = <NUM_LIT:2>*np.pi*(f_pass + f_stop)/<NUM_LIT:2>/fs<EOL>delta_w = <NUM_LIT:2>*np.pi*(f_stop - f_pass)/fs<EOL>M = np.ceil((d_stop - <NUM_LIT:8>)/(<NUM_LIT>*delta_w))<EOL>M += N_bump<EOL>if ((M+<NUM_LIT:1>)/<NUM_LIT>-int((M+<NUM_LIT:1>)/<NUM_LIT>)) == <NUM_LIT:0>:<EOL><INDENT>M += <NUM_LIT:1><EOL><DEDENT>N_taps = M + <NUM_LIT:1><EOL>beta = signal.kaiser_beta(d_stop)<EOL>w_k = signal.kaiser(N_taps,beta)<EOL>n = np.arange(N_taps)<EOL>b_k = wc/np.pi*np.sinc(wc/np.pi*(n-M/<NUM_LIT:2>)) * w_k<EOL>b_k /= np.sum(b_k)<EOL>f0 = (f_pass2 + f_pass1)/<NUM_LIT:2><EOL>w0 = <NUM_LIT:2>*np.pi*f0/fs<EOL>n = np.arange(len(b_k))<EOL>b_k_bs = <NUM_LIT:2>*b_k*np.cos(w0*(n-M/<NUM_LIT:2>))<EOL>b_k_bs = -b_k_bs<EOL>b_k_bs[int(M/<NUM_LIT:2>)] += <NUM_LIT:1> <EOL>print('<STR_LIT>' % N_taps)<EOL>return b_k_bs<EOL>
Design an FIR bandstop filter using the sinc() kernel and
a Kaiser window. The filter order is determined based on 
f_stop1 Hz, f_pass1 Hz, f_pass2 Hz, f_stop2 Hz, and the 
desired stopband attenuation d_stop in dB for both stopbands,
all relative to a sampling rate of fs Hz.
Note: The passband ripple cannot be set independent of the
stopband attenuation.
Note: The filter order is forced to be even (odd number of taps)
so there is a center tap that can be used to form 1 - H_BPF.

Mark Wickert October 2016