summaryrefslogtreecommitdiff
path: root/gr-filter/examples
diff options
context:
space:
mode:
authorAndrej Rode <mail@andrejro.de>2018-06-23 23:41:42 +0200
committerAndrej Rode <mail@andrejro.de>2018-06-24 00:03:35 +0200
commit167a6152bad060fc53dd29e0fa79ef83eff1be5b (patch)
treea01049672d9d7d1bf3d295ed96698a323941f8e8 /gr-filter/examples
parent3c8e6008b092287246234001db7cf1a4038300da (diff)
parentfcd002b6ac82e1e0c1224e24506410ff0833e1aa (diff)
Merge branch 'python3_fix' into next
Manual merge conflict resolution has been applied to following conflicts: * Typos: * gnuradio-runtime/python/gnuradio/ctrlport/GrDataPlotter.py * gr-blocks/python/blocks/qa_wavfile.py * gr-filter/examples/gr_filtdes_api.py * grc/blocks/parameter.xml * gr-uhd/python/uhd/__init__.py * ValueError -> RuntimeError: * gr-blocks/python/blocks/qa_hier_block2.py * relative Imports & other Py3k: * gr-digital/python/digital/psk_constellations.py * gr-digital/python/digital/qam_constellations.py * gr-digital/python/digital/test_soft_decisions.py * gr-digital/python/digital/gfsk.py * SequenceCompleter: * gr-utils/python/modtool/modtool_add.py * gr-utils/python/modtool/modtool_rename.py * gr-utils/python/modtool/modtool_rm.py * Updated API on next: * gr-blocks/grc/blocks_file_source.xml * gr-blocks/python/blocks/qa_file_source_sink.py * gr-qtgui/grc/qtgui_time_sink_x.xml * GRC Py3k Updates: * grc/core/Block.py * grc/core/Constants.py * grc/core/Platform.py * grc/core/utils/odict.py * grc/gui/Actions.py * grc/gui/Block.py * grc/gui/Executor.py * grc/gui/Port.py
Diffstat (limited to 'gr-filter/examples')
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/benchmark_filters.py6
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/channelize.py33
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/chirp_channelize.py29
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/decimate.py27
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/fft_filter_ccc.py13
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/fir_filter_ccc.py13
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/fir_filter_fff.py13
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/gr_filtdes_api.py10
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/gr_filtdes_callback.py14
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/gr_filtdes_live_upd.py6
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/gr_filtdes_restrict.py14
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/interpolate.py31
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/reconstruction.py19
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/resampler.py29
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/synth_filter.py9
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/synth_to_chan.py17
16 files changed, 163 insertions, 120 deletions
diff --git a/gr-filter/examples/benchmark_filters.py b/gr-filter/examples/benchmark_filters.py
index 4da6b9f5ad..0c7aebcf64 100755..100644
--- a/gr-filter/examples/benchmark_filters.py
+++ b/gr-filter/examples/benchmark_filters.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
import time
import random
from argparse import ArgumentParser
@@ -48,8 +50,8 @@ def benchmark(name, creator, dec, ntaps, total_test_size, block_size):
tb.run()
stop = time.time()
delta = stop - start
- print "%16s: taps: %4d input: %4g, time: %6.3f taps/sec: %10.4g" % (
- name, ntaps, total_test_size, delta, ntaps*total_test_size/delta)
+ print("%16s: taps: %4d input: %4g, time: %6.3f taps/sec: %10.4g" % (
+ name, ntaps, total_test_size, delta, ntaps*total_test_size/delta))
def main():
parser = ArgumentParser()
diff --git a/gr-filter/examples/channelize.py b/gr-filter/examples/channelize.py
index e70817e873..51f0bad20b 100755..100644
--- a/gr-filter/examples/channelize.py
+++ b/gr-filter/examples/channelize.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -60,10 +63,10 @@ class pfb_top_block(gr.top_block):
window=filter.firdes.WIN_BLACKMAN_hARRIS)
# Calculate the number of taps per channel for our own information
- tpc = scipy.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
+ tpc = scipy.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)
# Create a set of signals at different frequencies
# freqs lists the frequencies of the signals that get stored
@@ -71,8 +74,8 @@ class pfb_top_block(gr.top_block):
self.signals = list()
self.add = blocks.add_cc()
freqs = [-70, -50, -30, -10, 10, 20, 40, 60, 80]
- for i in xrange(len(freqs)):
- f = freqs[i] + (M/2-M+i+1)*self._fs
+ for i in range(len(freqs)):
+ f = freqs[i] + (M / 2-M+i+1)*self._fs
self.signals.append(analog.sig_source_c(self._ifs, analog.GR_SIN_WAVE, f, 1))
self.connect(self.signals[i], (self.add,i))
@@ -93,7 +96,7 @@ class pfb_top_block(gr.top_block):
# 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):
+ for i in range(self._M):
self.snks.append(blocks.vector_sink_c())
self.connect((self.pfb, i), self.snks[i])
@@ -105,7 +108,7 @@ def main():
tb.run()
tend = time.time()
- print "Run time: %f" % (tend - tstart)
+ print("Run time: %f" % (tend - tstart))
if 1:
fig_in = pylab.figure(1, figsize=(16,9), facecolor="w")
@@ -123,11 +126,11 @@ def main():
d = tb.snk_i.data()[Ns:Ne]
spin_f = fig_in.add_subplot(2, 1, 1)
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
X_in = 10.0*scipy.log10(abs(X))
- f_in = scipy.arange(-fs/2.0, fs/2.0, fs/float(X_in.size))
+ 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])
@@ -137,7 +140,7 @@ def main():
spin_f.set_ylabel("Power (dBW)")
- Ts = 1.0/fs
+ Ts = 1.0 / fs
Tmax = len(d)*Ts
t_in = scipy.arange(0, Tmax, Ts)
@@ -157,20 +160,20 @@ def main():
# Plot each of the channels outputs. Frequencies on Figure 2 and
# time signals on Figure 3
fs_o = tb._fs
- Ts_o = 1.0/fs_o
+ Ts_o = 1.0 / fs_o
Tmax_o = len(d)*Ts_o
- for i in xrange(len(tb.snks)):
+ for i in range(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 = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs_o,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
X_o = 10.0*scipy.log10(abs(X))
- f_o = scipy.arange(-fs_o/2.0, fs_o/2.0, fs_o/float(X_o.size))
+ 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])
diff --git a/gr-filter/examples/chirp_channelize.py b/gr-filter/examples/chirp_channelize.py
index aedd5c4892..471416b6a5 100755..100644
--- a/gr-filter/examples/chirp_channelize.py
+++ b/gr-filter/examples/chirp_channelize.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -59,17 +62,17 @@ class pfb_top_block(gr.top_block):
window=filter.firdes.WIN_BLACKMAN_hARRIS)
# Calculate the number of taps per channel for our own information
- tpc = scipy.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
+ tpc = scipy.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)
repeated = True
if(repeated):
self.vco_input = analog.sig_source_f(self._fs, analog.GR_SIN_WAVE, 0.25, 110)
else:
amp = 100
- data = scipy.arange(0, amp, amp/float(self._N))
+ data = scipy.arange(0, amp, amp / float(self._N))
self.vco_input = blocks.vector_source_f(data, False)
# Build a VCO controlled by either the sinusoid or single chirp tone
@@ -92,7 +95,7 @@ class pfb_top_block(gr.top_block):
# 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):
+ for i in range(self._M):
self.snks.append(blocks.vector_sink_c())
self.connect((self.pfb, i), self.snks[i])
@@ -104,7 +107,7 @@ def main():
tb.run()
tend = time.time()
- print "Run time: %f" % (tend - tstart)
+ print("Run time: %f" % (tend - tstart))
if 1:
fig_in = pylab.figure(1, figsize=(16,9), facecolor="w")
@@ -123,11 +126,11 @@ def main():
d = tb.snk_i.data()[Ns:Ne]
spin_f = fig_in.add_subplot(2, 1, 1)
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
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))
+ 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])
@@ -137,7 +140,7 @@ def main():
spin_f.set_ylabel("Power (dBW)")
- Ts = 1.0/fs
+ Ts = 1.0 / fs
Tmax = len(d)*Ts
t_in = scipy.arange(0, Tmax, Ts)
@@ -157,16 +160,16 @@ def main():
# Plot each of the channels outputs. Frequencies on Figure 2 and
# time signals on Figure 3
fs_o = tb._fs / tb._M
- Ts_o = 1.0/fs_o
+ Ts_o = 1.0 / fs_o
Tmax_o = len(d)*Ts_o
- for i in xrange(len(tb.snks)):
+ for i in range(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 = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs_o,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
X_o = 10.0*scipy.log10(abs(X))
diff --git a/gr-filter/examples/decimate.py b/gr-filter/examples/decimate.py
index 675073a431..fb37d8047e 100755..100644
--- a/gr-filter/examples/decimate.py
+++ b/gr-filter/examples/decimate.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -60,10 +63,10 @@ class pfb_top_block(gr.top_block):
window=filter.firdes.WIN_BLACKMAN_hARRIS)
# Calculate the number of taps per channel for our own information
- tpc = scipy.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
+ tpc = scipy.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)
# Build the input signal source
# We create a list of freqs, and a sine wave is generated and added to the source
@@ -71,7 +74,7 @@ class pfb_top_block(gr.top_block):
self.signals = list()
self.add = blocks.add_cc()
freqs = [10, 20, 2040]
- for i in xrange(len(freqs)):
+ for i in range(len(freqs)):
self.signals.append(analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freqs[i], 1))
self.connect(self.signals[i], (self.add,i))
@@ -100,7 +103,7 @@ def main():
tstart = time.time()
tb.run()
tend = time.time()
- print "Run time: %f" % (tend - tstart)
+ print("Run time: %f" % (tend - tstart))
if 1:
fig1 = pylab.figure(1, figsize=(16,9))
@@ -118,11 +121,11 @@ def main():
d = tb.snk_i.data()[Ns:Ns+Ne]
sp1_f = fig1.add_subplot(2, 1, 1)
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
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))
+ 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])
@@ -131,7 +134,7 @@ def main():
sp1_f.set_xlabel("Frequency (Hz)")
sp1_f.set_ylabel("Power (dBW)")
- Ts = 1.0/fs
+ Ts = 1.0 / fs
Tmax = len(d)*Ts
t_in = scipy.arange(0, Tmax, Ts)
@@ -150,11 +153,11 @@ def main():
sp2_f = fig2.add_subplot(2, 1, 1)
d = tb.snk.data()[Ns:Ns+Ne]
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs_o,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs_o,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
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))
+ 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])
@@ -164,7 +167,7 @@ def main():
sp2_f.set_ylabel("Power (dBW)")
- Ts_o = 1.0/fs_o
+ Ts_o = 1.0 / fs_o
Tmax_o = len(d)*Ts_o
x_o = scipy.array(d)
diff --git a/gr-filter/examples/fft_filter_ccc.py b/gr-filter/examples/fft_filter_ccc.py
index 92bcc7e316..6cadddee1f 100755..100644
--- a/gr-filter/examples/fft_filter_ccc.py
+++ b/gr-filter/examples/fft_filter_ccc.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr, filter
from gnuradio import analog
from gnuradio import blocks
@@ -31,13 +34,13 @@ import sys
try:
import scipy
except ImportError:
- print "Error: could not import scipy (http://www.scipy.org/)"
+ print("Error: could not import scipy (http://www.scipy.org/)")
sys.exit(1)
try:
import pylab
except ImportError:
- print "Error: could not import pylab (http://matplotlib.sourceforge.net/)"
+ print("Error: could not import pylab (http://matplotlib.sourceforge.net/)")
sys.exit(1)
class example_fft_filter_ccc(gr.top_block):
@@ -54,7 +57,7 @@ class example_fft_filter_ccc(gr.top_block):
taps = filter.firdes.complex_band_pass_2(1, self._fs,
self._bw0, self._bw1,
self._tw, self._at)
- print "Num. Taps: ", len(taps)
+ print("Num. Taps: ", len(taps))
self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps)
@@ -101,9 +104,9 @@ def main():
nfft = 1024
f1 = pylab.figure(1, figsize=(12,10))
s1 = f1.add_subplot(1,1,1)
- s1.psd(data_src, NFFT=nfft, noverlap=nfft/4,
+ s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
- s1.psd(data_snk, NFFT=nfft, noverlap=nfft/4,
+ s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
f2 = pylab.figure(2, figsize=(12,10))
diff --git a/gr-filter/examples/fir_filter_ccc.py b/gr-filter/examples/fir_filter_ccc.py
index 357e3d7111..fe5e7e0254 100755..100644
--- a/gr-filter/examples/fir_filter_ccc.py
+++ b/gr-filter/examples/fir_filter_ccc.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr, filter
from gnuradio import analog
from gnuradio import blocks
@@ -31,13 +34,13 @@ import sys
try:
import scipy
except ImportError:
- print "Error: could not import scipy (http://www.scipy.org/)"
+ print("Error: could not import scipy (http://www.scipy.org/)")
sys.exit(1)
try:
import pylab
except ImportError:
- print "Error: could not import pylab (http://matplotlib.sourceforge.net/)"
+ print("Error: could not import pylab (http://matplotlib.sourceforge.net/)")
sys.exit(1)
class example_fir_filter_ccc(gr.top_block):
@@ -51,7 +54,7 @@ class example_fir_filter_ccc(gr.top_block):
self._at = atten
self._decim = D
taps = filter.firdes.low_pass_2(1, self._fs, self._bw, self._tw, self._at)
- print "Num. Taps: ", len(taps)
+ print("Num. Taps: ", len(taps))
self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1)
self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps)
@@ -95,9 +98,9 @@ def main():
nfft = 1024
f1 = pylab.figure(1, figsize=(12,10))
s1 = f1.add_subplot(1,1,1)
- s1.psd(data_src, NFFT=nfft, noverlap=nfft/4,
+ s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
- s1.psd(data_snk, NFFT=nfft, noverlap=nfft/4,
+ s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
f2 = pylab.figure(2, figsize=(12,10))
diff --git a/gr-filter/examples/fir_filter_fff.py b/gr-filter/examples/fir_filter_fff.py
index 2019215f12..c4c9ea2c83 100755..100644
--- a/gr-filter/examples/fir_filter_fff.py
+++ b/gr-filter/examples/fir_filter_fff.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr, filter
from gnuradio import analog
from gnuradio import blocks
@@ -31,13 +34,13 @@ import sys
try:
import scipy
except ImportError:
- print "Error: could not import scipy (http://www.scipy.org/)"
+ print("Error: could not import scipy (http://www.scipy.org/)")
sys.exit(1)
try:
import pylab
except ImportError:
- print "Error: could not import pylab (http://matplotlib.sourceforge.net/)"
+ print("Error: could not import pylab (http://matplotlib.sourceforge.net/)")
sys.exit(1)
class example_fir_filter_fff(gr.top_block):
@@ -51,7 +54,7 @@ class example_fir_filter_fff(gr.top_block):
self._at = atten
self._decim = D
taps = filter.firdes.low_pass_2(1, self._fs, self._bw, self._tw, self._at)
- print "Num. Taps: ", len(taps)
+ print("Num. Taps: ", len(taps))
self.src = analog.noise_source_f(analog.GR_GAUSSIAN, 1)
self.head = blocks.head(gr.sizeof_float, self._nsamps)
@@ -95,9 +98,9 @@ def main():
nfft = 1024
f1 = pylab.figure(1, figsize=(12,10))
s1 = f1.add_subplot(1,1,1)
- s1.psd(data_src, NFFT=nfft, noverlap=nfft/4,
+ s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
- s1.psd(data_snk, NFFT=nfft, noverlap=nfft/4,
+ s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4,
Fs=args.samplerate)
f2 = pylab.figure(2, figsize=(12,10))
diff --git a/gr-filter/examples/gr_filtdes_api.py b/gr-filter/examples/gr_filtdes_api.py
index 9e9cb1df49..162b33e7b9 100755..100644
--- a/gr-filter/examples/gr_filtdes_api.py
+++ b/gr-filter/examples/gr_filtdes_api.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio.filter import filter_design
import sys
@@ -31,7 +33,7 @@ returns b,a for IIR filter design
filtobj = filter_design.launch(sys.argv)
# Displaying all filter parameters
-print "Filter Count:", filtobj.get_filtercount()
-print "Filter type:", filtobj.get_restype()
-print "Filter params", filtobj.get_params()
-print "Filter Coefficients", filtobj.get_taps()
+print("Filter Count:", filtobj.get_filtercount())
+print("Filter type:", filtobj.get_restype())
+print("Filter params", filtobj.get_params())
+print("Filter Coefficients", filtobj.get_taps())
diff --git a/gr-filter/examples/gr_filtdes_callback.py b/gr-filter/examples/gr_filtdes_callback.py
index 9496253d7a..d99edffc46 100755..100644
--- a/gr-filter/examples/gr_filtdes_callback.py
+++ b/gr-filter/examples/gr_filtdes_callback.py
@@ -20,13 +20,15 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio.filter import filter_design
import sys
try:
from PyQt4 import Qt, QtCore, QtGui
except ImportError:
- print "Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)"
- raise SystemExit, 1
+ print("Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)")
+ raise SystemExit(1)
'''
Callback example
@@ -36,10 +38,10 @@ launch function returns gr_filter_design mainwindow
object when callback is not None
'''
def print_params(filtobj):
- print "Filter Count:", filtobj.get_filtercount()
- print "Filter type:", filtobj.get_restype()
- print "Filter params", filtobj.get_params()
- print "Filter Coefficients", filtobj.get_taps()
+ print("Filter Count:", filtobj.get_filtercount())
+ print("Filter type:", filtobj.get_restype())
+ print("Filter params", filtobj.get_params())
+ print("Filter Coefficients", filtobj.get_taps())
app = Qt.QApplication(sys.argv)
#launch function returns gr_filter_design mainwindow object
diff --git a/gr-filter/examples/gr_filtdes_live_upd.py b/gr-filter/examples/gr_filtdes_live_upd.py
index 9f974dd81c..ca925eb9b4 100755..100644
--- a/gr-filter/examples/gr_filtdes_live_upd.py
+++ b/gr-filter/examples/gr_filtdes_live_upd.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio.filter import filter_design
from gnuradio import gr, filter
from gnuradio import blocks
@@ -89,8 +91,8 @@ class my_top_block(gr.top_block):
pyWin.show()
def update_filter(self, filtobj):
- print "Filter type:", filtobj.get_restype()
- print "Filter params", filtobj.get_params()
+ print("Filter type:", filtobj.get_restype())
+ print("Filter params", filtobj.get_params())
self.filt.set_taps(filtobj.get_taps())
if __name__ == "__main__":
diff --git a/gr-filter/examples/gr_filtdes_restrict.py b/gr-filter/examples/gr_filtdes_restrict.py
index 1613cc6489..c18d4c1f04 100755..100644
--- a/gr-filter/examples/gr_filtdes_restrict.py
+++ b/gr-filter/examples/gr_filtdes_restrict.py
@@ -20,13 +20,15 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import unicode_literals
from gnuradio.filter import filter_design
import sys
try:
from PyQt4 import Qt, QtCore, QtGui
except ImportError:
- print "Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)"
- raise SystemExit, 1
+ print("Please install PyQt4 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)")
+ raise SystemExit(1)
'''
@@ -35,10 +37,10 @@ Function called when "design" button is pressed
or pole-zero plot is changed
'''
def print_params(filtobj):
- print "Filter Count:", filtobj.get_filtercount()
- print "Filter type:", filtobj.get_restype()
- print "Filter params", filtobj.get_params()
- print "Filter Coefficients", filtobj.get_taps()
+ print("Filter Count:", filtobj.get_filtercount())
+ print("Filter type:", filtobj.get_restype())
+ print("Filter params", filtobj.get_params())
+ print("Filter Coefficients", filtobj.get_taps())
app = Qt.QApplication(sys.argv)
main_win = filter_design.launch(sys.argv, callback = print_params, restype = "iir")
diff --git a/gr-filter/examples/interpolate.py b/gr-filter/examples/interpolate.py
index 40bab7b1f1..1f1357211b 100755..100644
--- a/gr-filter/examples/interpolate.py
+++ b/gr-filter/examples/interpolate.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -79,10 +82,10 @@ class pfb_top_block(gr.top_block):
window=filter.firdes.WIN_BLACKMAN_hARRIS)
# Calculate the number of taps per channel for our own information
- tpc = scipy.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
+ tpc = scipy.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)
# Create a couple of signals at different frequencies
self.signal1 = analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freq1, 0.5)
@@ -121,7 +124,7 @@ def main():
tstart = time.time()
tb.run()
tend = time.time()
- print "Run time: %f" % (tend - tstart)
+ print("Run time: %f" % (tend - tstart))
if 1:
@@ -141,11 +144,11 @@ def main():
d = tb.snk_i.data()[Ns:Ns+Ne]
sp1_f = fig1.add_subplot(2, 1, 1)
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
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))
+ 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])
@@ -155,7 +158,7 @@ def main():
sp1_f.set_xlabel("Frequency (Hz)")
sp1_f.set_ylabel("Power (dBW)")
- Ts = 1.0/fs
+ Ts = 1.0 / fs
Tmax = len(d)*Ts
t_in = scipy.arange(0, Tmax, Ts)
@@ -175,11 +178,11 @@ def main():
sp2_f = fig2.add_subplot(2, 1, 1)
d = tb.snk1.data()[Ns:Ns+(tb._interp*Ne)]
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
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))
+ 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])
@@ -188,7 +191,7 @@ def main():
sp2_f.set_xlabel("Frequency (Hz)")
sp2_f.set_ylabel("Power (dBW)")
- Ts_int = 1.0/fs_int
+ Ts_int = 1.0 / fs_int
Tmax = len(d)*Ts_int
t_o = scipy.arange(0, Tmax, Ts_int)
@@ -208,11 +211,11 @@ def main():
sp3_f = fig3.add_subplot(2, 1, 1)
d = tb.snk2.data()[Ns:Ns+(tb._interp*Ne)]
- X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen/4, Fs=fs,
+ X,freq = mlab.psd(d, NFFT=fftlen, noverlap=fftlen / 4, Fs=fs,
window = lambda d: d*winfunc(fftlen),
scale_by_freq=True)
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))
+ 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])
@@ -221,7 +224,7 @@ def main():
sp3_f.set_xlabel("Frequency (Hz)")
sp3_f.set_ylabel("Power (dBW)")
- Ts_aint = 1.0/fs_aint
+ Ts_aint = 1.0 / fs_aint
Tmax = len(d)*Ts_aint
t_o = scipy.arange(0, Tmax, Ts_aint)
diff --git a/gr-filter/examples/reconstruction.py b/gr-filter/examples/reconstruction.py
index 0a83b5a4e0..c9c1cd3922 100755..100644
--- a/gr-filter/examples/reconstruction.py
+++ b/gr-filter/examples/reconstruction.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr, digital
from gnuradio import filter
from gnuradio import blocks
@@ -28,20 +31,20 @@ import sys
try:
from gnuradio import channels
except ImportError:
- print "Error: Program requires gr-channels."
+ print("Error: Program requires gr-channels.")
sys.exit(1)
try:
import scipy
from scipy import fftpack
except ImportError:
- print "Error: Program requires scipy (see: www.scipy.org)."
+ 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)."
+ print("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).")
sys.exit(1)
fftlen = 8192
@@ -49,7 +52,7 @@ fftlen = 8192
def main():
N = 10000
fs = 2000.0
- Ts = 1.0/fs
+ Ts = 1.0 / fs
t = scipy.arange(0, N*Ts, Ts)
# When playing with the number of channels, be careful about the filter
@@ -62,7 +65,7 @@ def main():
proto_taps = filter.firdes.low_pass_2(1, nchans*fs,
bw, tb, 80,
filter.firdes.WIN_BLACKMAN_hARRIS)
- print "Filter length: ", len(proto_taps)
+ print("Filter length: ", len(proto_taps))
# Create a modulated signal
@@ -95,7 +98,7 @@ def main():
tb.connect(rrc, src_snk)
vsnk = []
- for i in xrange(nchans):
+ for i in range(nchans):
tb.connect((channelizer,i), (synthesizer, i))
vsnk.append(blocks.vector_sink_c())
@@ -131,10 +134,10 @@ def main():
# Plot channels
nrows = int(scipy.sqrt(nchans))
- ncols = int(scipy.ceil(float(nchans)/float(nrows)))
+ ncols = int(scipy.ceil(float(nchans) / float(nrows)))
f2 = pylab.figure(2, figsize=(16,12), facecolor='w')
- for n in xrange(nchans):
+ for n in range(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))
diff --git a/gr-filter/examples/resampler.py b/gr-filter/examples/resampler.py
index e329f062d0..29b25629cc 100755..100644
--- a/gr-filter/examples/resampler.py
+++ b/gr-filter/examples/resampler.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import filter
from gnuradio import blocks
@@ -48,7 +51,7 @@ class mytb(gr.top_block):
gr.top_block.__init__(self)
rerate = float(fs_out) / float(fs_in)
- print "Resampling from %f to %f by %f " %(fs_in, fs_out, rerate)
+ print("Resampling from %f to %f by %f " %(fs_in, fs_out, rerate))
# Creating our own taps
taps = filter.firdes.low_pass_2(32, 32, 0.25, 0.1, 80)
@@ -91,31 +94,31 @@ def main():
fig1 = pylab.figure(1, figsize=(10,10), facecolor="w")
sp1 = fig1.add_subplot(2,1,1)
sp1.psd(tb.snk_in.data(), NFFT=nfftsize,
- noverlap=nfftsize/4, Fs = fs_in)
- sp1.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in/1000.0)))
- sp1.set_xlim([-fs_in/2, fs_in/2])
+ noverlap=nfftsize / 4, Fs = fs_in)
+ sp1.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in / 1000.0)))
+ sp1.set_xlim([-fs_in / 2, fs_in / 2])
sp2 = fig1.add_subplot(2,1,2)
sp2.psd(tb.snk_0.data(), NFFT=nfftsize,
- noverlap=nfftsize/4, Fs = fs_out,
+ noverlap=nfftsize / 4, Fs = fs_out,
label="With our filter")
sp2.psd(tb.snk_1.data(), NFFT=nfftsize,
- noverlap=nfftsize/4, Fs = fs_out,
+ noverlap=nfftsize / 4, Fs = fs_out,
label="With auto-generated filter")
- sp2.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out/1000.0)))
- sp2.set_xlim([-fs_out/2, fs_out/2])
+ sp2.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out / 1000.0)))
+ sp2.set_xlim([-fs_out / 2, fs_out / 2])
sp2.legend()
# Plot signals in time
- Ts_in = 1.0/fs_in
- Ts_out = 1.0/fs_out
+ Ts_in = 1.0 / fs_in
+ Ts_out = 1.0 / fs_out
t_in = scipy.arange(0, len(tb.snk_in.data())*Ts_in, Ts_in)
t_out = scipy.arange(0, len(tb.snk_0.data())*Ts_out, Ts_out)
fig2 = pylab.figure(2, figsize=(10,10), facecolor="w")
sp21 = fig2.add_subplot(2,1,1)
sp21.plot(t_in, tb.snk_in.data())
- sp21.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in/1000.0)))
+ sp21.set_title(("Input Signal at f_s=%.2f kHz" % (fs_in / 1000.0)))
sp21.set_xlim([t_in[100], t_in[200]])
sp22 = fig2.add_subplot(2,1,2)
@@ -123,8 +126,8 @@ def main():
label="With our filter")
sp22.plot(t_out, tb.snk_1.data(),
label="With auto-generated filter")
- sp22.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out/1000.0)))
- r = float(fs_out)/float(fs_in)
+ sp22.set_title(("Output Signals at f_s=%.2f kHz" % (fs_out / 1000.0)))
+ r = float(fs_out) / float(fs_in)
sp22.set_xlim([t_out[r * 100], t_out[r * 200]])
sp22.legend()
diff --git a/gr-filter/examples/synth_filter.py b/gr-filter/examples/synth_filter.py
index 5382127b35..b971c4a641 100755..100644
--- a/gr-filter/examples/synth_filter.py
+++ b/gr-filter/examples/synth_filter.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import filter
from gnuradio import blocks
@@ -57,8 +60,8 @@ def main():
taps = filter.firdes.low_pass_2(len(freqs), fs,
fs/float(nchans)/2, 100, 100)
- print "Num. Taps = %d (taps per filter = %d)" % (len(taps),
- len(taps)/nchans)
+ print("Num. Taps = %d (taps per filter = %d)" % (len(taps),
+ len(taps) / nchans))
filtbank = filter.pfb_synthesizer_ccf(nchans, taps)
head = blocks.head(gr.sizeof_gr_complex, N)
@@ -83,7 +86,7 @@ def main():
winfunc = scipy.blackman
s2.psd(snk.data()[10000:], NFFT=fftlen,
Fs = nchans*fs,
- noverlap=fftlen/4,
+ noverlap=fftlen / 4,
window = lambda d: d*winfunc(fftlen))
pylab.show()
diff --git a/gr-filter/examples/synth_to_chan.py b/gr-filter/examples/synth_to_chan.py
index 88fb080a65..f1f1da4ec1 100755..100644
--- a/gr-filter/examples/synth_to_chan.py
+++ b/gr-filter/examples/synth_to_chan.py
@@ -20,6 +20,9 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+from __future__ import division
+from __future__ import unicode_literals
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
@@ -59,11 +62,11 @@ def main():
fmtx.append(fm)
syntaps = filter.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100)
- print "Synthesis Num. Taps = %d (taps per filter = %d)" % (len(syntaps),
- len(syntaps)/nchans)
+ print("Synthesis Num. Taps = %d (taps per filter = %d)" % (len(syntaps),
+ len(syntaps) / nchans))
chtaps = filter.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100)
- print "Channelizer Num. Taps = %d (taps per filter = %d)" % (len(chtaps),
- len(chtaps)/nchans)
+ print("Channelizer Num. Taps = %d (taps per filter = %d)" % (len(chtaps),
+ len(chtaps) / nchans))
filtbank = filter.pfb_synthesizer_ccf(nchans, syntaps)
channelizer = filter.pfb.channelizer_ccf(nchans, chtaps)
@@ -84,7 +87,7 @@ def main():
for i,si in enumerate(sigs):
tb.connect(si, fmtx[i], (filtbank, i))
- for i in xrange(nchans):
+ for i in range(nchans):
snk.append(blocks.vector_sink_c())
tb.connect((channelizer, i), snk[i])
@@ -107,7 +110,7 @@ def main():
s2 = f2.add_subplot(1,1,1)
s2.psd(data, NFFT=fftlen,
Fs = nchans*fs,
- noverlap=fftlen/4,
+ noverlap=fftlen / 4,
window = lambda d: d*winfunc(fftlen))
s2.set_title(("Output PSD from Channel %d" % channel))
@@ -115,7 +118,7 @@ def main():
s3 = f3.add_subplot(1,1,1)
s3.psd(snk_synth.data()[1000:], NFFT=fftlen,
Fs = nchans*fs,
- noverlap=fftlen/4,
+ noverlap=fftlen / 4,
window = lambda d: d*winfunc(fftlen))
s3.set_title("Output of Synthesis Filter")