commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] r11533 - in gnuradio/branches/developers/n4hy/pfb_iir2


From: n4hy
Subject: [Commit-gnuradio] r11533 - in gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python: . pfb
Date: Mon, 3 Aug 2009 09:48:59 -0600 (MDT)

Author: n4hy
Date: 2009-08-03 09:48:59 -0600 (Mon, 03 Aug 2009)
New Revision: 11533

Added:
   gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/channelize.py
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/chirp_channelize.py
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/decimate.py
   
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/interpolate.py
Log:
add Tom's examples and we can begin work

Added: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/channelize.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/channelize.py
                               (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/channelize.py
       2009-08-03 15:48:59 UTC (rev 11533)
@@ -0,0 +1,148 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, blks2
+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 = 2000000
+        self._fs = 9000
+        self._Tmax = self._N * (1.0/self._fs)
+        self._M = 9
+        self._taps = gr.firdes.low_pass_2(1, self._fs, 475,50, 100,5)
+
+        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, 4300]
+        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.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps)
+        self.snk_i = gr.vector_sink_c()
+
+        # Connect the blocks
+        self.connect(self.add, self.head, self.pfb)
+        self.connect(self.add, self.snk_i)
+
+        # 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.snks.append(gr.vector_sink_c())
+            self.connect((self.pfb, i), self.snks[i])
+                             
+
+def main():
+    tstart = time.time()
+    
+    tb = pfb_top_block()
+    tb.run()
+
+    tend = time.time()
+    print "Run time: %f" % (tend - tstart)
+
+    if 1:
+        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]
+        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)
+        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]
+
+            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(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()
+
+
+if __name__ == "__main__":
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+    


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

Added: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/chirp_channelize.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/chirp_channelize.py
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/chirp_channelize.py
 2009-08-03 15:48:59 UTC (rev 11533)
@@ -0,0 +1,107 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, blks2
+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 = 200000
+        self._fs = 9000
+        self._Tmax = self._N * (1.0/self._fs)
+        self._M = 9
+        self._taps = gr.firdes.low_pass_2(1, self._fs, 800,100 ,90,5)
+        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
+
+        data = scipy.arange(0, 1000, 100.0/float(self._N))
+        
+        #self.vco_input = gr.sig_source_f(self._fs, gr.GR_SIN_WAVE, 0.25, 100)
+        self.vco_input = gr.vector_source_f(data, False)
+        self.vco = gr.vco_f(self._fs, 225, 1)
+        self.f2c = gr.float_to_complex()
+
+        self.head = gr.head(gr.sizeof_gr_complex, self._N)
+        self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps)
+        self.snk_i = gr.vector_sink_c()
+
+        # Connect the rest
+        self.connect(self.vco_input, self.vco, self.f2c)
+        self.connect(self.f2c, self.head, self.pfb)
+        self.connect(self.f2c, self.snk_i)
+
+        # 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.snks.append(gr.vector_sink_c())
+            self.connect((self.pfb, i), self.snks[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 = 100
+        Ne = tb._N
+        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)
+            sp1_o.set_ylim([-50.0, 30.0])
+            
+            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")
+            sp2_o.set_ylim([-1.0, 1.0])
+            
+        pylab.show()
+
+
+if __name__ == "__main__":
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+    


Property changes on: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/chirp_channelize.py
___________________________________________________________________
Added: svn:executable
   + *

Added: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/decimate.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/decimate.py
                         (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/decimate.py
 2009-08-03 15:48:59 UTC (rev 11533)
@@ -0,0 +1,135 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, blks2
+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 = 10000000
+        self._fs = 10000
+        self._Tmax = self._N * (1.0/self._fs)
+        self._decim = 20
+        self._taps = gr.firdes.low_pass_2(1, self._fs, 200, 50,120,5)
+
+        tpc = math.ceil(float(len(self._taps)) /  float(self._decim))
+
+        print "Number of taps:     ", len(self._taps)
+        print "Number of filters:  ", self._decim
+        print "Taps per channel:   ", tpc
+        
+        self.signals = list()
+        self.add = gr.add_cc()
+        freqs = [10, 2040]
+        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.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
+        self.connect(self.add, self.head, self.pfb)
+        self.connect(self.add, self.snk_i)
+
+        # Create the sink for the decimated siganl
+        self.snk = gr.vector_sink_c()
+        self.connect(self.pfb, self.snk)
+                             
+
+def main():
+    tb = pfb_top_block()
+
+    tstart = time.time()    
+    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 = 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]
+        sp1_f = fig1.add_subplot(2, 1, 1)
+
+        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)")
+        
+        t_in = scipy.arange(0, tb._Tmax, tb._Tmax/float(len(d)))
+        x_in = scipy.array(d)
+        sp1_t = fig1.add_subplot(2, 1, 2)
+        p1_t = sp1_t.plot(t_in, x_in.real, "b")
+        p1_t = sp1_t.plot(t_in, x_in.imag, "r")
+        sp1_t.set_ylim([-tb._decim*1.1, tb._decim*1.1])
+
+        sp1_t.set_xlabel("Time (s)")
+        sp1_t.set_ylabel("Amplitude")
+
+        
+        # Plot the output of the decimator
+        fs_o = tb._fs / tb._decim
+
+        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_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 = 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)")
+        sp2_f.set_ylabel("Power (dBW)")
+        
+
+        x_o = scipy.array(d)
+        t_o = scipy.arange(0, tb._Tmax, tb._Tmax/float(x_o.size))
+        sp2_t = fig2.add_subplot(2, 1, 2)
+        p2_t = sp2_t.plot(t_o, x_o.real, "b")
+        p2_t = sp2_t.plot(t_o, x_o.imag, "r")
+        sp2_t.set_ylim([-1.5, 1.5])
+
+        sp2_t.set_xlabel("Time (s)")
+        sp2_t.set_ylabel("Amplitude")
+
+        pylab.show()
+
+
+if __name__ == "__main__":
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+    


