commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: trondeau
Subject: [Commit-gnuradio] r11345 - gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb
Date: Sun, 5 Jul 2009 10:11:58 -0600 (MDT)

Author: trondeau
Date: 2009-07-05 10:11:57 -0600 (Sun, 05 Jul 2009)
New Revision: 11345

Modified:
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/decimate.py
Log:
Better plotting of channelizer example; small fix for decimator example.

Modified: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
        2009-07-05 15:31:19 UTC (rev 11344)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/channelize.py
        2009-07-05 16:11:57 UTC (rev 11345)
@@ -14,7 +14,7 @@
     def __init__(self):
         gr.top_block.__init__(self)
 
-        self._N = 20000000
+        self._N = 2000000
         self._fs = 9000
         self._Tmax = self._N * (1.0/self._fs)
         self._M = 9
@@ -60,40 +60,83 @@
     print "Run time: %f" % (tend - tstart)
 
     if 1:
-        fig1 = pylab.figure(1, figsize=(16,9))
-        fig2 = pylab.figure(2, figsize=(16,9))
+        fig_in = pylab.figure(1, figsize=(16,9), facecolor="w")
+        fig1 = pylab.figure(2, figsize=(16,9), facecolor="w")
+        fig2 = pylab.figure(3, figsize=(16,9), facecolor="w")
         
         Ns = 1000
         Ne = 10000
+
+        fftlen = 8192
+        winfunc = scipy.blackman
+        fs = tb._fs
+
+        # Plot the input signal on its own figure
         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)
-        
+        spin_f = fig_in.add_subplot(2, 1, 1)
+
+        X,freq = spin_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+                            window = lambda d: d*winfunc(fftlen),
+                            visible=False)
+        X_in = 10.0*scipy.log10(abs(fftpack.fftshift(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]) 
+        spin_f.set_ylim([-200.0, 50.0]) 
+
+        spin_f.set_title("Input Signal", weight="bold")
+        spin_f.set_xlabel("Frequency (Hz)")
+        spin_f.set_ylabel("Power (dBW)")
+
         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")
-        
+        spin_t = fig_in.add_subplot(2, 1, 2)
+        pin_t = spin_t.plot(t_in, x_in.real, "b")
+        pin_t = spin_t.plot(t_in, x_in.imag, "r")
+
+        spin_t.set_xlabel("Time (s)")
+        spin_t.set_ylabel("Amplitude")
+
+        Ncols = int(scipy.floor(scipy.sqrt(tb._M)))
+        Nrows = int(scipy.floor(tb._M / Ncols))
+        if(tb._M % Ncols != 0):
+            Nrows += 1
+
+        # Plot each of the channels outputs. Frequencies on Figure 2 and
+        # time signals on Figure 3
         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)
+
+            sp1_f = fig1.add_subplot(Nrows, Ncols, 1+i)
+            X,freq = sp1_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o,
+                               window = lambda d: d*winfunc(fftlen),
+                               visible=False)
+            X_o = 10.0*scipy.log10(abs(fftpack.fftshift(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]) 
+            sp1_f.set_ylim([-200.0, 50.0]) 
+
+            sp1_f.set_title(("Channel %d" % i), weight="bold")
+            sp1_f.set_xlabel("Frequency (Hz)")
+            sp1_f.set_ylabel("Power (dBW)")
+
             
             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)
+            sp2_o = fig2.add_subplot(Nrows, Ncols, 1+i)
             p2_o = sp2_o.plot(t_o, x_o.real, "b")
             p2_o = sp2_o.plot(t_o, x_o.imag, "r")
-            
+            sp2_o.set_xlim([min(t_o), max(t_o)+1]) 
+            sp2_o.set_ylim([-2, 2]) 
+
+            sp2_o.set_xlabel("Time (s)")
+            sp2_o.set_ylabel("Amplitude")
+
         pylab.show()
 
 

Modified: 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/decimate.py
===================================================================
--- 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/decimate.py
  2009-07-05 15:31:19 UTC (rev 11344)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/decimate.py
  2009-07-05 16:11:57 UTC (rev 11345)
@@ -98,10 +98,9 @@
         # Plot the output of the decimator
         fs_o = tb._fs / tb._decim
 
-        d = tb.snk.data()[Ns:Ns+Ne]
         sp2_f = fig2.add_subplot(2, 1, 1)
         d = tb.snk.data()[Ns:Ns+Ne]
-        X,freq = sp2_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+        X,freq = sp2_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o,
                            window = lambda d: d*winfunc(fftlen),
                            visible=False)
         X_o = 10.0*scipy.log10(abs(fftpack.fftshift(X)))





reply via email to

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