[SciPy-user] FIR Filters

Travis E. Oliphant oliphant at ee.byu.edu
Wed Feb 25 16:40:34 CST 2004

Bob.Cowdery at CGI-Europe.com wrote:
> I am trying to get a windowed FIR filter to use in fast convolution 
> filtering.
> I have tried using :
> signal.remez(2048,[300,3000],[1],Hz=44100)
> to generate a 2048 tap filter, which is what I have used previously in 
> Intel IPP. Firstly, this gives me an array full of QNAN errors. 

That is a lot of taps.  In theory remez should work, but I admit it has 
not been tested for so many taps.   And, the "bandpass" option can 
generate a lowpass filter by making the lower band 0.

Why are you doing convolution filtering with 2048 taps?   Why are you 
not using the FFT which should be much faster?

> Infact 
> the only time I don't get errors is by using a very small number of 
> taps, say 10. Various other values of taps fails to converge or gives 
> QNAN errors. With the 2048 taps it is also very, very slow (about 75 
> seconds on a 1.2GHz). The IPP implementation is sub-second. I don't know 
> if it's throwing an exception on every QNAN or quite what is hapenning.

I don't think IPP is using the remez algorithm for getting it's filter. 
    It's probably doing windowed filter design.

> I am also confused by not being able to specify a window type and I 
> really need lowpass not bandpass. I can see there is a function 
> get_window() but I don't know how this relates to an FIR filter when the 
> only other parameter is fftbins. Do I do something like tell it the 
> number of fftbins I want the filter to cover (I have 2048 bins of around 
> 10Hz each) then shift it to the correct part of the spectrum?

There is not currently an FIR-filter design program in SciPy.  One 
should be constructed as it is not hard to implement (of course making 
it generic with all the options you might want would take some time).

What kind of window are you currently using?

For your purposes this is what I would do:

w = fftfreq(2048,T)  # give frequency bins in Hz, T is sample spacing

myfilter = where((abs(w)< cutoff),1,0)  # cutoff is low-pass filter

h = ifft(myfilter) # ideal filter

beta = 11.7
myh = fftshift(h) * get_window(beta,2048)  # beta implies Kaiser Filter

Someday this will get wrapped up into a nice FIR filter design routine 
--- any suggestions on the interface that routine should take would be 

-Travis O.

> Any help appreciated.
> Bob
> Bob Cowdery
> CGI Senior Technical Architect
> +44(0)1438 791517
> Mobile: +44(0)7771 532138
> bob.cowdery at cgi-europe.com <mailto:bob.cowdery at cgi-europe.com>
> **** Confidentiality Notice **** Proprietary/Confidential
> Information belonging to CGI Group Inc. and its affiliates
> may be contained in this message. If you are not a recipient
> indicated or intended in this message (or responsible for
> delivery of this message to such person), or you think for
> any reason that this message may have been addressed to you
> in error, you may not use or copy or deliver this message
> to anyone else.  In such case, you should destroy this
> message and are asked to notify the sender by reply email.
> ------------------------------------------------------------------------
> _______________________________________________
> SciPy-user mailing list
> SciPy-user at scipy.net
> http://www.scipy.net/mailman/listinfo/scipy-user

More information about the SciPy-user mailing list