summaryrefslogtreecommitdiff
path: root/gr-filter/examples/channelize.py
diff options
context:
space:
mode:
Diffstat (limited to 'gr-filter/examples/channelize.py')
-rw-r--r--[-rwxr-xr-x]gr-filter/examples/channelize.py33
1 files changed, 18 insertions, 15 deletions
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])