[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] r11291 - gnuradio/branches/developers/trondeau/pfb/gnu
From: |
trondeau |
Subject: |
[Commit-gnuradio] r11291 - gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb |
Date: |
Thu, 25 Jun 2009 20:42:28 -0600 (MDT) |
Author: trondeau
Date: 2009-06-25 20:42:28 -0600 (Thu, 25 Jun 2009)
New Revision: 11291
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/chirp_channelize.py
Log:
Adding a basic chirp example through the PFB channelizer.
Added:
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/chirp_channelize.py
===================================================================
---
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/chirp_channelize.py
(rev 0)
+++
gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb/chirp_channelize.py
2009-06-26 02:42:28 UTC (rev 11291)
@@ -0,0 +1,112 @@
+#!/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 = 200000
+ 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
+
+ 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.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.vco_input, self.vco, self.f2c)
+ self.connect(self.f2c, self.head, self.s2ss)
+ self.connect(self.pfb, self.v2s)
+ self.connect(self.f2c, 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 = 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/trondeau/pfb/gnuradio-examples/python/pfb/chirp_channelize.py
___________________________________________________________________
Added: svn:executable
+ *
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Commit-gnuradio] r11291 - gnuradio/branches/developers/trondeau/pfb/gnuradio-examples/python/pfb,
trondeau <=