diff options
author | Johnathan Corgan | 2009-10-29 06:52:53 -0700 |
---|---|---|
committer | Johnathan Corgan | 2009-10-29 06:52:53 -0700 |
commit | 8a0affcfb6154cadd1710e682fe09f040ed05a28 (patch) | |
tree | 680e797323aa598ee497f20fc4a249c4d5aeb83c /gnuradio-core/src | |
parent | 005f14ca07e66056bdc8e33a0cae1d461f5e1b9d (diff) | |
parent | 230e062e51d43f389520207cf147838c666a1f21 (diff) | |
download | gnuradio-8a0affcfb6154cadd1710e682fe09f040ed05a28.tar.gz gnuradio-8a0affcfb6154cadd1710e682fe09f040ed05a28.tar.bz2 gnuradio-8a0affcfb6154cadd1710e682fe09f040ed05a28.zip |
Merge branch 'flattopwindow' of http://gnuradio.org/git/jblum
Merge-fix: Remove debugging print
Merge-fix: Update copyrights
* 'flattopwindow' of http://gnuradio.org/git/jblum:
Added window option to wxgui fft and waterfall sink.
redid cos windows, added flattop and nuttall_cfd
Diffstat (limited to 'gnuradio-core/src')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py | 6 | ||||
-rw-r--r-- | gnuradio-core/src/python/gnuradio/window.py | 46 |
2 files changed, 22 insertions, 30 deletions
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py index 7ef40be40..200c4cfbe 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/logpwrfft.py @@ -28,7 +28,7 @@ class _logpwrfft_base(gr.hier_block2): Create a log10(abs(fft)) stream chain, with real or complex input. """ - def __init__(self, sample_rate, fft_size, ref_scale, frame_rate, avg_alpha, average): + def __init__(self, sample_rate, fft_size, ref_scale, frame_rate, avg_alpha, average, win=None): """ Create an log10(abs(fft)) stream chain. Provide access to the setting the filter and sample rate. @@ -38,6 +38,7 @@ class _logpwrfft_base(gr.hier_block2): @param frame_rate Output frame rate @param avg_alpha FFT averaging (over time) constant [0.0-1.0] @param average Whether to average [True, False] + @param win the window taps generation function """ gr.hier_block2.__init__(self, self._name, gr.io_signature(1, 1, self._item_size), # Input signature @@ -48,7 +49,8 @@ class _logpwrfft_base(gr.hier_block2): vec_rate=frame_rate, vec_len=fft_size) - fft_window = window.blackmanharris(fft_size) + if win is None: win = window.blackmanharris + fft_window = win(fft_size) fft = self._fft_block[0](fft_size, True, fft_window) window_power = sum(map(lambda x: x*x, fft_window)) diff --git a/gnuradio-core/src/python/gnuradio/window.py b/gnuradio-core/src/python/gnuradio/window.py index fb4a10675..e109a9892 100644 --- a/gnuradio-core/src/python/gnuradio/window.py +++ b/gnuradio-core/src/python/gnuradio/window.py @@ -1,5 +1,5 @@ # -# Copyright 2004,2005 Free Software Foundation, Inc. +# Copyright 2004,2005,2009 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -153,32 +153,6 @@ def riemann(fft_size): j -= 1 return window -def blackmanharris(fft_size): - a0 = 0.35875 - a1 = 0.48829 - a2 = 0.14128 - a3 = 0.01168 - window = [0 for i in range(fft_size)] - for index in xrange(fft_size): - window[index] = a0 - window[index] -= a1*math.cos(2.0*math.pi*(index+0.5)/(fft_size - 1)) - window[index] += a2*math.cos(4.0*math.pi*(index+0.5)/(fft_size - 1)) - window[index] -= a3*math.cos(6.0*math.pi*(index+0.5)/(fft_size - 1)) - return window - -def nuttall(fft_size): - a0 = 0.3635819 - a1 = 0.4891775 - a2 = 0.1365995 - a3 = 0.0106411 - window = [0 for i in range(fft_size)] - for index in xrange(fft_size): - window[index] = a0 - window[index] -= a1*math.cos(2.0*math.pi*(index+0.5)/(fft_size - 1)) - window[index] += a2*math.cos(4.0*math.pi*(index+0.5)/(fft_size - 1)) - window[index] -= a3*math.cos(6.0*math.pi*(index+0.5)/(fft_size - 1)) - return window - def kaiser(fft_size,beta): ibeta = 1.0/izero(beta) inm1 = 1.0/(fft_size) @@ -187,4 +161,20 @@ def kaiser(fft_size,beta): window[index] = izero(beta*math.sqrt(1.0 - (index * inm1)*(index * inm1))) * ibeta return window - +# Closure to generate functions to create cos windows + +def coswindow(coeffs): + def closure(fft_size): + window = [0] * fft_size + #print list(enumerate(coeffs)) + for w_index in range(fft_size): + for (c_index, coeff) in enumerate(coeffs): + window[w_index] += (-1)**c_index * coeff * math.cos(2.0*c_index*math.pi*(w_index+0.5)/(fft_size-1)) + return window + return closure + +blackmanharris = coswindow((0.35875,0.48829,0.14128,0.01168)) +nuttall = coswindow((0.3635819,0.4891775,0.1365995,0.0106411)) # Wikipedia calls this Blackman-Nuttall +nuttall_cfd = coswindow((0.355768,0.487396,0.144232,0.012604)) # Wikipedia calls this Nuttall, continuous first deriv +flattop = coswindow((1.0,1.93,1.29,0.388,0.032)) # Flat top window, coeffs from Wikipedia +rectangular = lambda fft_size: [1]*fft_size |