diff options
author | Douglas Anderson <danderson@ntia.doc.gov> | 2017-02-12 15:52:19 -0800 |
---|---|---|
committer | Johnathan Corgan <johnathan@corganlabs.com> | 2017-02-26 18:21:22 -0800 |
commit | 9e625c4821f4c63421b3d3747c0c4f358fef6c5f (patch) | |
tree | 41dedbe053417be7314cdce15d64fbbb89db4d8d /gr-filter/examples/resampler.py | |
parent | e5aabcc6a4a9335f3ef8abf5f89104b626e9364d (diff) |
python3: update non-GRC components to use python2 or python3
Diffstat (limited to 'gr-filter/examples/resampler.py')
-rw-r--r--[-rwxr-xr-x] | gr-filter/examples/resampler.py | 29 |
1 files changed, 16 insertions, 13 deletions
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() |