From 0e86a5f357d40de759c804cc704dd907c50b02d7 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Sep 2011 16:34:49 -0400 Subject: tags: updated uhd_burst_detector with a better energy detector. Works well when receiving bursty NBFM signals. --- .../python/tags/uhd_burst_detector.py | 66 ++++++++++++++-------- 1 file changed, 43 insertions(+), 23 deletions(-) (limited to 'gnuradio-examples/python') diff --git a/gnuradio-examples/python/tags/uhd_burst_detector.py b/gnuradio-examples/python/tags/uhd_burst_detector.py index f8ebbe66a..ffa419562 100755 --- a/gnuradio-examples/python/tags/uhd_burst_detector.py +++ b/gnuradio-examples/python/tags/uhd_burst_detector.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# 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. +# from gnuradio import eng_notation from gnuradio import gr @@ -9,16 +29,16 @@ from gnuradio.gr import firdes from optparse import OptionParser class uhd_burst_detector(gr.top_block): - def __init__(self, frequency, sample_rate, - uhd_address="192.168.10.2", trigger=False): + def __init__(self, uhd_address, options): gr.top_block.__init__(self) - self.freq = frequency - self.samp_rate = sample_rate self.uhd_addr = uhd_address - self.gain = 32 - self.trigger = trigger + self.freq = options.freq + self.samp_rate = options.samp_rate + self.gain = options.gain + self.threshold = options.threshold + self.trigger = options.trigger self.uhd_src = uhd.single_usrp_source( device_addr=self.uhd_addr, @@ -32,7 +52,6 @@ class uhd_burst_detector(gr.top_block): taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) self.chanfilt = gr.fir_filter_ccc(10, taps) - self.ann0 = gr.annotator_alltoall(100000, gr.sizeof_gr_complex) self.tagger = gr.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods @@ -40,11 +59,18 @@ class uhd_burst_detector(gr.top_block): self.signal = gr.vector_source_s(data, True) # Energy detector to get signal burst + ## use squelch to detect energy + self.det = gr.simple_squelch_cc(self.threshold, 0.01) + ## convert to mag squared (float) self.c2m = gr.complex_to_mag_squared() - self.iir = gr.single_pole_iir_filter_ff(0.0001) - self.sub = gr.sub_ff() - self.mult = gr.multiply_const_ff(32768) + ## average to debounce + self.avg = gr.single_pole_iir_filter_ff(0.01) + ## rescale signal for conversion to short + self.scale = gr.multiply_const_ff(2**16) + ## signal input uses shorts self.f2s = gr.float_to_short() + + # Use file sink burst tagger to capture bursts self.fsnk = gr.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) @@ -60,17 +86,12 @@ class uhd_burst_detector(gr.top_block): else: # Connect an energy detector signaler to the burst tagger - self.connect((self.uhd_src, 0), (self.c2m, 0)) - self.connect((self.c2m, 0), (self.sub, 0)) - self.connect((self.c2m, 0), (self.iir, 0)) - self.connect((self.iir, 0), (self.sub, 1)) - self.connect((self.sub, 0), (self.mult,0)) - self.connect((self.mult, 0), (self.f2s, 0)) - self.connect((self.f2s, 0), (self.tagger, 1)) + self.connect(self.uhd_src, self.det) + self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s) + self.connect(self.f2s, (self.tagger, 1)) def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate - self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate/10) self.uhd_src_0.set_samp_rate(self.samp_rate) if __name__ == '__main__': @@ -83,16 +104,15 @@ if __name__ == '__main__': help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=0, help="set gain in dB [default=%default]") - parser.add_option("-R", "--rate", type="eng_float", default=200000, + parser.add_option("-R", "--samp-rate", type="eng_float", default=200000, help="set USRP sample rate [default=%default]") + parser.add_option("-t", "--threshold", type="float", default=-60, + help="Set the detection power threshold (dBm) [default=%default") parser.add_option("-T", "--trigger", action="store_true", default=False, help="Use internal trigger instead of detector [default=%default]") (options, args) = parser.parse_args() - frequency = options.freq - samp_rate = samp_rate = options.rate uhd_addr = options.address - trigger = options.trigger - tb = uhd_burst_detector(frequency, samp_rate, uhd_addr, trigger) + tb = uhd_burst_detector(uhd_addr, options) tb.run() -- cgit From 34d725a16b695be59f04f2b4eb503532d1cbfe2f Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Sep 2011 17:08:23 -0400 Subject: tags: adding tags examples to build distribution. --- gnuradio-examples/python/Makefile.am | 1 + gnuradio-examples/python/tags/.gitignore | 2 ++ gnuradio-examples/python/tags/Makefile.am | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 gnuradio-examples/python/tags/.gitignore create mode 100644 gnuradio-examples/python/tags/Makefile.am (limited to 'gnuradio-examples/python') diff --git a/gnuradio-examples/python/Makefile.am b/gnuradio-examples/python/Makefile.am index eba4c14ab..3f1977e74 100644 --- a/gnuradio-examples/python/Makefile.am +++ b/gnuradio-examples/python/Makefile.am @@ -31,5 +31,6 @@ SUBDIRS = \ network \ ofdm \ pfb \ + tags \ usrp \ usrp2 diff --git a/gnuradio-examples/python/tags/.gitignore b/gnuradio-examples/python/tags/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gnuradio-examples/python/tags/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gnuradio-examples/python/tags/Makefile.am b/gnuradio-examples/python/tags/Makefile.am new file mode 100644 index 000000000..5d71bf9b0 --- /dev/null +++ b/gnuradio-examples/python/tags/Makefile.am @@ -0,0 +1,29 @@ +# +# 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 + -- cgit From 7fa533e2b04423e31159b10fb4c54554fe93ea0e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Sep 2011 16:34:49 -0400 Subject: tags: updated uhd_burst_detector with a better energy detector. Works well when receiving bursty NBFM signals. --- .../python/tags/uhd_burst_detector.py | 66 ++++++++++++++-------- 1 file changed, 43 insertions(+), 23 deletions(-) (limited to 'gnuradio-examples/python') diff --git a/gnuradio-examples/python/tags/uhd_burst_detector.py b/gnuradio-examples/python/tags/uhd_burst_detector.py index f8ebbe66a..ffa419562 100755 --- a/gnuradio-examples/python/tags/uhd_burst_detector.py +++ b/gnuradio-examples/python/tags/uhd_burst_detector.py @@ -1,4 +1,24 @@ #!/usr/bin/env python +# +# 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. +# from gnuradio import eng_notation from gnuradio import gr @@ -9,16 +29,16 @@ from gnuradio.gr import firdes from optparse import OptionParser class uhd_burst_detector(gr.top_block): - def __init__(self, frequency, sample_rate, - uhd_address="192.168.10.2", trigger=False): + def __init__(self, uhd_address, options): gr.top_block.__init__(self) - self.freq = frequency - self.samp_rate = sample_rate self.uhd_addr = uhd_address - self.gain = 32 - self.trigger = trigger + self.freq = options.freq + self.samp_rate = options.samp_rate + self.gain = options.gain + self.threshold = options.threshold + self.trigger = options.trigger self.uhd_src = uhd.single_usrp_source( device_addr=self.uhd_addr, @@ -32,7 +52,6 @@ class uhd_burst_detector(gr.top_block): taps = firdes.low_pass_2(1, 1, 0.4, 0.1, 60) self.chanfilt = gr.fir_filter_ccc(10, taps) - self.ann0 = gr.annotator_alltoall(100000, gr.sizeof_gr_complex) self.tagger = gr.burst_tagger(gr.sizeof_gr_complex) # Dummy signaler to collect a burst on known periods @@ -40,11 +59,18 @@ class uhd_burst_detector(gr.top_block): self.signal = gr.vector_source_s(data, True) # Energy detector to get signal burst + ## use squelch to detect energy + self.det = gr.simple_squelch_cc(self.threshold, 0.01) + ## convert to mag squared (float) self.c2m = gr.complex_to_mag_squared() - self.iir = gr.single_pole_iir_filter_ff(0.0001) - self.sub = gr.sub_ff() - self.mult = gr.multiply_const_ff(32768) + ## average to debounce + self.avg = gr.single_pole_iir_filter_ff(0.01) + ## rescale signal for conversion to short + self.scale = gr.multiply_const_ff(2**16) + ## signal input uses shorts self.f2s = gr.float_to_short() + + # Use file sink burst tagger to capture bursts self.fsnk = gr.tagged_file_sink(gr.sizeof_gr_complex, self.samp_rate) @@ -60,17 +86,12 @@ class uhd_burst_detector(gr.top_block): else: # Connect an energy detector signaler to the burst tagger - self.connect((self.uhd_src, 0), (self.c2m, 0)) - self.connect((self.c2m, 0), (self.sub, 0)) - self.connect((self.c2m, 0), (self.iir, 0)) - self.connect((self.iir, 0), (self.sub, 1)) - self.connect((self.sub, 0), (self.mult,0)) - self.connect((self.mult, 0), (self.f2s, 0)) - self.connect((self.f2s, 0), (self.tagger, 1)) + self.connect(self.uhd_src, self.det) + self.connect(self.det, self.c2m, self.avg, self.scale, self.f2s) + self.connect(self.f2s, (self.tagger, 1)) def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate - self.wxgui_fftsink2_0.set_sample_rate(self.samp_rate/10) self.uhd_src_0.set_samp_rate(self.samp_rate) if __name__ == '__main__': @@ -83,16 +104,15 @@ if __name__ == '__main__': help="set frequency to FREQ", metavar="FREQ") parser.add_option("-g", "--gain", type="eng_float", default=0, help="set gain in dB [default=%default]") - parser.add_option("-R", "--rate", type="eng_float", default=200000, + parser.add_option("-R", "--samp-rate", type="eng_float", default=200000, help="set USRP sample rate [default=%default]") + parser.add_option("-t", "--threshold", type="float", default=-60, + help="Set the detection power threshold (dBm) [default=%default") parser.add_option("-T", "--trigger", action="store_true", default=False, help="Use internal trigger instead of detector [default=%default]") (options, args) = parser.parse_args() - frequency = options.freq - samp_rate = samp_rate = options.rate uhd_addr = options.address - trigger = options.trigger - tb = uhd_burst_detector(frequency, samp_rate, uhd_addr, trigger) + tb = uhd_burst_detector(uhd_addr, options) tb.run() -- cgit From 0c9ec724a6f5e1dc234bb8b3158726310a3bb0cb Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 9 Sep 2011 17:08:23 -0400 Subject: tags: adding tags examples to build distribution. --- gnuradio-examples/python/Makefile.am | 1 + gnuradio-examples/python/tags/.gitignore | 2 ++ gnuradio-examples/python/tags/Makefile.am | 29 +++++++++++++++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 gnuradio-examples/python/tags/.gitignore create mode 100644 gnuradio-examples/python/tags/Makefile.am (limited to 'gnuradio-examples/python') diff --git a/gnuradio-examples/python/Makefile.am b/gnuradio-examples/python/Makefile.am index 30effdf9a..65021729a 100644 --- a/gnuradio-examples/python/Makefile.am +++ b/gnuradio-examples/python/Makefile.am @@ -32,5 +32,6 @@ SUBDIRS = \ network \ ofdm \ pfb \ + tags \ usrp \ usrp2 diff --git a/gnuradio-examples/python/tags/.gitignore b/gnuradio-examples/python/tags/.gitignore new file mode 100644 index 000000000..b336cc7ce --- /dev/null +++ b/gnuradio-examples/python/tags/.gitignore @@ -0,0 +1,2 @@ +/Makefile +/Makefile.in diff --git a/gnuradio-examples/python/tags/Makefile.am b/gnuradio-examples/python/tags/Makefile.am new file mode 100644 index 000000000..5d71bf9b0 --- /dev/null +++ b/gnuradio-examples/python/tags/Makefile.am @@ -0,0 +1,29 @@ +# +# 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 + -- cgit From 801465fe8dbac9905ac74aeb5c3dc308d3328d98 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 23 Sep 2011 17:03:32 -0400 Subject: examples: fixed examples (pfb and tags) to print an error when python modules are not available. --- gnuradio-examples/python/pfb/channelize.py | 19 ++++++++--- gnuradio-examples/python/pfb/chirp_channelize.py | 19 ++++++++--- gnuradio-examples/python/pfb/decimate.py | 23 ++++++++----- gnuradio-examples/python/pfb/fmtest.py | 42 ++++++++++++++++++++---- gnuradio-examples/python/pfb/interpolate.py | 23 ++++++++----- gnuradio-examples/python/pfb/resampler.py | 34 ++++++++++++++++++- gnuradio-examples/python/pfb/synth_filter.py | 14 +++++++- gnuradio-examples/python/pfb/synth_to_chan.py | 14 +++++++- gnuradio-examples/python/tags/test_file_tags.py | 28 +++++++++++++++- 9 files changed, 181 insertions(+), 35 deletions(-) (limited to 'gnuradio-examples/python') diff --git a/gnuradio-examples/python/pfb/channelize.py b/gnuradio-examples/python/pfb/channelize.py index f845c05c6..999e5d20e 100755 --- a/gnuradio-examples/python/pfb/channelize.py +++ b/gnuradio-examples/python/pfb/channelize.py @@ -21,10 +21,21 @@ # from gnuradio import gr, blks2 -import os, time -import scipy, pylab -from scipy import fftpack -from pylab import mlab +import sys, time + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab + from pylab import mlab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) class pfb_top_block(gr.top_block): def __init__(self): diff --git a/gnuradio-examples/python/pfb/chirp_channelize.py b/gnuradio-examples/python/pfb/chirp_channelize.py index edebf5f59..951255d3b 100755 --- a/gnuradio-examples/python/pfb/chirp_channelize.py +++ b/gnuradio-examples/python/pfb/chirp_channelize.py @@ -21,10 +21,21 @@ # from gnuradio import gr, blks2 -import os, time -import scipy, pylab -from scipy import fftpack -from pylab import mlab +import sys, time + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab + from pylab import mlab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) class pfb_top_block(gr.top_block): def __init__(self): diff --git a/gnuradio-examples/python/pfb/decimate.py b/gnuradio-examples/python/pfb/decimate.py index cb5d61b72..643a2c241 100755 --- a/gnuradio-examples/python/pfb/decimate.py +++ b/gnuradio-examples/python/pfb/decimate.py @@ -21,14 +21,21 @@ # from gnuradio import gr, blks2 -import os -import scipy, pylab -from scipy import fftpack -from pylab import mlab -import time - -#print os.getpid() -#raw_input() +import sys, time + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab + from pylab import mlab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) class pfb_top_block(gr.top_block): def __init__(self): diff --git a/gnuradio-examples/python/pfb/fmtest.py b/gnuradio-examples/python/pfb/fmtest.py index 97df0e0f5..635ee4e9e 100755 --- a/gnuradio-examples/python/pfb/fmtest.py +++ b/gnuradio-examples/python/pfb/fmtest.py @@ -1,14 +1,42 @@ #!/usr/bin/env python # +# 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. +# + +from gnuradio import gr, blks2 +import sys, math, time + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) -from gnuradio import gr, eng_notation -from gnuradio import blks2 -from gnuradio.eng_option import eng_option -from optparse import OptionParser -import math, time, sys, scipy, pylab -from scipy import fftpack - class fmtx(gr.hier_block2): def __init__(self, lo_freq, audio_rate, if_rate): diff --git a/gnuradio-examples/python/pfb/interpolate.py b/gnuradio-examples/python/pfb/interpolate.py index a7a2522f8..370cf26a7 100755 --- a/gnuradio-examples/python/pfb/interpolate.py +++ b/gnuradio-examples/python/pfb/interpolate.py @@ -21,14 +21,21 @@ # from gnuradio import gr, blks2 -import os -import scipy, pylab -from scipy import fftpack -from pylab import mlab -import time - -#print os.getpid() -#raw_input() +import sys, time + +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab + from pylab import mlab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) class pfb_top_block(gr.top_block): def __init__(self): diff --git a/gnuradio-examples/python/pfb/resampler.py b/gnuradio-examples/python/pfb/resampler.py index 6be7cf14e..7b296ca71 100755 --- a/gnuradio-examples/python/pfb/resampler.py +++ b/gnuradio-examples/python/pfb/resampler.py @@ -1,7 +1,39 @@ #!/usr/bin/env python +# +# 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. +# from gnuradio import gr, blks2 -import scipy, pylab +import sys + +try: + import scipy +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) class mytb(gr.top_block): def __init__(self, fs_in, fs_out, fc, N=10000): diff --git a/gnuradio-examples/python/pfb/synth_filter.py b/gnuradio-examples/python/pfb/synth_filter.py index a1562f9ea..074d9cb2c 100755 --- a/gnuradio-examples/python/pfb/synth_filter.py +++ b/gnuradio-examples/python/pfb/synth_filter.py @@ -21,7 +21,19 @@ # from gnuradio import gr, blks2 -import scipy, pylab +import sys + +try: + import scipy +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) def main(): N = 1000000 diff --git a/gnuradio-examples/python/pfb/synth_to_chan.py b/gnuradio-examples/python/pfb/synth_to_chan.py index 1beda1a54..7e454d903 100755 --- a/gnuradio-examples/python/pfb/synth_to_chan.py +++ b/gnuradio-examples/python/pfb/synth_to_chan.py @@ -21,7 +21,19 @@ # from gnuradio import gr, blks2 -import scipy, pylab +import sys + +try: + import scipy +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + import pylab +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) def main(): N = 1000000 diff --git a/gnuradio-examples/python/tags/test_file_tags.py b/gnuradio-examples/python/tags/test_file_tags.py index 4ff4549ef..446986cd7 100755 --- a/gnuradio-examples/python/tags/test_file_tags.py +++ b/gnuradio-examples/python/tags/test_file_tags.py @@ -1,7 +1,33 @@ #!/usr/bin/env python +# +# 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. +# from gnuradio import gr -import scipy +import sys + +try: + import scipy +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) def main(): data = scipy.arange(0, 32000, 1).tolist() -- cgit From c825caf1a86c5cefd20fdd222d915011ef43fbae Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 23 Sep 2011 17:21:39 -0400 Subject: examples: fixed import statements. --- gnuradio-examples/python/ofdm/gr_plot_ofdm.py | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) (limited to 'gnuradio-examples/python') diff --git a/gnuradio-examples/python/ofdm/gr_plot_ofdm.py b/gnuradio-examples/python/ofdm/gr_plot_ofdm.py index e3b347189..b24855148 100755 --- a/gnuradio-examples/python/ofdm/gr_plot_ofdm.py +++ b/gnuradio-examples/python/ofdm/gr_plot_ofdm.py @@ -20,14 +20,24 @@ # Boston, MA 02110-1301, USA. # -import scipy, pylab, math -import struct, sys -from pylab import * -from matplotlib.font_manager import fontManager, FontProperties +import math, struct, sys from optparse import OptionParser -from scipy import fftpack from math import log10 +try: + import scipy + from scipy import fftpack +except ImportError: + print "Error: Program requires scipy (see: www.scipy.org)." + sys.exit(1) + +try: + from pylab import * + from matplotlib.font_manager import fontManager, FontProperties +except ImportError: + print "Error: Program requires matplotlib (see: matplotlib.sourceforge.net)." + sys.exit(1) + matplotlib.interactive(True) matplotlib.use('TkAgg') -- cgit