commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11286 - gnuradio/branches/developers/trondeau/pfb/gnu


From: trondeau
Subject: [Commit-gnuradio] r11286 - gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter
Date: Thu, 25 Jun 2009 18:49:50 -0600 (MDT)

Author: trondeau
Date: 2009-06-25 18:49:50 -0600 (Thu, 25 Jun 2009)
New Revision: 11286

Modified:
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/channelize.py
Log:
Example of using channelizer with multiple input streams; plots the data with 
matplotlib.

Modified: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/channelize.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/channelize.py
        2009-06-26 00:47:18 UTC (rev 11285)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-core/src/lib/filter/channelize.py
        2009-06-26 00:49:50 UTC (rev 11286)
@@ -5,6 +5,7 @@
 import os
 import scipy, pylab
 from scipy import fftpack
+import time
 
 #print os.getpid()
 #raw_input()
@@ -13,7 +14,7 @@
     def __init__(self):
         gr.top_block.__init__(self)
 
-        self._N = 200000
+        self._N = 20000000
         self._fs = 9000
         self._Tmax = self._N * (1.0/self._fs)
         self._M = 9
@@ -35,8 +36,8 @@
 
         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_filter_ccf(self._M, self._taps)
-
         self.v2s = gr.vector_to_streams(gr.sizeof_gr_complex, self._M)
 
         self.snk_i = gr.vector_sink_c()
@@ -44,53 +45,63 @@
         # 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.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()
 
-    fig1 = pylab.figure(1, figsize=(16,9))
-    fig2 = pylab.figure(2, figsize=(16,9))
+    tend = time.time()
+    print "Run time: %f" % (tend - tstart)
 
-    f_in = scipy.arange(-tb._fs/2.0, tb._fs/2.0, 
tb._fs/float(len(tb.snk_i.data())))
-    X_in = 10.0*scipy.log10(fftpack.fftshift(fftpack.fft(tb.snk_i.data(), 
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(tb.snk_i.data())))
-    x_in = scipy.array(tb.snk_i.data())
-    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()[2000:10000]
-        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")
+    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()
 
-    pylab.show()
 
-
 if __name__ == "__main__":
     try:
         main()





reply via email to

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