diff options
Diffstat (limited to 'gnuradio-examples/python')
-rw-r--r-- | gnuradio-examples/python/.gitignore | 10 | ||||
-rw-r--r-- | gnuradio-examples/python/Makefile.am | 28 | ||||
-rw-r--r-- | gnuradio-examples/python/mp-sched/.gitignore | 10 | ||||
-rw-r--r-- | gnuradio-examples/python/mp-sched/Makefile.am | 32 | ||||
-rw-r--r-- | gnuradio-examples/python/network/.gitignore | 2 | ||||
-rw-r--r-- | gnuradio-examples/python/network/Makefile.am | 32 | ||||
-rw-r--r-- | gnuradio-examples/python/pfb/.gitignore | 2 | ||||
-rw-r--r-- | gnuradio-examples/python/pfb/CMakeLists.txt | 1 | ||||
-rw-r--r-- | gnuradio-examples/python/pfb/Makefile.am | 37 | ||||
-rwxr-xr-x | gnuradio-examples/python/pfb/channelize.py | 5 | ||||
-rwxr-xr-x | gnuradio-examples/python/pfb/reconstruction.py | 131 | ||||
-rw-r--r-- | gnuradio-examples/python/tags/.gitignore | 2 | ||||
-rw-r--r-- | gnuradio-examples/python/tags/Makefile.am | 29 |
13 files changed, 136 insertions, 185 deletions
diff --git a/gnuradio-examples/python/.gitignore b/gnuradio-examples/python/.gitignore deleted file mode 100644 index c400497f5..000000000 --- a/gnuradio-examples/python/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/*.pyo diff --git a/gnuradio-examples/python/Makefile.am b/gnuradio-examples/python/Makefile.am deleted file mode 100644 index 4327fd359..000000000 --- a/gnuradio-examples/python/Makefile.am +++ /dev/null @@ -1,28 +0,0 @@ -# -# Copyright 2004,2007,2009,2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -SUBDIRS = \ - mp-sched \ - network \ - pfb \ - tags diff --git a/gnuradio-examples/python/mp-sched/.gitignore b/gnuradio-examples/python/mp-sched/.gitignore deleted file mode 100644 index c400497f5..000000000 --- a/gnuradio-examples/python/mp-sched/.gitignore +++ /dev/null @@ -1,10 +0,0 @@ -/Makefile -/Makefile.in -/.la -/.lo -/.deps -/.libs -/*.la -/*.lo -/*.pyc -/*.pyo diff --git a/gnuradio-examples/python/mp-sched/Makefile.am b/gnuradio-examples/python/mp-sched/Makefile.am deleted file mode 100644 index 98fa283ef..000000000 --- a/gnuradio-examples/python/mp-sched/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2008,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along -# with this program; if not, write to the Free Software Foundation, Inc., -# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/mp-sched - -dist_ourdata_DATA = \ - README - -dist_ourdata_SCRIPTS = \ - plot_flops.py \ - run_synthetic.py \ - synthetic.py \ - wfm_rcv_pll_to_wav.py diff --git a/gnuradio-examples/python/network/.gitignore b/gnuradio-examples/python/network/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/python/network/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gnuradio-examples/python/network/Makefile.am b/gnuradio-examples/python/network/Makefile.am deleted file mode 100644 index 77cacbfd2..000000000 --- a/gnuradio-examples/python/network/Makefile.am +++ /dev/null @@ -1,32 +0,0 @@ -# -# Copyright 2007,2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/network - -dist_ourdata_SCRIPTS = \ - audio_sink.py \ - audio_source.py \ - dial_tone_sink.py \ - dial_tone_source.py \ - vector_sink.py \ - vector_source.py diff --git a/gnuradio-examples/python/pfb/.gitignore b/gnuradio-examples/python/pfb/.gitignore deleted file mode 100644 index 282522db0..000000000 --- a/gnuradio-examples/python/pfb/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -Makefile -Makefile.in diff --git a/gnuradio-examples/python/pfb/CMakeLists.txt b/gnuradio-examples/python/pfb/CMakeLists.txt index 55dbb16ac..88fdf2ead 100644 --- a/gnuradio-examples/python/pfb/CMakeLists.txt +++ b/gnuradio-examples/python/pfb/CMakeLists.txt @@ -29,6 +29,7 @@ GR_PYTHON_INSTALL(PROGRAMS resampler.py synth_filter.py synth_to_chan.py + reconstruction.py DESTINATION ${GR_PKG_DATA_DIR}/examples/pfb COMPONENT "gnuradio_examples" ) diff --git a/gnuradio-examples/python/pfb/Makefile.am b/gnuradio-examples/python/pfb/Makefile.am deleted file mode 100644 index 39c81bfc2..000000000 --- a/gnuradio-examples/python/pfb/Makefile.am +++ /dev/null @@ -1,37 +0,0 @@ -# -# Copyright 2009 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/pfb - -dist_ourdata_SCRIPTS = \ - channelize.py \ - chirp_channelize.py \ - decimate.py \ - interpolate.py \ - fmtest.py \ - resampler.py \ - synth_filter.py \ - synth_to_chan.py - -dist_ourdata_DATA = \ - resampler_demo.grc diff --git a/gnuradio-examples/python/pfb/channelize.py b/gnuradio-examples/python/pfb/channelize.py index 999e5d20e..2fcb14a36 100755 --- a/gnuradio-examples/python/pfb/channelize.py +++ b/gnuradio-examples/python/pfb/channelize.py @@ -68,7 +68,7 @@ class pfb_top_block(gr.top_block): self.head = gr.head(gr.sizeof_gr_complex, self._N) # Construct the channelizer filter - self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps) + self.pfb = blks2.pfb_channelizer_ccf(self._M, self._taps, 1) # Construct a vector sink for the input signal to the channelizer self.snk_i = gr.vector_sink_c() @@ -77,6 +77,9 @@ class pfb_top_block(gr.top_block): self.connect(self.add, self.head, self.pfb) self.connect(self.add, self.snk_i) + # Use this to play with the channel mapping + #self.pfb.set_channel_map([5,6,7,8,0,1,2,3,4]) + # Create a vector sink for each of M output channels of the filter and connect it self.snks = list() for i in xrange(self._M): diff --git a/gnuradio-examples/python/pfb/reconstruction.py b/gnuradio-examples/python/pfb/reconstruction.py new file mode 100755 index 000000000..2b6f9a831 --- /dev/null +++ b/gnuradio-examples/python/pfb/reconstruction.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python + +import scipy, math, pylab +from scipy import fftpack +from gnuradio import gr, digital, blks2 + +fftlen = 8192 + +def main(): + N = 10000 + fs = 2000.0 + Ts = 1.0/fs + t = scipy.arange(0, N*Ts, Ts) + + # When playing with the number of channels, be careful about the filter + # specs and the channel map of the synthesizer set below. + nchans = 10 + + # Build the filter(s) + bw = 1000 + tb = 400 + proto_taps = gr.firdes.low_pass_2(1, nchans*fs, bw, tb, 80, + gr.firdes.WIN_BLACKMAN_hARRIS) + print "Filter length: ", len(proto_taps) + + + # Create a modulated signal + npwr = 0.01 + data = scipy.random.randint(0, 256, N) + rrc_taps = gr.firdes.root_raised_cosine(1, 2, 1, 0.35, 41) + + src = gr.vector_source_b(data.astype(scipy.uint8).tolist(), False) + mod = digital.bpsk_mod(samples_per_symbol=2) + chan = gr.channel_model(npwr) + rrc = gr.fft_filter_ccc(1, rrc_taps) + + # Split it up into pieces + channelizer = blks2.pfb_channelizer_ccf(nchans, proto_taps, 2) + + # Put the pieces back together again + syn_taps = [nchans*t for t in proto_taps] + synthesizer = gr.pfb_synthesis_filterbank_ccf(nchans, syn_taps, True) + src_snk = gr.vector_sink_c() + snk = gr.vector_sink_c() + + # Remap the location of the channels + # Can be done in synth or channelizer (watch out for rotattions in + # the channelizer) + synthesizer.set_channel_map([ 0, 1, 2, 3, 4, + 15, 16, 17, 18, 19]) + + tb = gr.top_block() + tb.connect(src, mod, chan, rrc, channelizer) + tb.connect(rrc, src_snk) + + vsnk = [] + for i in xrange(nchans): + tb.connect((channelizer,i), (synthesizer, i)) + + vsnk.append(gr.vector_sink_c()) + tb.connect((channelizer,i), vsnk[i]) + + tb.connect(synthesizer, snk) + tb.run() + + sin = scipy.array(src_snk.data()[1000:]) + sout = scipy.array(snk.data()[1000:]) + + + # Plot original signal + fs_in = nchans*fs + f1 = pylab.figure(1, figsize=(16,12), facecolor='w') + s11 = f1.add_subplot(2,2,1) + s11.psd(sin, NFFT=fftlen, Fs=fs_in) + s11.set_title("PSD of Original Signal") + s11.set_ylim([-200, -20]) + + s12 = f1.add_subplot(2,2,2) + s12.plot(sin.real[1000:1500], "o-b") + s12.plot(sin.imag[1000:1500], "o-r") + s12.set_title("Original Signal in Time") + + start = 1 + skip = 4 + s13 = f1.add_subplot(2,2,3) + s13.plot(sin.real[start::skip], sin.imag[start::skip], "o") + s13.set_title("Constellation") + s13.set_xlim([-2, 2]) + s13.set_ylim([-2, 2]) + + # Plot channels + nrows = int(scipy.sqrt(nchans)) + ncols = int(scipy.ceil(float(nchans)/float(nrows))) + + f2 = pylab.figure(2, figsize=(16,12), facecolor='w') + for n in xrange(nchans): + s = f2.add_subplot(nrows, ncols, n+1) + s.psd(vsnk[n].data(), NFFT=fftlen, Fs=fs_in) + s.set_title("Channel {0}".format(n)) + s.set_ylim([-200, -20]) + + # Plot reconstructed signal + fs_out = 2*nchans*fs + f3 = pylab.figure(3, figsize=(16,12), facecolor='w') + s31 = f3.add_subplot(2,2,1) + s31.psd(sout, NFFT=fftlen, Fs=fs_out) + s31.set_title("PSD of Reconstructed Signal") + s31.set_ylim([-200, -20]) + + s32 = f3.add_subplot(2,2,2) + s32.plot(sout.real[1000:1500], "o-b") + s32.plot(sout.imag[1000:1500], "o-r") + s32.set_title("Reconstructed Signal in Time") + + start = 2 + skip = 4 + s33 = f3.add_subplot(2,2,3) + s33.plot(sout.real[start::skip], sout.imag[start::skip], "o") + s33.set_title("Constellation") + s33.set_xlim([-2, 2]) + s33.set_ylim([-2, 2]) + + pylab.show() + + +if __name__ == "__main__": + try: + main() + except KeyboardInterrupt: + pass + diff --git a/gnuradio-examples/python/tags/.gitignore b/gnuradio-examples/python/tags/.gitignore deleted file mode 100644 index b336cc7ce..000000000 --- a/gnuradio-examples/python/tags/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/Makefile -/Makefile.in diff --git a/gnuradio-examples/python/tags/Makefile.am b/gnuradio-examples/python/tags/Makefile.am deleted file mode 100644 index 5d71bf9b0..000000000 --- a/gnuradio-examples/python/tags/Makefile.am +++ /dev/null @@ -1,29 +0,0 @@ -# -# Copyright 2011 Free Software Foundation, Inc. -# -# This file is part of GNU Radio -# -# GNU Radio is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3, or (at your option) -# any later version. -# -# GNU Radio is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with GNU Radio; see the file COPYING. If not, write to -# the Free Software Foundation, Inc., 51 Franklin Street, -# Boston, MA 02110-1301, USA. -# - -include $(top_srcdir)/Makefile.common - -ourdatadir = $(exampledir)/tags - -dist_ourdata_SCRIPTS = \ - test_file_tags.py \ - uhd_burst_detector.py - |