commit-gnuradio
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Commit-gnuradio] r11289 - in gnuradio/branches/developers/trondeau/pfb:


From: trondeau
Subject: [Commit-gnuradio] r11289 - in gnuradio/branches/developers/trondeau/pfb: gnuradio-core/src/lib/filter gnuradio-examples/python/pfb
Date: Thu, 25 Jun 2009 19:18:16 -0600 (MDT)

Author: trondeau
Date: 2009-06-25 19:18:16 -0600 (Thu, 25 Jun 2009)
New Revision: 11289

Added:
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
Removed:
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/channelize.py
Log:
Moving channelizer example to PFB examples directory.

Copied: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
 (from rev 11287, 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/channelize.py)
===================================================================
--- 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
                                (rev 0)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
        2009-06-26 01:18:16 UTC (rev 11289)
@@ -0,0 +1,110 @@
+#!/usr/bin/env python
+
+from gnuradio import gr
+import math
+import os
+import scipy, pylab
+from scipy import fftpack
+import time
+
+#print os.getpid()
+#raw_input()
+
+class pfb_top_block(gr.top_block):
+    def __init__(self):
+        gr.top_block.__init__(self)
+
+        self._N = 20000000
+        self._fs = 9000
+        self._Tmax = self._N * (1.0/self._fs)
+        self._M = 9
+        self._taps = gr.firdes.low_pass(1, self._fs, 800, 20)
+        fc = 200
+
+        tpc = math.ceil(float(len(self._taps)) /  float(self._M))
+
+        print "Number of taps:     ", len(self._taps)
+        print "Number of channels: ", self._M
+        print "Taps per channel:   ", tpc
+        
+        self.signals = list()
+        self.add = gr.add_cc()
+        freqs = [-4070, -3050, -2030, -1010, 10, 1020, 2040, 3060, 4080]
+        for i in xrange(len(freqs)):
+            self.signals.append(gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, 
freqs[i], 1))
+            self.connect(self.signals[i], (self.add,i))
+
+        self.head = gr.head(gr.sizeof_gr_complex, self._N)
+
+        self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._M)
+        self.pfb = gr.pfb_channelizer_ccf(self._M, self._taps)
+        self.v2s = gr.vector_to_streams(gr.sizeof_gr_complex, self._M)
+
+        self.snk_i = gr.vector_sink_c()
+
+        # Create a file sink for each of M output channels of the filter and 
connect it
+        self.snks = list()
+        for i in xrange(self._M):
+            self.connect((self.s2ss, i), (self.pfb, i))
+            self.snks.append(gr.vector_sink_c())
+            self.connect((self.v2s, i), self.snks[i])
+                             
+        # Connect the rest
+        #self.connect(self.add, self.head, self.pfb)
+        self.connect(self.add, self.head, self.s2ss)
+        self.connect(self.pfb, self.v2s)
+        self.connect(self.add, self.snk_i)
+
+def main():
+    tstart = time.time()
+    
+    tb = pfb_top_block()
+    tb.run()
+
+    tend = time.time()
+    print "Run time: %f" % (tend - tstart)
+
+    if 1:
+        fig1 = pylab.figure(1, figsize=(16,9))
+        fig2 = pylab.figure(2, figsize=(16,9))
+        
+        Ns = 1000
+        Ne = 10000
+        d = tb.snk_i.data()[Ns:Ne]
+        f_in = scipy.arange(-tb._fs/2.0, tb._fs/2.0, tb._fs/float(len(d)))
+        X_in = 10.0*scipy.log10(fftpack.fftshift(fftpack.fft(d, f_in.size)))
+        sp1_in = fig1.add_subplot(4, 3, 1)
+        p1_in = sp1_in.plot(f_in, X_in)
+        
+        t_in = scipy.arange(0, tb._Tmax, tb._Tmax/float(len(d)))
+        x_in = scipy.array(d)
+        sp2_in = fig2.add_subplot(4, 3, 1)
+        p2_in = sp2_in.plot(t_in, x_in.real, "b")
+        p2_in = sp2_in.plot(t_in, x_in.imag, "r")
+        
+        fs_o = tb._fs / tb._M
+        for i in xrange(len(tb.snks)):
+            # remove issues with the transients at the beginning
+            # also remove some corruption at the end of the stream
+            #    this is a bug, probably due to the corner cases
+            d = tb.snks[i].data()[Ns:Ne]
+            f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(len(d)))
+            x_o = 10.0*scipy.log10(fftpack.fftshift(fftpack.fft(d)))
+            sp1_o = fig1.add_subplot(4, 3, 2+i)
+            p1_o = sp1_o.plot(f_o, x_o)
+            
+            x_o = scipy.array(d)
+            t_o = scipy.arange(0, tb._Tmax, tb._Tmax/float(x_o.size))
+            sp2_o = fig2.add_subplot(4, 3, 2+i)
+            p2_o = sp2_o.plot(t_o, x_o.real, "b")
+            p2_o = sp2_o.plot(t_o, x_o.imag, "r")
+            
+        pylab.show()
+
+
+if __name__ == "__main__":
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+    


Property changes on: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
___________________________________________________________________
Added: svn:executable
   + *
Added: svn:mergeinfo
   + 





reply via email to

[Prev in Thread] Current Thread [Next in Thread]