[SciPy-dev] Question about Kaiser Implementation in firwin

Charles R Harris charlesr.harris at gmail.com
Sat Oct 4 04:40:53 EDT 2008


On Sat, Jul 15, 2006 at 10:50 PM, Travis Oliphant
<oliphant.travis at ieee.org>wrote:

> Buehler, Eric (AGRE) wrote:
> > Hello,
> >
> > However, the last line of the firwin function is causing me some
> > heartburn.
> > filter_design.py
> >
> > 1538    win = get_window(window,N,fftbins=1)
> > 1539    alpha = N//2
> > 1540    m = numpy.arange(0,N)
> > 1541    h = win*special.sinc(cutoff*(m-alpha))
> > 1542    return h / sum(h)
> >
> > Line 1542 of filter_design.py, "return h / sum(h)", normalizes the
> > function where it doesn't seem necessary, at least in the kaiser window
> > case.  Without the normalization, the kaiser window already returns a
> > value of 1 at the zero frequency point.  This normalization scales all
> > of the data, making the window difficult to use in the frequency domain.
> >
> > Can someone point me to the rationale for this line?  Looking at the
> > code, this seems to be a pretty recent change (within the last year/year
> > and a half).
> >
> >
> I'm not aware of if and when the change was made.   Was there a time
> when firwin did not have this normalization?
>
> The normalization is done so that the resulting filter has a 0dB gain at
> DC (which is the center of the pass-band).
>
> In other-words fft(h)[0] is approximately equal to 1.  This is usually
> what is desired as firwin returns "time-domain" filter coefficients.
> The return value of the function is not designed for use in the
> "frequency"-domain.  I'm not even sure what you mean by that in this
> context.
>
> The intended usage of the result of firwin is in a convolution:
>
> convolve(h, <mysignal>)
>

I almost always use area one. For looking at spectra and such it is best to
be able to integrate over a band in the frequency domain without the results
changing much. In particular, it is best to preserve the shape of continua.
This is also the best way to treat power spectra.

Chuck
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/scipy-dev/attachments/20081004/b7ddfcd5/attachment.html>


More information about the SciPy-Dev mailing list