From 96a20bb09dc6b07b3d2651645e579dff6c3f3a45 Mon Sep 17 00:00:00 2001 From: Josh Blum Date: Tue, 23 Mar 2010 23:39:05 -0700 Subject: work on the string representations for parameters (large vectors could be too much to render, ie use truncation) --- grc/gui/Param.py | 15 +++++++++++++-- grc/python/Param.py | 32 ++++++++++++++++++++------------ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/grc/gui/Param.py b/grc/gui/Param.py index b3018dab2..7c00c1b67 100644 --- a/grc/gui/Param.py +++ b/grc/gui/Param.py @@ -1,5 +1,5 @@ """ -Copyright 2007, 2008, 2009 Free Software Foundation, Inc. +Copyright 2007, 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -135,10 +135,21 @@ PARAM_LABEL_MARKUP_TMPL="""\ $encode($param.get_name())""" TIP_MARKUP_TMPL="""\ +######################################## +#def truncate(string) + #set $max_len = 100 + #set $string = str($string) + #if len($string) > $max_len +$('%s...%s'%($string[:$max_len/2], $string[-$max_len/2:]))#slurp + #else +$string#slurp + #end if +#end def +######################################## Key: $param.get_key() Type: $param.get_type() #if $param.is_valid() -Value: $param.get_evaluated() +Value: $truncate($param.get_evaluated()) #elif len($param.get_error_messages()) == 1 Error: $(param.get_error_messages()[0]) #else diff --git a/grc/python/Param.py b/grc/python/Param.py index e04bc8fcb..6dd008d1d 100644 --- a/grc/python/Param.py +++ b/grc/python/Param.py @@ -1,5 +1,5 @@ """ -Copyright 2008, 2009 Free Software Foundation, Inc. +Copyright 2008, 2009, 2010 Free Software Foundation, Inc. This file is part of GNU Radio GNU Radio Companion is free software; you can redistribute it and/or @@ -108,7 +108,23 @@ class Param(_Param, _GUIParam): Get the repr (nice string format) for this param. @return the string representation """ - if not self.is_valid(): return self.get_value() + ################################################## + # truncate helper method + ################################################## + def _truncate(string, style=0): + max_len = max(27 - len(self.get_name()), 3) + if len(string) > max_len: + if style < 0: #front truncate + string = '...' + string[3-max_len:] + elif style == 0: #center truncate + string = string[:max_len/2 -3] + '...' + string[-max_len/2:] + elif style > 0: #rear truncate + string = string[:max_len-3] + '...' + return string + ################################################## + # simple conditions + ################################################## + if not self.is_valid(): return _truncate(self.get_value()) if self.get_value() in self.get_option_keys(): return self.get_option(self.get_value()).get_name() ################################################## # display logic for numbers @@ -126,7 +142,6 @@ class Param(_Param, _GUIParam): # split up formatting by type ################################################## truncate = 0 #default center truncate - max_len = max(27 - len(self.get_name()), 3) e = self.get_evaluated() t = self.get_type() if isinstance(e, bool): return str(e) @@ -141,16 +156,9 @@ class Param(_Param, _GUIParam): truncate = -1 else: dt_str = str(e) #other types ################################################## - # truncate + # done ################################################## - if len(dt_str) > max_len: - if truncate < 0: #front truncate - dt_str = '...' + dt_str[3-max_len:] - elif truncate == 0: #center truncate - dt_str = dt_str[:max_len/2 -3] + '...' + dt_str[-max_len/2:] - elif truncate > 0: #rear truncate - dt_str = dt_str[:max_len-3] + '...' - return dt_str + return _truncate(dt_str, truncate) def get_input(self, *args, **kwargs): if self.get_type() in ('file_open', 'file_save'): return FileParam(self, *args, **kwargs) -- cgit From e06d290279803c47bff2331859d6ad4e68236a13 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 7 Apr 2010 18:25:46 -0400 Subject: Opening up channelizer to have different sampling rates out. This first pass produces the correct output for oversampling_rate = 1. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 51 +++++++++++++++++++--- .../src/lib/filter/gr_pfb_channelizer_ccf.h | 12 +++-- .../src/lib/filter/gr_pfb_channelizer_ccf.i | 8 ++-- .../python/gnuradio/blks2impl/pfb_channelizer.py | 8 ++-- 4 files changed, 62 insertions(+), 17 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index 7e34551c8..4ba073efd 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -33,18 +33,21 @@ #include gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps) + const std::vector &taps, + float oversample_rate) { - return gr_pfb_channelizer_ccf_sptr (new gr_pfb_channelizer_ccf (numchans, taps)); + return gr_pfb_channelizer_ccf_sptr (new gr_pfb_channelizer_ccf (numchans, taps, + oversample_rate)); } gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps) + const std::vector &taps, + float oversample_rate) : gr_sync_block ("pfb_channelizer_ccf", gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))), - d_updated (false) + d_updated (false), d_oversample_rate(oversample_rate) { d_numchans = numchans; d_filters = std::vector(d_numchans); @@ -133,7 +136,39 @@ gr_pfb_channelizer_ccf::work (int noutput_items, return 0; // history requirements may have changed. } - for(int i = 0; i < noutput_items; i++) { + int M = d_oversample_rate; + int N = d_numchans; + int r = N / M; + + int n=0, i=0, j=0; + + printf("\nnoutput_items = %d\n", noutput_items); + printf("N = %d M = %d r = %d\n", N, M, r); + + //for(int n = 1; n < noutput_items; n++) { + while(n < noutput_items) { + j = 0; + i = (i + r - 1) % N; + //printf("i = %d i >= 0 n = %d\n", i, n); + while(i >= 0) { + in = (gr_complex*)input_items[j]; + d_fft->get_inbuf()[i] = d_filters[i]->filter(&in[n]); + j++; + i--; + } + + i = N; + //printf("i = %d r = %d i >= r\n", i, r); + while(i > r) { + i--; + in = (gr_complex*)input_items[j]; + d_fft->get_inbuf()[i] = d_filters[i]->filter(&in[n-1]); + j++; + } + + n += (i+r) >= N; + + /* // Move through filters from bottom to top for(int j = d_numchans-1; j >= 0; j--) { // Take in the items from the first input stream to d_numchans @@ -142,10 +177,12 @@ gr_pfb_channelizer_ccf::work (int noutput_items, // Filter current input stream from bottom filter to top d_fft->get_inbuf()[j] = d_filters[j]->filter(&in[i]); } + */ // despin through FFT d_fft->execute(); - memcpy(&out[d_numchans*i], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); + memcpy(&out[d_numchans*n], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); + //memcpy(&out[d_numchans*i], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); } return noutput_items; diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index b2e67e817..c73300459 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -29,7 +29,8 @@ class gr_pfb_channelizer_ccf; typedef boost::shared_ptr gr_pfb_channelizer_ccf_sptr; gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps); + const std::vector &taps, + float oversample_rate=1); class gr_fir_ccf; class gri_fft_complex; @@ -105,7 +106,8 @@ class gr_pfb_channelizer_ccf : public gr_sync_block * \param taps (vector/list of floats) The prototype filter to populate the filterbank. */ friend gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps); + const std::vector &taps, + float oversample_rate); std::vector d_filters; std::vector< std::vector > d_taps; @@ -113,6 +115,7 @@ class gr_pfb_channelizer_ccf : public gr_sync_block unsigned int d_numchans; unsigned int d_taps_per_filter; bool d_updated; + float d_oversample_rate; /*! * Build the polyphase filterbank decimator. @@ -120,7 +123,8 @@ class gr_pfb_channelizer_ccf : public gr_sync_block * \param taps (vector/list of floats) The prototype filter to populate the filterbank. */ gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps); + const std::vector &taps, + float oversample_rate); public: ~gr_pfb_channelizer_ccf (); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i index 4bef90e22..d9c4581a2 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i @@ -1,6 +1,6 @@ /* -*- c++ -*- */ /* - * Copyright 2009 Free Software Foundation, Inc. + * Copyright 2009,2010 Free Software Foundation, Inc. * * This file is part of GNU Radio * @@ -23,13 +23,15 @@ GR_SWIG_BLOCK_MAGIC(gr,pfb_channelizer_ccf); gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps); + const std::vector &taps, + float oversample_rate=1); class gr_pfb_channelizer_ccf : public gr_sync_block { private: gr_pfb_channelizer_ccf (unsigned int numchans, - const std::vector &taps); + const std::vector &taps, + float oversample_rate); public: ~gr_pfb_channelizer_ccf (); diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py index c45ae4d1a..a479ed48e 100644 --- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py +++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py @@ -1,6 +1,6 @@ #!/usr/bin/env python # -# Copyright 2009 Free Software Foundation, Inc. +# Copyright 2009,2010 Free Software Foundation, Inc. # # This file is part of GNU Radio # @@ -29,16 +29,18 @@ class pfb_channelizer_ccf(gr.hier_block2): This simplifies the interface by allowing a single input stream to connect to this block. It will then output a stream for each channel. ''' - def __init__(self, numchans, taps): + def __init__(self, numchans, taps, oversample_rate=1): gr.hier_block2.__init__(self, "pfb_channelizer_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature gr.io_signature(numchans, numchans, gr.sizeof_gr_complex)) # Output signature self._numchans = numchans self._taps = taps + self._oversample_rate = oversample_rate self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._numchans) - self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps) + self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps, + self._oversample_rate) self.v2s = gr.vector_to_streams(gr.sizeof_gr_complex, self._numchans) self.connect(self, self.s2ss) -- cgit From a88f6c0ab090c2d22707564fbd6db45a85567c59 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Apr 2010 00:37:03 -0400 Subject: Working version of channelizer allowing an integer multiple of the sampling rate out. There are two versions of the code in here with the second way being more general and efficient. This one should be more extendable to allowing rational ratio output sampling rates. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 98 +++++++++++++++------- .../src/lib/filter/gr_pfb_channelizer_ccf.h | 4 +- .../src/lib/filter/gr_pfb_channelizer_ccf.i | 2 +- 3 files changed, 71 insertions(+), 33 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index 4ba073efd..e1ab1ffee 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -44,9 +44,10 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, const std::vector &taps, float oversample_rate) - : gr_sync_block ("pfb_channelizer_ccf", - gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), - gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))), + : gr_sync_interpolator ("pfb_channelizer_ccf", + gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), + gr_make_io_signature (1, 1, numchans*sizeof(gr_complex)), + oversample_rate), d_updated (false), d_oversample_rate(oversample_rate) { d_numchans = numchans; @@ -136,54 +137,91 @@ gr_pfb_channelizer_ccf::work (int noutput_items, return 0; // history requirements may have changed. } +#if 0 + int M = d_numchans; + int N = d_oversample_rate; + int lastidx = 0, i = 1, k = 0, m = 0, n = 0; + + int *idx = new int[M]; + for(k = 0; k < M; k++) + idx[k] = 0; + + while(i <= noutput_items/N) { + unsigned int x = 0; + unsigned int y = 0; + for(n = N-1; n >= 0; n--) { + for(k = 0; k < M/N; k++) + idx[(lastidx + k) % M]++; + lastidx = (lastidx + M/N) % M; + + x += M/N; + y = M/N; + for(m = 0; m < M; m++) { + in = (gr_complex*)input_items[m]; + + x = (M + x - 1) % M; + y = (M + y - 1) % M; + + d_fft->get_inbuf()[y] = d_filters[x]->filter(&in[idx[m]]); + } + + d_fft->execute(); + memcpy(out, d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); + out += d_numchans; + } + i++; + } + +#else + int M = d_oversample_rate; int N = d_numchans; int r = N / M; - int n=0, i=0, j=0; - - printf("\nnoutput_items = %d\n", noutput_items); - printf("N = %d M = %d r = %d\n", N, M, r); + int n=1, i=-1, j=0, last; + //int state = 0; - //for(int n = 1; n < noutput_items; n++) { - while(n < noutput_items) { + // Although the filters change, we use this look up table + // to set the index of the FFT input buffer, which equivalently + // performs the FFT shift operation on every other turn. + int *idxlut = new int[N]; + for(int ii = 0; ii < N; ii++) { + idxlut[ii] = N - ((ii + r) % N) - 1; + } + + while(n <= noutput_items/M) { j = 0; - i = (i + r - 1) % N; - //printf("i = %d i >= 0 n = %d\n", i, n); + i = (i + r) % N; + last = i; while(i >= 0) { in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[i] = d_filters[i]->filter(&in[n]); + //d_fft->get_inbuf()[(i + state*r) % N] = d_filters[i]->filter(&in[n]); + d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n]); j++; i--; } - i = N; - //printf("i = %d r = %d i >= r\n", i, r); - while(i > r) { - i--; + i = N-1; + while(i > last) { in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[i] = d_filters[i]->filter(&in[n-1]); + //d_fft->get_inbuf()[(i + state*r) % N] = d_filters[i]->filter(&in[n-1]); + d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n-1]); j++; + i--; } n += (i+r) >= N; - - /* - // Move through filters from bottom to top - for(int j = d_numchans-1; j >= 0; j--) { - // Take in the items from the first input stream to d_numchans - in = (gr_complex*)input_items[d_numchans - 1 - j]; - - // Filter current input stream from bottom filter to top - d_fft->get_inbuf()[j] = d_filters[j]->filter(&in[i]); - } - */ + //state ^= 1; // despin through FFT d_fft->execute(); - memcpy(&out[d_numchans*n], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); - //memcpy(&out[d_numchans*i], d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); + memcpy(out, d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); + out += d_numchans; } + delete [] idxlut; + +#endif + return noutput_items; } diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index c73300459..359cd0438 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -24,7 +24,7 @@ #ifndef INCLUDED_GR_PFB_CHANNELIZER_CCF_H #define INCLUDED_GR_PFB_CHANNELIZER_CCF_H -#include +#include class gr_pfb_channelizer_ccf; typedef boost::shared_ptr gr_pfb_channelizer_ccf_sptr; @@ -97,7 +97,7 @@ class gri_fft_complex; * */ -class gr_pfb_channelizer_ccf : public gr_sync_block +class gr_pfb_channelizer_ccf : public gr_sync_interpolator { private: /*! diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i index d9c4581a2..1d2dcb73a 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i @@ -26,7 +26,7 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector &taps, float oversample_rate=1); -class gr_pfb_channelizer_ccf : public gr_sync_block +class gr_pfb_channelizer_ccf : public gr_sync_interpolator { private: gr_pfb_channelizer_ccf (unsigned int numchans, -- cgit From 520e64c211324ef32dabe66fa492825fe5c3eda1 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Apr 2010 00:39:55 -0400 Subject: Removing other version of code for different sample rates. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 39 ---------------------- 1 file changed, 39 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index e1ab1ffee..5ac5c2a7f 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -137,43 +137,6 @@ gr_pfb_channelizer_ccf::work (int noutput_items, return 0; // history requirements may have changed. } -#if 0 - int M = d_numchans; - int N = d_oversample_rate; - int lastidx = 0, i = 1, k = 0, m = 0, n = 0; - - int *idx = new int[M]; - for(k = 0; k < M; k++) - idx[k] = 0; - - while(i <= noutput_items/N) { - unsigned int x = 0; - unsigned int y = 0; - for(n = N-1; n >= 0; n--) { - for(k = 0; k < M/N; k++) - idx[(lastidx + k) % M]++; - lastidx = (lastidx + M/N) % M; - - x += M/N; - y = M/N; - for(m = 0; m < M; m++) { - in = (gr_complex*)input_items[m]; - - x = (M + x - 1) % M; - y = (M + y - 1) % M; - - d_fft->get_inbuf()[y] = d_filters[x]->filter(&in[idx[m]]); - } - - d_fft->execute(); - memcpy(out, d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); - out += d_numchans; - } - i++; - } - -#else - int M = d_oversample_rate; int N = d_numchans; int r = N / M; @@ -221,7 +184,5 @@ gr_pfb_channelizer_ccf::work (int noutput_items, delete [] idxlut; -#endif - return noutput_items; } -- cgit From 08c3b8fe72915e30bc62d0d944640a41c5315e8c Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Apr 2010 00:40:36 -0400 Subject: Every other time through the channelizer, the FFT input buffer must be flipped. The commented code removed in this checkin does that through a calculation in the loops, but the way the filter assignment works with this code, the flip is done by keeping the indexing static, so a look up table works and is slightly faster. --- gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index 5ac5c2a7f..f0fd33a88 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -142,7 +142,6 @@ gr_pfb_channelizer_ccf::work (int noutput_items, int r = N / M; int n=1, i=-1, j=0, last; - //int state = 0; // Although the filters change, we use this look up table // to set the index of the FFT input buffer, which equivalently @@ -158,7 +157,6 @@ gr_pfb_channelizer_ccf::work (int noutput_items, last = i; while(i >= 0) { in = (gr_complex*)input_items[j]; - //d_fft->get_inbuf()[(i + state*r) % N] = d_filters[i]->filter(&in[n]); d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n]); j++; i--; @@ -167,14 +165,12 @@ gr_pfb_channelizer_ccf::work (int noutput_items, i = N-1; while(i > last) { in = (gr_complex*)input_items[j]; - //d_fft->get_inbuf()[(i + state*r) % N] = d_filters[i]->filter(&in[n-1]); d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n-1]); j++; i--; } n += (i+r) >= N; - //state ^= 1; // despin through FFT d_fft->execute(); -- cgit From 69c6a0739f4df46d49e3ed4c151f99f8eca2a5de Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 12 Apr 2010 17:28:39 -0400 Subject: Moving towards gr_block implementation to enable non-integer output rates. Also, cleaning up a bit wrt class members. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 45 ++++++++++++---------- .../src/lib/filter/gr_pfb_channelizer_ccf.h | 20 +++++----- .../src/lib/filter/gr_pfb_channelizer_ccf.i | 2 +- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index f0fd33a88..ba22af99a 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -44,13 +44,11 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, const std::vector &taps, float oversample_rate) - : gr_sync_interpolator ("pfb_channelizer_ccf", - gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), - gr_make_io_signature (1, 1, numchans*sizeof(gr_complex)), - oversample_rate), - d_updated (false), d_oversample_rate(oversample_rate) + : gr_block ("pfb_channelizer_ccf", + gr_make_io_signature (numchans, numchans, sizeof(gr_complex)), + gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))), + d_updated (false), d_numchans(numchans), d_oversample_rate(oversample_rate) { - d_numchans = numchans; d_filters = std::vector(d_numchans); // Create an FIR filter for each channel and zero out the taps @@ -64,10 +62,23 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, // Create the FFT to handle the output de-spinning of the channels d_fft = new gri_fft_complex (d_numchans, false); + + // Although the filters change, we use this look up table + // to set the index of the FFT input buffer, which equivalently + // performs the FFT shift operation on every other turn. + int r = d_numchans / d_oversample_rate; + d_idxlut = new int[d_numchans]; + for(int i = 0; i < d_numchans; i++) { + d_idxlut[i] = d_numchans - ((i + r) % d_numchans) - 1; + } + + set_output_multiple(d_oversample_rate); } gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf () { + delete [] d_idxlut; + for(unsigned int i = 0; i < d_numchans; i++) { delete d_filters[i]; } @@ -125,9 +136,10 @@ gr_pfb_channelizer_ccf::print_taps() int -gr_pfb_channelizer_ccf::work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items) +gr_pfb_channelizer_ccf::general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items) { gr_complex *in = (gr_complex *) input_items[0]; gr_complex *out = (gr_complex *) output_items[0]; @@ -143,21 +155,13 @@ gr_pfb_channelizer_ccf::work (int noutput_items, int n=1, i=-1, j=0, last; - // Although the filters change, we use this look up table - // to set the index of the FFT input buffer, which equivalently - // performs the FFT shift operation on every other turn. - int *idxlut = new int[N]; - for(int ii = 0; ii < N; ii++) { - idxlut[ii] = N - ((ii + r) % N) - 1; - } - while(n <= noutput_items/M) { j = 0; i = (i + r) % N; last = i; while(i >= 0) { in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n]); + d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n]); j++; i--; } @@ -165,7 +169,7 @@ gr_pfb_channelizer_ccf::work (int noutput_items, i = N-1; while(i > last) { in = (gr_complex*)input_items[j]; - d_fft->get_inbuf()[idxlut[j]] = d_filters[i]->filter(&in[n-1]); + d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n-1]); j++; i--; } @@ -178,7 +182,6 @@ gr_pfb_channelizer_ccf::work (int noutput_items, out += d_numchans; } - delete [] idxlut; - + consume_each(noutput_items/M); return noutput_items; } diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index 359cd0438..1f9189e28 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -24,7 +24,7 @@ #ifndef INCLUDED_GR_PFB_CHANNELIZER_CCF_H #define INCLUDED_GR_PFB_CHANNELIZER_CCF_H -#include +#include class gr_pfb_channelizer_ccf; typedef boost::shared_ptr gr_pfb_channelizer_ccf_sptr; @@ -97,7 +97,7 @@ class gri_fft_complex; * */ -class gr_pfb_channelizer_ccf : public gr_sync_interpolator +class gr_pfb_channelizer_ccf : public gr_block { private: /*! @@ -109,13 +109,14 @@ class gr_pfb_channelizer_ccf : public gr_sync_interpolator const std::vector &taps, float oversample_rate); + bool d_updated; + unsigned int d_numchans; + float d_oversample_rate; std::vector d_filters; std::vector< std::vector > d_taps; - gri_fft_complex *d_fft; - unsigned int d_numchans; unsigned int d_taps_per_filter; - bool d_updated; - float d_oversample_rate; + gri_fft_complex *d_fft; + int *d_idxlut; /*! * Build the polyphase filterbank decimator. @@ -140,9 +141,10 @@ public: */ void print_taps(); - int work (int noutput_items, - gr_vector_const_void_star &input_items, - gr_vector_void_star &output_items); + int general_work (int noutput_items, + gr_vector_int &ninput_items, + gr_vector_const_void_star &input_items, + gr_vector_void_star &output_items); }; #endif diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i index 1d2dcb73a..63e3e0fe6 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.i @@ -26,7 +26,7 @@ gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector &taps, float oversample_rate=1); -class gr_pfb_channelizer_ccf : public gr_sync_interpolator +class gr_pfb_channelizer_ccf : public gr_block { private: gr_pfb_channelizer_ccf (unsigned int numchans, -- cgit From f1cda009dfd5edd7e1e234b97a4456076aebac0a Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 12 Apr 2010 20:45:10 -0400 Subject: Channelizer can now produce any rational ratio of the sample rate in [fs/N, fs] where fs is the input sample rate and N is the number of channels. The ratios work out to be N/i for i in [1, N]. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 22 ++++++++++++++-------- .../src/lib/filter/gr_pfb_channelizer_ccf.h | 1 + 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index ba22af99a..1296c71f3 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -66,13 +66,18 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, // Although the filters change, we use this look up table // to set the index of the FFT input buffer, which equivalently // performs the FFT shift operation on every other turn. - int r = d_numchans / d_oversample_rate; + int r = (int)rintf(d_numchans / d_oversample_rate); d_idxlut = new int[d_numchans]; for(int i = 0; i < d_numchans; i++) { d_idxlut[i] = d_numchans - ((i + r) % d_numchans) - 1; } - set_output_multiple(d_oversample_rate); + // Calculate the number of filtering rounds to do to evenly + // align the input vectors with the output channels + d_output_multiple = 1; + while((d_output_multiple * r) % d_numchans != 0) + d_output_multiple++; + set_output_multiple(d_output_multiple); } gr_pfb_channelizer_ccf::~gr_pfb_channelizer_ccf () @@ -149,13 +154,14 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, return 0; // history requirements may have changed. } - int M = d_oversample_rate; + float M = d_oversample_rate; int N = d_numchans; - int r = N / M; + int r = (int)rintf(N / M); - int n=1, i=-1, j=0, last; + int toconsume = (int)rintf(noutput_items/M); - while(n <= noutput_items/M) { + int n=1, i=-1, j=0, last; + while(n <= toconsume) { j = 0; i = (i + r) % N; last = i; @@ -181,7 +187,7 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, memcpy(out, d_fft->get_outbuf(), d_numchans*sizeof(gr_complex)); out += d_numchans; } - - consume_each(noutput_items/M); + + consume_each(toconsume); return noutput_items; } diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index 1f9189e28..7e71ff292 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -117,6 +117,7 @@ class gr_pfb_channelizer_ccf : public gr_block unsigned int d_taps_per_filter; gri_fft_complex *d_fft; int *d_idxlut; + int d_output_multiple; /*! * Build the polyphase filterbank decimator. -- cgit From 1e5d21b4ff14e19593909092ea67593ba0d4c086 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 12 Apr 2010 20:50:56 -0400 Subject: Reworking variables to avoid recalculations/assignments. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 19 +++++++------------ gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h | 1 + 2 files changed, 8 insertions(+), 12 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index 1296c71f3..e13a933ea 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -66,16 +66,16 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, // Although the filters change, we use this look up table // to set the index of the FFT input buffer, which equivalently // performs the FFT shift operation on every other turn. - int r = (int)rintf(d_numchans / d_oversample_rate); + d_rate_ratio = (int)rintf(d_numchans / d_oversample_rate); d_idxlut = new int[d_numchans]; for(int i = 0; i < d_numchans; i++) { - d_idxlut[i] = d_numchans - ((i + r) % d_numchans) - 1; + d_idxlut[i] = d_numchans - ((i + d_rate_ratio) % d_numchans) - 1; } // Calculate the number of filtering rounds to do to evenly // align the input vectors with the output channels d_output_multiple = 1; - while((d_output_multiple * r) % d_numchans != 0) + while((d_output_multiple * d_rate_ratio) % d_numchans != 0) d_output_multiple++; set_output_multiple(d_output_multiple); } @@ -154,16 +154,11 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, return 0; // history requirements may have changed. } - float M = d_oversample_rate; - int N = d_numchans; - int r = (int)rintf(N / M); - - int toconsume = (int)rintf(noutput_items/M); - int n=1, i=-1, j=0, last; + int toconsume = (int)rintf(noutput_items/d_oversample_rate); while(n <= toconsume) { j = 0; - i = (i + r) % N; + i = (i + d_rate_ratio) % d_numchans; last = i; while(i >= 0) { in = (gr_complex*)input_items[j]; @@ -172,7 +167,7 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, i--; } - i = N-1; + i = d_numchans-1; while(i > last) { in = (gr_complex*)input_items[j]; d_fft->get_inbuf()[d_idxlut[j]] = d_filters[i]->filter(&in[n-1]); @@ -180,7 +175,7 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, i--; } - n += (i+r) >= N; + n += (i+d_rate_ratio) >= d_numchans; // despin through FFT d_fft->execute(); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index 7e71ff292..e33e1938e 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -117,6 +117,7 @@ class gr_pfb_channelizer_ccf : public gr_block unsigned int d_taps_per_filter; gri_fft_complex *d_fft; int *d_idxlut; + int d_rate_ratio; int d_output_multiple; /*! -- cgit From 9600dff866e193391c4df8f5e3f9bd65f3392d26 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 12 Apr 2010 21:22:20 -0400 Subject: The oversampling rate can be only a few values as defined by the number of channels and input sample rate. This now checks to make sure the user-specified rate is valid. Also added some documentation to describe the oversample rate parameter. --- .../src/lib/filter/gr_pfb_channelizer_ccf.cc | 15 +++++++++++-- .../src/lib/filter/gr_pfb_channelizer_ccf.h | 25 ++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index e13a933ea..824a78dd9 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -49,6 +49,17 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, gr_make_io_signature (1, 1, numchans*sizeof(gr_complex))), d_updated (false), d_numchans(numchans), d_oversample_rate(oversample_rate) { + // The over sampling rate must be rationally related to the number of channels + // in that it must be N/i for i in [1,N], which gives an outputsample rate + // of [fs/N, fs] where fs is the input sample rate. + // This tests the specified input sample rate to see if it conforms to this + // requirement within a few significant figures. + double intp = 0; + double x = (10000.0*rint(numchans / oversample_rate)) / 10000.0; + double fltp = modf(numchans / oversample_rate, &intp); + if(fltp != 0.0) + throw std::invalid_argument("gr_pfb_channelizer: oversample rate must be N/i for i in [1, N]"); + d_filters = std::vector(d_numchans); // Create an FIR filter for each channel and zero out the taps @@ -68,7 +79,7 @@ gr_pfb_channelizer_ccf::gr_pfb_channelizer_ccf (unsigned int numchans, // performs the FFT shift operation on every other turn. d_rate_ratio = (int)rintf(d_numchans / d_oversample_rate); d_idxlut = new int[d_numchans]; - for(int i = 0; i < d_numchans; i++) { + for(unsigned int i = 0; i < d_numchans; i++) { d_idxlut[i] = d_numchans - ((i + d_rate_ratio) % d_numchans) - 1; } @@ -175,7 +186,7 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, i--; } - n += (i+d_rate_ratio) >= d_numchans; + n += (i+d_rate_ratio) >= (int)d_numchans; // despin through FFT d_fft->execute(); diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h index e33e1938e..d56ccdbc6 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.h @@ -89,6 +89,19 @@ class gri_fft_complex; * self._taps = gr.firdes.low_pass_2(1, fs, BW, TB, * attenuation_dB=ATT, window=gr.firdes.WIN_BLACKMAN_hARRIS) * + * The filter output can also be overs ampled. The over sampling rate + * is the ratio of the the actual output sampling rate to the normal + * output sampling rate. It must be rationally related to the number + * of channels as N/i for i in [1,N], which gives an outputsample rate + * of [fs/N, fs] where fs is the input sample rate and N is the number + * of channels. + * + * For example, for 6 channels with fs = 6000 Hz, the normal rate is + * 6000/6 = 1000 Hz. Allowable oversampling rates are 6/6, 6/5, 6/4, + * 6/3, 6/2, and 6/1 where the output sample rate of a 6/1 oversample + * ratio is 6000 Hz, or 6 times the normal 1000 Hz. A rate of 6/5 = 1.2, + * so the output rate would be 1200 Hz. + * * The theory behind this block can be found in Chapter 6 of * the following book. * @@ -104,6 +117,18 @@ class gr_pfb_channelizer_ccf : public gr_block * Build the polyphase filterbank decimator. * \param numchans (unsigned integer) Specifies the number of channels M * \param taps (vector/list of floats) The prototype filter to populate the filterbank. + * \param oversample_rate (float) The over sampling rate is the ratio of the the actual + * output sampling rate to the normal output sampling rate. + * It must be rationally related to the number of channels + * as N/i for i in [1,N], which gives an outputsample rate + * of [fs/N, fs] where fs is the input sample rate and N is + * the number of channels. + * + * For example, for 6 channels with fs = 6000 Hz, the normal + * rate is 6000/6 = 1000 Hz. Allowable oversampling rates + * are 6/6, 6/5, 6/4, 6/3, 6/2, and 6/1 where the output + * sample rate of a 6/1 oversample ratio is 6000 Hz, or + * 6 times the normal 1000 Hz. */ friend gr_pfb_channelizer_ccf_sptr gr_make_pfb_channelizer_ccf (unsigned int numchans, const std::vector &taps, -- cgit From da8ebdb30509c07718b10b642e2b4250aa45b1d8 Mon Sep 17 00:00:00 2001 From: Eric Blossom Date: Wed, 14 Apr 2010 13:55:46 -0700 Subject: Add pid for ThinkRF --- usrp/firmware/include/usrp_ids.h | 1 + 1 file changed, 1 insertion(+) diff --git a/usrp/firmware/include/usrp_ids.h b/usrp/firmware/include/usrp_ids.h index dd5daed01..4152600bd 100644 --- a/usrp/firmware/include/usrp_ids.h +++ b/usrp/firmware/include/usrp_ids.h @@ -55,6 +55,7 @@ #define USB_PID_FSF_BDALE_8 0x0012 // Bdale Garbee #define USB_PID_FSF_BDALE_9 0x0013 // Bdale Garbee #define USB_PID_FSF_HPSDR_HERMES 0x0014 // HPSDR Hermes +#define USB_PID_FSF_THINKRF 0x0015 // Catalin Patulea #define USB_PID_FSF_LBNL_UXO 0x0018 // http://recycle.lbl.gov/~ldoolitt/uxo/ -- cgit From 75e55b8112db3de830401270ea4e21b6f636191b Mon Sep 17 00:00:00 2001 From: Jason Abele Date: Wed, 14 Apr 2010 15:07:24 -0700 Subject: Increase sleep to prevent eeprom problems --- usrp/firmware/src/common/build_eeprom.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usrp/firmware/src/common/build_eeprom.py b/usrp/firmware/src/common/build_eeprom.py index ed9bb56a4..d73cbbc4f 100755 --- a/usrp/firmware/src/common/build_eeprom.py +++ b/usrp/firmware/src/common/build_eeprom.py @@ -146,7 +146,7 @@ def build_shell_script (out, ihx_filename, rev, prefix): out.write ('#!/bin/sh\n') out.write ('usrper -x load_firmware ' + prefix + '/share/usrp/rev%d/std.ihx\n' % rev) - out.write ('sleep 1\n') + out.write ('sleep 2\n') # print "len(image) =", len(image) @@ -161,7 +161,7 @@ def build_shell_script (out, ihx_filename, rev, prefix): (i2c_addr, rom_addr, ''.join (hex_image[0:l]))) hex_image = hex_image[l:] rom_addr = rom_addr + l - out.write ('sleep 1\n') + out.write ('sleep 2\n') if __name__ == '__main__': usage = "usage: %prog -p PREFIX -r REV [options] bootfile.ihx" -- cgit From 7f217fbf1579bd4a37b633d29c15b929bfe8b9d5 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 14 Apr 2010 22:20:00 -0400 Subject: Fixes small bug by handling boundaries properly. --- gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index 824a78dd9..68f3db620 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -165,9 +165,9 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, return 0; // history requirements may have changed. } - int n=1, i=-1, j=0, last; + int n=0, i=-1, j=0, last; int toconsume = (int)rintf(noutput_items/d_oversample_rate); - while(n <= toconsume) { + while(n < toconsume) { j = 0; i = (i + d_rate_ratio) % d_numchans; last = i; -- cgit From 2a2e808f56df2a0bf1704aa20b03d0ed4f5bdd5e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 15 Apr 2010 00:32:14 -0400 Subject: Nevermind that last checkin. THIS is the right answer that doesn't have us possibly looking back at input item -1. --- gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc index 68f3db620..5fda47880 100644 --- a/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc +++ b/gnuradio-core/src/lib/filter/gr_pfb_channelizer_ccf.cc @@ -132,7 +132,7 @@ gr_pfb_channelizer_ccf::set_taps (const std::vector &taps) } // Set the history to ensure enough input items for each filter - set_history (d_taps_per_filter); + set_history (d_taps_per_filter+1); d_updated = true; } @@ -165,9 +165,9 @@ gr_pfb_channelizer_ccf::general_work (int noutput_items, return 0; // history requirements may have changed. } - int n=0, i=-1, j=0, last; + int n=1, i=-1, j=0, last; int toconsume = (int)rintf(noutput_items/d_oversample_rate); - while(n < toconsume) { + while(n <= toconsume) { j = 0; i = (i + d_rate_ratio) % d_numchans; last = i; -- cgit From 434c113106e0f18b08392e32829015ffdd866513 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Thu, 15 Apr 2010 00:34:05 -0400 Subject: New matplotlib does the fftshift for us when doing mlab.psd. This makes the figures make sense again. --- gnuradio-examples/python/pfb/channelize.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gnuradio-examples/python/pfb/channelize.py b/gnuradio-examples/python/pfb/channelize.py index bc83fae27..27d87e558 100755 --- a/gnuradio-examples/python/pfb/channelize.py +++ b/gnuradio-examples/python/pfb/channelize.py @@ -101,7 +101,7 @@ def main(): X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs, window = lambda d: d*winfunc(fftlen), scale_by_freq=True) - X_in = 10.0*scipy.log10(abs(fftpack.fftshift(X))) + X_in = 10.0*scipy.log10(abs(X)) f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size)) pin_f = spin_f.plot(f_in, X_in, "b") spin_f.set_xlim([min(f_in), max(f_in)+1]) @@ -144,7 +144,7 @@ def main(): X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o, window = lambda d: d*winfunc(fftlen), scale_by_freq=True) - X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X))) + X_o = 10.0*scipy.log10(abs(X)) f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(X_o.size)) p2_f = sp1_f.plot(f_o, X_o, "b") sp1_f.set_xlim([min(f_o), max(f_o)+1]) -- cgit