[SciPy-dev] problem with signal.butter
oliphant at ee.byu.edu
Wed Aug 3 17:05:41 CDT 2005
John Hunter wrote:
>I am trying to design a bandpass butterworth filter and am getting an
> import scipy.signal as sig
> Fs = 400.
> Nyq = Fs/2.
> # low pass stop freq, high pass corner freq, etc...
> lpsf = 5.
> lpcf = 7.
> hpcf = 12.
> hpsf = 18.
> Nyq = Fs/2.
> wp = [lpcf/Nyq, hpcf/Nyq]
> ws = [lpsf/Nyq, hpsf/Nyq]
> gpass = 3.
> gstop = 15.
> ord, Wn = sig.buttord(wp, ws, gpass, gstop)
> mybutt = sig.butter(ord, Wn, btype='bandpass') # pun intended
>With scipy version 0.3.2 I get the following the traceback
>Traceback (most recent call last):
> File "<console>", line 1, in ?
> File "/usr/lib/python2.4/site-packages/scipy/signal/filter_design.py", line 482, in butter
> return iirfilter(N, Wn, btype=btype, analog=analog, output=output, ftype='butter')
> File "/usr/lib/python2.4/site-packages/scipy/signal/filter_design.py", line 456, in iirfilter
> b, a = lp2bp(b,a,wo=wo,bw=bw)
> File "/usr/lib/python2.4/site-packages/scipy/signal/filter_design.py", line 253, in lp2bp
> aprime[Dp-j] = val
>TypeError: can't convert complex to float; use abs(z)
val must be complex for some reason where it is not expected to be.
Not sure what is going on. Which version of Numeric do you have installed?
This is what I get.
>>> import scipy
import scipy.signal as sig
ord,Wn = sig.buttord([7/200.,12/200.],[5/200.0,18/200.0],3,15)
array([ 0.034979417860466, 0.060035166350418])
>>> mybutt = sig.butter(ord,Wn,btype='bandpass')
(array([ 0.001466661479123, 0. , -0.002933322958246,
0. , 0.001466661479123]), array([
1. , -3.848535133256346, 5.594309123067282,
More information about the Scipy-dev