Property changes on: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/decimate.py
___________________________________________________________________
Added: svn:executable
   + *

Added: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/interpolate.py
===================================================================
--- 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/interpolate.py
                              (rev 0)
+++ 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/interpolate.py
      2009-08-03 15:48:59 UTC (rev 11533)
@@ -0,0 +1,194 @@
+#!/usr/bin/env python
+
+from gnuradio import gr, blks2
+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)
+
+        freq1 = 100
+        freq2 = 500
+
+        self._N = 100000
+        self._fs = 2000
+        self._Tmax = self._N * (1.0/self._fs)
+        self._interp = 8
+        self._ainterp = 8
+
+        self._taps = gr.firdes.low_pass_2(self._interp, self._interp*self._fs, 
freq2+50, 150,120,5)
+        self._taps2 = gr.firdes.low_pass_2(32.0, 1,
+                                         0.4 / (32.0), 0.1/(32.0),100,5)
+
+        tpc = math.ceil(float(len(self._taps)) /  float(self._interp))
+
+        print "Number of taps:     ", len(self._taps)
+        print "Number of filters:  ", self._interp
+        print "Taps per channel:   ", tpc
+        
+        self.signal1 = gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, freq1, 0.5)
+        self.signal2 = gr.sig_source_c(self._fs, gr.GR_SIN_WAVE, freq2, 0.5)
+        self.signal = gr.add_cc()
+        
+        self.head = gr.head(gr.sizeof_gr_complex, self._N)
+        self.pfb = blks2.pfb_interpolator_ccf(self._interp, self._taps)
+        self.pfb_ar = blks2.pfb_arb_resampler_ccf(self._ainterp, self._taps2)
+        self.snk_i = gr.vector_sink_c()
+
+        #self.pfb_ar.pfb.print_taps()
+
+        # Connect the blocks
+        self.connect(self.signal1, self.head, (self.signal,0))
+        self.connect(self.signal2, (self.signal,1))
+        self.connect(self.signal, self.pfb)
+        self.connect(self.signal, self.pfb_ar)
+        self.connect(self.signal, self.snk_i)
+
+        # Create the sink for the interpolated siganl
+        self.snk1 = gr.vector_sink_c()
+        self.snk2 = gr.vector_sink_c()
+        self.connect(self.pfb, self.snk1)
+        self.connect(self.pfb_ar, self.snk2)
+                             
+
+def main():
+    tb = pfb_top_block()
+
+    tstart = time.time()
+    tb.run()
+    tend = time.time()
+    print "Run time: %f" % (tend - tstart)
+
+
+    if 1:
+        fig1 = pylab.figure(1, figsize=(12,10), facecolor="w")
+        fig2 = pylab.figure(2, figsize=(12,10), facecolor="w")
+        fig3 = pylab.figure(3, figsize=(12,10), facecolor="w")
+        
+        Ns = 10000
+        Ne = 10000
+
+        fftlen = 8192
+        winfunc = scipy.blackman
+
+        # Plot input signal
+        fs = tb._fs
+
+        d = tb.snk_i.data()[Ns:Ns+Ne]
+        sp1_f = fig1.add_subplot(2, 1, 1)
+
+        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)")
+
+        Ts = 1.0/fs
+        Tmax = len(d)*Ts
+        
+        t_in = scipy.arange(0, Tmax, Ts)
+        x_in = scipy.array(d)
+        sp1_t = fig1.add_subplot(2, 1, 2)
+        p1_t = sp1_t.plot(t_in, x_in.real, "b-o")
+        #p1_t = sp1_t.plot(t_in, x_in.imag, "r-o")
+        sp1_t.set_ylim([-2.5, 2.5])
+
+        sp1_t.set_title("Input Signal", weight="bold")
+        sp1_t.set_xlabel("Time (s)")
+        sp1_t.set_ylabel("Amplitude")
+
+
+        # Plot output of PFB interpolator
+        fs_int = tb._fs*tb._interp
+
+        sp2_f = fig2.add_subplot(2, 1, 1)
+        d = tb.snk1.data()[Ns:Ns+(tb._interp*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_int/2.0, fs_int/2.0, fs_int/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("Output Signal from PFB Interpolator", weight="bold")
+        sp2_f.set_xlabel("Frequency (Hz)")
+        sp2_f.set_ylabel("Power (dBW)")
+
+        Ts_int = 1.0/fs_int
+        Tmax = len(d)*Ts_int
+
+        t_o = scipy.arange(0, Tmax, Ts_int)
+        x_o1 = scipy.array(d)
+        sp2_t = fig2.add_subplot(2, 1, 2)
+        p2_t = sp2_t.plot(t_o, x_o1.real, "b-o")
+        #p2_t = sp2_t.plot(t_o, x_o.imag, "r-o")
+        sp2_t.set_ylim([-2.5, 2.5])
+
+        sp2_t.set_title("Output Signal from PFB Interpolator", weight="bold")
+        sp2_t.set_xlabel("Time (s)")
+        sp2_t.set_ylabel("Amplitude")
+
+
+        # Plot output of PFB arbitrary resampler
+        fs_aint = tb._fs * tb._ainterp
+
+        sp3_f = fig3.add_subplot(2, 1, 1)
+        d = tb.snk2.data()[Ns:Ns+(tb._interp*Ne)]
+        X,freq = sp3_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_aint/2.0, fs_aint/2.0, fs_aint/float(X_o.size))
+        p3_f = sp3_f.plot(f_o, X_o, "b")
+        sp3_f.set_xlim([min(f_o), max(f_o)+1]) 
+        sp3_f.set_ylim([-200.0, 50.0]) 
+
+        #f_o = scipy.arange(-fs_int/2.0, fs_int/2.0, fs_int/float(len(d)))
+        #X_o = 10.0*scipy.log10(fftpack.fftshift(fftpack.fft(d)))
+        #p3_f = sp3_f.plot(f_o, X_o)
+        #sp3_f.set_ylim([-50.0, 50.0])
+
+        sp3_f.set_title("Output Signal from PFB Arbitrary Resampler", 
weight="bold")
+        sp3_f.set_xlabel("Frequency (Hz)")
+        sp3_f.set_ylabel("Power (dBW)")
+
+        Ts_aint = 1.0/fs_aint
+        Tmax = len(d)*Ts_aint
+
+        t_o = scipy.arange(0, Tmax, Ts_aint)
+        x_o1 = scipy.array(d)
+        sp3_f = fig3.add_subplot(2, 1, 2)
+        p3_f = sp3_f.plot(t_o, x_o1.real, "b-o")
+        #p3_f = sp3_f.plot(t_o, x_o.imag, "r-o")
+        sp3_f.set_ylim([-2.5, 2.5])
+        
+        sp3_f.set_title("Output Signal from PFB Arbitrary Resampler", 
weight="bold")
+        sp3_f.set_xlabel("Time (s)")
+        sp3_f.set_ylabel("Amplitude")
+
+        pylab.show()
+
+
+if __name__ == "__main__":
+    try:
+        main()
+    except KeyboardInterrupt:
+        pass
+    


Property changes on: 
gnuradio/branches/developers/n4hy/pfb_iir2/gnuradio-examples/python/pfb/interpolate.py
___________________________________________________________________
Added: svn:executable
   + *





reply via email to

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