Question about Kaiser Implementation in firwin
Hello, I have been using the signal.firwin FIR design tool and I have a question about the implementation. Scipy-0.4.8 Numpy-0.9.6 I am generating a kaiser window with the following parameters: N = 128 Cutoff = ~4e7 width = .3 All of the special kaiser generation parameters in the function follow Oppenheim and Schafer well. Even the sinc function for linear phase is follows exactly. 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). Thanks, Eric Buehler eric <dot> buehler <at> smiths-aerospace <dot> com ****************************************** The information contained in, or attached to, this e-mail, may contain confidential information and is intended solely for the use of the individual or entity to whom they are addressed and may be subject to legal privilege. If you have received this e-mail in error you should notify the sender immediately by reply e-mail, delete the message from your system and notify your system manager. Please do not copy it for any purpose, or disclose its contents to any other person. The views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. The recipient should check this e-mail and any attachments for the presence of viruses. The company accepts no liability for any damage caused, directly or indirectly, by any virus transmitted in this email. ******************************************
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>) -Travis
On Sat, Jul 15, 2006 at 10:50 PM, Travis Oliphant <oliphant.travis@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
participants (3)
-
Buehler, Eric (AGRE)
-
Charles R Harris
-
Travis Oliphant