commit-gnuradio
[Top][All Lists]
Advanced

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

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


From: trondeau
Subject: [Commit-gnuradio] r11343 - gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb
Date: Sun, 5 Jul 2009 09:25:59 -0600 (MDT)

Author: trondeau
Date: 2009-07-05 09:25:59 -0600 (Sun, 05 Jul 2009)
New Revision: 11343

Modified:
   
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/decimate.py
Log:
Actually using the PFB decimator. Plotting with windowed PSD instead of FFT.

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-04 23:49:12 UTC (rev 11342)
+++ 
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/decimate.py
  2009-07-05 15:25:59 UTC (rev 11343)
@@ -34,8 +34,8 @@
             self.connect(self.signals[i], (self.add,i))
 
         self.head = gr.head(gr.sizeof_gr_complex, self._N)
-        #self.pfb = blks2.pfb_decimator_ccf(self._decim, self._taps, 0)
-        self.pfb = gr.fir_filter_ccf(self._decim, self._taps)
+        self.pfb = blks2.pfb_decimator_ccf(self._decim, self._taps, 0)
+        #self.pfb = gr.fir_filter_ccf(self._decim, self._taps)
         self.snk_i = gr.vector_sink_c()
 
         # Connect the blocks
@@ -61,13 +61,25 @@
         
         Ns = 10000
         Ne = 10000
+
+        fftlen = 8192
+        winfunc = scipy.blackman
+        fs = tb._fs
+
+        # Plot the input to the decimator
+
         d = tb.snk_i.data()[Ns: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_f = fig1.add_subplot(2, 1, 1)
-        p1_f = sp1_f.plot(f_in, X_in)
-        sp1_f.set_ylim([-50.0, 50.0])
 
+        X,freq = sp1_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))
+        p1_f = sp1_f.plot(f_in, X_in, "b")
+        sp1_f.set_xlim([min(f_in), max(f_in)+1]) 
+        sp1_f.set_ylim([-200.0, 50.0]) 
+
         sp1_f.set_title("Input Signal", weight="bold")
         sp1_f.set_xlabel("Frequency (Hz)")
         sp1_f.set_ylabel("Power (dBW)")
@@ -82,14 +94,21 @@
         sp1_t.set_xlabel("Time (s)")
         sp1_t.set_ylabel("Amplitude")
 
+        
+        # Plot the output of the decimator
         fs_o = tb._fs / tb._decim
 
         d = tb.snk.data()[Ns: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)))
         sp2_f = fig2.add_subplot(2, 1, 1)
-        p2_f = sp2_f.plot(f_o, x_o)
-        sp2_f.set_ylim([-50.0, 50.0])
+        d = tb.snk.data()[Ns:Ns+Ne]
+        X,freq = sp2_f.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+                           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 = sp2_f.plot(f_o, X_o, "b")
+        sp2_f.set_xlim([min(f_o), max(f_o)+1]) 
+        sp2_f.set_ylim([-200.0, 50.0]) 
 
         sp2_f.set_title("PFB Decimated Signal", weight="bold")
         sp2_f.set_xlabel("Frequency (Hz)")





reply via email to

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