diff options
author | Josh Morman <jmorman@gnuradio.org> | 2021-11-24 12:34:58 -0500 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-11-24 14:41:53 -0500 |
commit | 09cd2d7cccf0a472ee2623c4a388a4ce950c0c5c (patch) | |
tree | 69655be1c0d244a68c1fe054969263d27ef99c07 /gr-filter | |
parent | b4aaa48f69239e16341a59628ca7795cfeebb4da (diff) |
filter: pep8 formatting
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'gr-filter')
33 files changed, 1819 insertions, 1262 deletions
diff --git a/gr-filter/examples/benchmark_filters.py b/gr-filter/examples/benchmark_filters.py index f447065105..2cecc57f71 100644 --- a/gr-filter/examples/benchmark_filters.py +++ b/gr-filter/examples/benchmark_filters.py @@ -15,13 +15,15 @@ from gnuradio import gr from gnuradio import blocks, filter from gnuradio.eng_arg import eng_float, intx + def make_random_complex_tuple(L): result = [] for x in range(L): - result.append(complex(random.uniform(-1000,1000), - random.uniform(-1000,1000))) + result.append(complex(random.uniform(-1000, 1000), + random.uniform(-1000, 1000))) return tuple(result) + def benchmark(name, creator, dec, ntaps, total_test_size, block_size): block_size = 32768 @@ -37,12 +39,14 @@ def benchmark(name, creator, dec, ntaps, total_test_size, block_size): 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)) + name, ntaps, total_test_size, delta, ntaps * total_test_size / delta)) + def main(): parser = ArgumentParser() parser.add_argument("-n", "--ntaps", type=int, default=256) - parser.add_argument("-t", "--total-input-size", type=eng_float, default=40e6) + parser.add_argument("-t", "--total-input-size", + type=eng_float, default=40e6) parser.add_argument("-b", "--block-size", type=intx, default=50000) parser.add_argument("-d", "--decimation", type=int, default=1) args = parser.parse_args() @@ -52,5 +56,6 @@ def main(): benchmark("filter.fft_filter_ccc", filter.fft_filter_ccc, args.decimation, args.ntaps, args.total_input_size, args.block_size) + if __name__ == '__main__': main() diff --git a/gr-filter/examples/channelize.py b/gr-filter/examples/channelize.py index 4d92bdce3f..83e85bc9c1 100644 --- a/gr-filter/examples/channelize.py +++ b/gr-filter/examples/channelize.py @@ -12,7 +12,8 @@ from gnuradio import gr from gnuradio import blocks from gnuradio import filter from gnuradio.fft import window -import sys, time +import sys +import time import numpy try: @@ -25,9 +26,11 @@ try: import pylab from pylab import mlab except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + class pfb_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) @@ -35,7 +38,7 @@ class pfb_top_block(gr.top_block): self._N = 2000000 # number of samples to use self._fs = 1000 # initial sampling rate self._M = M = 9 # Number of channels to channelize - self._ifs = M*self._fs # initial sampling rate + self._ifs = M * self._fs # initial sampling rate # Create a set of taps for the PFB channelizer self._taps = filter.firdes.low_pass_2(1, self._ifs, 475.50, 50, @@ -55,9 +58,10 @@ class pfb_top_block(gr.top_block): self.add = blocks.add_cc() freqs = [-70, -50, -30, -10, 10, 20, 40, 60, 80] 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)) + 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)) self.head = blocks.head(gr.sizeof_gr_complex, self._N) @@ -72,7 +76,7 @@ class pfb_top_block(gr.top_block): 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]) + # 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() @@ -91,9 +95,9 @@ def main(): print("Run time: %f" % (tend - tstart)) if 1: - fig_in = pylab.figure(1, figsize=(16,9), facecolor="w") - fig1 = pylab.figure(2, figsize=(16,9), facecolor="w") - fig2 = pylab.figure(3, figsize=(16,9), facecolor="w") + fig_in = pylab.figure(1, figsize=(16, 9), facecolor="w") + fig1 = pylab.figure(2, figsize=(16, 9), facecolor="w") + fig2 = pylab.figure(3, figsize=(16, 9), facecolor="w") Ns = 1000 Ne = 10000 @@ -106,22 +110,21 @@ 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*numpy.log10(abs(X)) + 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 * numpy.log10(abs(X)) f_in = numpy.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_xlim([min(f_in), max(f_in) + 1]) spin_f.set_ylim([-200.0, 50.0]) spin_f.set_title("Input Signal", weight="bold") spin_f.set_xlabel("Frequency (Hz)") spin_f.set_ylabel("Power (dBW)") - Ts = 1.0 / fs - Tmax = len(d)*Ts + Tmax = len(d) * Ts t_in = numpy.arange(0, Tmax, Ts) x_in = numpy.array(d) @@ -141,21 +144,21 @@ def main(): # time signals on Figure 3 fs_o = tb._fs Ts_o = 1.0 / fs_o - Tmax_o = len(d)*Ts_o + Tmax_o = len(d) * Ts_o 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*numpy.log10(abs(X)) + sp1_f = fig1.add_subplot(Nrows, Ncols, 1 + i) + 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 * numpy.log10(abs(X)) f_o = numpy.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_xlim([min(f_o), max(f_o) + 1]) sp1_f.set_ylim([-200.0, 50.0]) sp1_f.set_title(("Channel %d" % i), weight="bold") @@ -164,10 +167,10 @@ def main(): x_o = numpy.array(d) t_o = numpy.arange(0, Tmax_o, Ts_o) - sp2_o = fig2.add_subplot(Nrows, Ncols, 1+i) + sp2_o = fig2.add_subplot(Nrows, Ncols, 1 + i) p2_o = sp2_o.plot(t_o, x_o.real, "b") p2_o = sp2_o.plot(t_o, x_o.imag, "r") - sp2_o.set_xlim([min(t_o), max(t_o)+1]) + sp2_o.set_xlim([min(t_o), max(t_o) + 1]) sp2_o.set_ylim([-2, 2]) sp2_o.set_title(("Channel %d" % i), weight="bold") @@ -182,4 +185,3 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/chirp_channelize.py b/gr-filter/examples/chirp_channelize.py index 03efcf873f..d37e35cb8d 100644 --- a/gr-filter/examples/chirp_channelize.py +++ b/gr-filter/examples/chirp_channelize.py @@ -12,7 +12,8 @@ from gnuradio import gr from gnuradio import blocks from gnuradio import filter from gnuradio.fft import window -import sys, time +import sys +import time import numpy try: @@ -25,9 +26,11 @@ try: import pylab from pylab import mlab except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + class pfb_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) @@ -49,7 +52,8 @@ class pfb_top_block(gr.top_block): repeated = True if(repeated): - self.vco_input = analog.sig_source_f(self._fs, analog.GR_SIN_WAVE, 0.25, 110) + self.vco_input = analog.sig_source_f( + self._fs, analog.GR_SIN_WAVE, 0.25, 110) else: amp = 100 data = numpy.arange(0, amp, amp / float(self._N)) @@ -90,10 +94,10 @@ def main(): print("Run time: %f" % (tend - tstart)) if 1: - fig_in = pylab.figure(1, figsize=(16,9), facecolor="w") - fig1 = pylab.figure(2, figsize=(16,9), facecolor="w") - fig2 = pylab.figure(3, figsize=(16,9), facecolor="w") - fig3 = pylab.figure(4, figsize=(16,9), facecolor="w") + fig_in = pylab.figure(1, figsize=(16, 9), facecolor="w") + fig1 = pylab.figure(2, figsize=(16, 9), facecolor="w") + fig2 = pylab.figure(3, figsize=(16, 9), facecolor="w") + fig3 = pylab.figure(4, figsize=(16, 9), facecolor="w") Ns = 650 Ne = 20000 @@ -106,22 +110,21 @@ 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*numpy.log10(abs(numpy.fft.fftshift(X))) + 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 * numpy.log10(abs(numpy.fft.fftshift(X))) f_in = numpy.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_xlim([min(f_in), max(f_in) + 1]) spin_f.set_ylim([-200.0, 50.0]) spin_f.set_title("Input Signal", weight="bold") spin_f.set_xlabel("Frequency (Hz)") spin_f.set_ylabel("Power (dBW)") - Ts = 1.0 / fs - Tmax = len(d)*Ts + Tmax = len(d) * Ts t_in = numpy.arange(0, Tmax, Ts) x_in = numpy.array(d) @@ -141,21 +144,21 @@ def main(): # time signals on Figure 3 fs_o = tb._fs / tb._M Ts_o = 1.0 / fs_o - Tmax_o = len(d)*Ts_o + Tmax_o = len(d) * Ts_o 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*numpy.log10(abs(X)) + sp1_f = fig1.add_subplot(Nrows, Ncols, 1 + i) + 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 * numpy.log10(abs(X)) f_o = freq p2_f = sp1_f.plot(f_o, X_o, "b") - sp1_f.set_xlim([min(f_o), max(f_o)+1]) + sp1_f.set_xlim([min(f_o), max(f_o) + 1]) sp1_f.set_ylim([-200.0, 50.0]) sp1_f.set_title(("Channel %d" % i), weight="bold") @@ -164,20 +167,19 @@ def main(): x_o = numpy.array(d) t_o = numpy.arange(0, Tmax_o, Ts_o) - sp2_o = fig2.add_subplot(Nrows, Ncols, 1+i) + sp2_o = fig2.add_subplot(Nrows, Ncols, 1 + i) p2_o = sp2_o.plot(t_o, x_o.real, "b") p2_o = sp2_o.plot(t_o, x_o.imag, "r") - sp2_o.set_xlim([min(t_o), max(t_o)+1]) + sp2_o.set_xlim([min(t_o), max(t_o) + 1]) sp2_o.set_ylim([-2, 2]) sp2_o.set_title(("Channel %d" % i), weight="bold") sp2_o.set_xlabel("Time (s)") sp2_o.set_ylabel("Amplitude") - - sp3 = fig3.add_subplot(1,1,1) + sp3 = fig3.add_subplot(1, 1, 1) p3 = sp3.plot(t_o, x_o.real) - sp3.set_xlim([min(t_o), max(t_o)+1]) + sp3.set_xlim([min(t_o), max(t_o) + 1]) sp3.set_ylim([-2, 2]) sp3.set_title("All Channels") @@ -192,4 +194,3 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/decimate.py b/gr-filter/examples/decimate.py index 8e2f3c7c36..f291e51eb4 100644 --- a/gr-filter/examples/decimate.py +++ b/gr-filter/examples/decimate.py @@ -12,7 +12,8 @@ from gnuradio import gr from gnuradio import blocks from gnuradio import filter from gnuradio.fft import window -import sys, time +import sys +import time import numpy try: @@ -26,9 +27,11 @@ try: from matplotlib import pyplot from matplotlib import pyplot as mlab except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + class pfb_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) @@ -56,8 +59,9 @@ class pfb_top_block(gr.top_block): self.add = blocks.add_cc() freqs = [10, 20, 2040] 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)) + self.signals.append(analog.sig_source_c( + self._fs, analog.GR_SIN_WAVE, freqs[i], 1)) + self.connect(self.signals[i], (self.add, i)) self.head = blocks.head(gr.sizeof_gr_complex, self._N) @@ -87,8 +91,8 @@ def main(): print("Run time: %f" % (tend - tstart)) if 1: - fig1 = pyplot.figure(1, figsize=(16,9)) - fig2 = pyplot.figure(2, figsize=(16,9)) + fig1 = pyplot.figure(1, figsize=(16, 9)) + fig2 = pyplot.figure(2, figsize=(16, 9)) Ns = 10000 Ne = 10000 @@ -99,16 +103,16 @@ def main(): # Plot the input to the decimator - d = tb.snk_i.data()[Ns:Ns+Ne] + 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*numpy.log10(abs(numpy.fft.fftshift(X))) + 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 * numpy.log10(abs(numpy.fft.fftshift(X))) f_in = numpy.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_xlim([min(f_in), max(f_in) + 1]) sp1_f.set_ylim([-200.0, 50.0]) sp1_f.set_title("Input Signal", weight="bold") @@ -116,40 +120,38 @@ def main(): sp1_f.set_ylabel("Power (dBW)") Ts = 1.0 / fs - Tmax = len(d)*Ts + Tmax = len(d) * Ts t_in = numpy.arange(0, Tmax, Ts) x_in = numpy.array(d) sp1_t = fig1.add_subplot(2, 1, 2) p1_t = sp1_t.plot(t_in, x_in.real, "b") p1_t = sp1_t.plot(t_in, x_in.imag, "r") - sp1_t.set_ylim([-tb._decim*1.1, tb._decim*1.1]) + sp1_t.set_ylim([-tb._decim * 1.1, tb._decim * 1.1]) sp1_t.set_xlabel("Time (s)") sp1_t.set_ylabel("Amplitude") - # Plot the output of the decimator fs_o = tb._fs / tb._decim 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*numpy.log10(abs(numpy.fft.fftshift(X))) + d = tb.snk.data()[Ns:Ns + Ne] + 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 * numpy.log10(abs(numpy.fft.fftshift(X))) f_o = numpy.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_xlim([min(f_o), max(f_o) + 1]) sp2_f.set_ylim([-200.0, 50.0]) sp2_f.set_title("PFB Decimated Signal", weight="bold") sp2_f.set_xlabel("Frequency (Hz)") sp2_f.set_ylabel("Power (dBW)") - Ts_o = 1.0 / fs_o - Tmax_o = len(d)*Ts_o + Tmax_o = len(d) * Ts_o x_o = numpy.array(d) t_o = numpy.arange(0, Tmax_o, Ts_o) @@ -169,4 +171,3 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/fft_filter_ccc.py b/gr-filter/examples/fft_filter_ccc.py index afdc0f3127..c9a8353af2 100644 --- a/gr-filter/examples/fft_filter_ccc.py +++ b/gr-filter/examples/fft_filter_ccc.py @@ -23,6 +23,7 @@ except ImportError: print("Error: could not from matplotlib import pyplot (http://matplotlib.sourceforge.net/)") sys.exit(1) + class example_fft_filter_ccc(gr.top_block): def __init__(self, N, fs, bw0, bw1, tw, atten, D): gr.top_block.__init__(self) @@ -39,7 +40,7 @@ class example_fft_filter_ccc(gr.top_block): self._tw, self._at) print("Num. Taps: ", len(taps)) - self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) + self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps) self.filt0 = filter.fft_filter_ccc(self._decim, taps) @@ -50,22 +51,23 @@ class example_fft_filter_ccc(gr.top_block): self.connect(self.src, self.head, self.vsnk_src) self.connect(self.head, self.filt0, self.vsnk_out) + def main(): parser = ArgumentParser(conflict_handler="resolve") parser.add_argument("-N", "--nsamples", type=int, default=10000, - help="Number of samples to process [default=%(default)r]") + help="Number of samples to process [default=%(default)r]") parser.add_argument("-s", "--samplerate", type=eng_float, default=8000, - help="System sample rate [default=%(default)r]") + help="System sample rate [default=%(default)r]") parser.add_argument("-S", "--start-pass", type=eng_float, default=1000, - help="Start of Passband [default=%(default)r]") + help="Start of Passband [default=%(default)r]") parser.add_argument("-E", "--end-pass", type=eng_float, default=2000, - help="End of Passband [default=%(default)r]") + help="End of Passband [default=%(default)r]") parser.add_argument("-T", "--transition", type=eng_float, default=100, - help="Transition band [default=%(default)r]") + help="Transition band [default=%(default)r]") parser.add_argument("-A", "--attenuation", type=eng_float, default=80, - help="Stopband attenuation [default=%(default)r]") + help="Stopband attenuation [default=%(default)r]") parser.add_argument("-D", "--decimation", type=int, default=1, - help="Decmation factor [default=%(default)r]") + help="Decmation factor [default=%(default)r]") args = parser.parse_args() put = example_fft_filter_ccc(args.nsamples, @@ -82,23 +84,23 @@ def main(): # Plot the signals PSDs nfft = 1024 - f1 = pyplot.figure(1, figsize=(12,10)) - s1 = f1.add_subplot(1,1,1) + f1 = pyplot.figure(1, figsize=(12, 10)) + s1 = f1.add_subplot(1, 1, 1) s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4, Fs=args.samplerate) s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4, Fs=args.samplerate) - f2 = pyplot.figure(2, figsize=(12,10)) - s2 = f2.add_subplot(1,1,1) + f2 = pyplot.figure(2, figsize=(12, 10)) + s2 = f2.add_subplot(1, 1, 1) s2.plot(data_src) s2.plot(data_snk.real, 'g') pyplot.show() + if __name__ == "__main__": try: main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/fir_filter_ccc.py b/gr-filter/examples/fir_filter_ccc.py index 7e43735bb1..26ee561982 100644 --- a/gr-filter/examples/fir_filter_ccc.py +++ b/gr-filter/examples/fir_filter_ccc.py @@ -23,6 +23,7 @@ except ImportError: print("Error: could not from matplotlib import pyplot (http://matplotlib.sourceforge.net/)") sys.exit(1) + class example_fir_filter_ccc(gr.top_block): def __init__(self, N, fs, bw, tw, atten, D): gr.top_block.__init__(self) @@ -33,10 +34,11 @@ class example_fir_filter_ccc(gr.top_block): self._tw = tw self._at = atten self._decim = D - taps = filter.firdes.low_pass_2(1, self._fs, self._bw, self._tw, self._at) + taps = filter.firdes.low_pass_2( + 1, self._fs, self._bw, self._tw, self._at) print("Num. Taps: ", len(taps)) - self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) + self.src = analog.noise_source_c(analog.GR_GAUSSIAN, 1) self.head = blocks.head(gr.sizeof_gr_complex, self._nsamps) self.filt0 = filter.fir_filter_ccc(self._decim, taps) @@ -47,20 +49,21 @@ class example_fir_filter_ccc(gr.top_block): self.connect(self.src, self.head, self.vsnk_src) self.connect(self.head, self.filt0, self.vsnk_out) + def main(): parser = ArgumentParser(conflict_handler="resolve") parser.add_argument("-N", "--nsamples", type=int, default=10000, - help="Number of samples to process [default=%(default)r]") + help="Number of samples to process [default=%(default)r]") parser.add_argument("-s", "--samplerate", type=eng_float, default=8000, - help="System sample rate [default=%(default)r]") + help="System sample rate [default=%(default)r]") parser.add_argument("-B", "--bandwidth", type=eng_float, default=1000, - help="Filter bandwidth [default=%(default)r]") + help="Filter bandwidth [default=%(default)r]") parser.add_argument("-T", "--transition", type=eng_float, default=100, - help="Transition band [default=%(default)r]") + help="Transition band [default=%(default)r]") parser.add_argument("-A", "--attenuation", type=eng_float, default=80, - help="Stopband attenuation [default=%(default)r]") + help="Stopband attenuation [default=%(default)r]") parser.add_argument("-D", "--decimation", type=int, default=1, - help="Decmation factor [default=%(default)r]") + help="Decmation factor [default=%(default)r]") args = parser.parse_args() put = example_fir_filter_ccc(args.nsamples, @@ -76,23 +79,23 @@ def main(): # Plot the signals PSDs nfft = 1024 - f1 = pyplot.figure(1, figsize=(12,10)) - s1 = f1.add_subplot(1,1,1) + f1 = pyplot.figure(1, figsize=(12, 10)) + s1 = f1.add_subplot(1, 1, 1) s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4, Fs=args.samplerate) s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4, Fs=args.samplerate) - f2 = pyplot.figure(2, figsize=(12,10)) - s2 = f2.add_subplot(1,1,1) + f2 = pyplot.figure(2, figsize=(12, 10)) + s2 = f2.add_subplot(1, 1, 1) s2.plot(data_src) s2.plot(data_snk.real, 'g') pyplot.show() + if __name__ == "__main__": try: main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/fir_filter_fff.py b/gr-filter/examples/fir_filter_fff.py index f634c44cf2..74c41b1ec7 100644 --- a/gr-filter/examples/fir_filter_fff.py +++ b/gr-filter/examples/fir_filter_fff.py @@ -23,6 +23,7 @@ except ImportError: print("Error: could not from matplotlib import pyplot (http://matplotlib.sourceforge.net/)") sys.exit(1) + class example_fir_filter_fff(gr.top_block): def __init__(self, N, fs, bw, tw, atten, D): gr.top_block.__init__(self) @@ -33,10 +34,11 @@ class example_fir_filter_fff(gr.top_block): self._tw = tw self._at = atten self._decim = D - taps = filter.firdes.low_pass_2(1, self._fs, self._bw, self._tw, self._at) + taps = filter.firdes.low_pass_2( + 1, self._fs, self._bw, self._tw, self._at) print("Num. Taps: ", len(taps)) - self.src = analog.noise_source_f(analog.GR_GAUSSIAN, 1) + self.src = analog.noise_source_f(analog.GR_GAUSSIAN, 1) self.head = blocks.head(gr.sizeof_float, self._nsamps) self.filt0 = filter.fir_filter_fff(self._decim, taps) @@ -47,20 +49,21 @@ class example_fir_filter_fff(gr.top_block): self.connect(self.src, self.head, self.vsnk_src) self.connect(self.head, self.filt0, self.vsnk_out) + def main(): parser = ArgumentParser(conflict_handler="resolve") parser.add_argument("-N", "--nsamples", type=int, default=10000, - help="Number of samples to process [default=%(default)r]") + help="Number of samples to process [default=%(default)r]") parser.add_argument("-s", "--samplerate", type=eng_float, default=8000, - help="System sample rate [default=%(default)r]") + help="System sample rate [default=%(default)r]") parser.add_argument("-B", "--bandwidth", type=eng_float, default=1000, - help="Filter bandwidth [default=%(default)r]") + help="Filter bandwidth [default=%(default)r]") parser.add_argument("-T", "--transition", type=eng_float, default=100, - help="Transition band [default=%(default)r]") + help="Transition band [default=%(default)r]") parser.add_argument("-A", "--attenuation", type=eng_float, default=80, - help="Stopband attenuation [default=%(default)r]") + help="Stopband attenuation [default=%(default)r]") parser.add_argument("-D", "--decimation", type=int, default=1, - help="Decmation factor [default=%(default)r]") + help="Decmation factor [default=%(default)r]") args = parser.parse_args() put = example_fir_filter_fff(args.nsamples, @@ -76,23 +79,23 @@ def main(): # Plot the signals PSDs nfft = 1024 - f1 = pyplot.figure(1, figsize=(12,10)) - s1 = f1.add_subplot(1,1,1) + f1 = pyplot.figure(1, figsize=(12, 10)) + s1 = f1.add_subplot(1, 1, 1) s1.psd(data_src, NFFT=nfft, noverlap=nfft / 4, Fs=args.samplerate) s1.psd(data_snk, NFFT=nfft, noverlap=nfft / 4, Fs=args.samplerate) - f2 = pyplot.figure(2, figsize=(12,10)) - s2 = f2.add_subplot(1,1,1) + f2 = pyplot.figure(2, figsize=(12, 10)) + s2 = f2.add_subplot(1, 1, 1) s2.plot(data_src) s2.plot(data_snk.real, 'g') pyplot.show() + if __name__ == "__main__": try: main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/gr_filtdes_callback.py b/gr-filter/examples/gr_filtdes_callback.py index d27943174e..371f337d4d 100644 --- a/gr-filter/examples/gr_filtdes_callback.py +++ b/gr-filter/examples/gr_filtdes_callback.py @@ -23,14 +23,17 @@ or pole-zero plot is changed 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()) + app = Qt.QApplication(sys.argv) -#launch function returns gr_filter_design mainwindow object +# launch function returns gr_filter_design mainwindow object main_win = filter_design.launch(sys.argv, print_params) main_win.show() app.exec_() diff --git a/gr-filter/examples/gr_filtdes_live_upd.py b/gr-filter/examples/gr_filtdes_live_upd.py index 3b1fd1e1c6..182b7535ae 100644 --- a/gr-filter/examples/gr_filtdes_live_upd.py +++ b/gr-filter/examples/gr_filtdes_live_upd.py @@ -41,6 +41,7 @@ except ImportError: sys.stderr.write("Error: Program requires gr-channels.\n") sys.exit(1) + class my_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) @@ -53,24 +54,24 @@ class my_top_block(gr.top_block): self.qapp = QtGui.QApplication(sys.argv) - self.filt_taps = [1,] + self.filt_taps = [1, ] src1 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f1, 0.1, 0) src2 = analog.sig_source_c(Rs, analog.GR_SIN_WAVE, f2, 0.1, 0) - src = blocks.add_cc() + src = blocks.add_cc() channel = channels.channel_model(0.01) self.filt = filter.fft_filter_ccc(1, self.filt_taps) - thr = blocks.throttle(gr.sizeof_gr_complex, 100*npts) + thr = blocks.throttle(gr.sizeof_gr_complex, 100 * npts) self.snk1 = qtgui.freq_sink_c(npts, window.WIN_BLACKMAN_hARRIS, 0, Rs, "Complex Freq Example", 1) - self.connect(src1, (src,0)) - self.connect(src2, (src,1)) - self.connect(src, channel, thr, self.filt, (self.snk1, 0)) + self.connect(src1, (src, 0)) + self.connect(src2, (src, 1)) + self.connect(src, channel, thr, self.filt, (self.snk1, 0)) # Get the reference pointer to the SpectrumDisplayForm QWidget - pyQt = self.snk1.qwidget() + pyQt = self.snk1.qwidget() # Wrap the pointer as a PyQt SIP object # This can now be manipulated as a PyQt5.QtGui.QWidget @@ -82,12 +83,11 @@ class my_top_block(gr.top_block): print("Filter params", filtobj.get_params()) self.filt.set_taps(filtobj.get_taps()) + if __name__ == "__main__": - tb = my_top_block(); + tb = my_top_block() tb.start() mw = filter_design.launch(sys.argv, tb.update_filter) mw.show() tb.qapp.exec_() tb.stop() - - diff --git a/gr-filter/examples/gr_filtdes_restrict.py b/gr-filter/examples/gr_filtdes_restrict.py index e707895717..7c734cbaf8 100644 --- a/gr-filter/examples/gr_filtdes_restrict.py +++ b/gr-filter/examples/gr_filtdes_restrict.py @@ -22,13 +22,16 @@ Callback with restrict example 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()) + app = Qt.QApplication(sys.argv) -main_win = filter_design.launch(sys.argv, callback = print_params, restype = "iir") +main_win = filter_design.launch(sys.argv, callback=print_params, restype="iir") main_win.show() app.exec_() diff --git a/gr-filter/examples/interpolate.py b/gr-filter/examples/interpolate.py index 8674566e25..5f6f1a5f5c 100644 --- a/gr-filter/examples/interpolate.py +++ b/gr-filter/examples/interpolate.py @@ -12,7 +12,8 @@ from gnuradio import gr from gnuradio import blocks from gnuradio import filter from gnuradio.fft import window -import sys, time +import sys +import time import numpy try: @@ -25,9 +26,11 @@ try: import pylab from pylab import mlab except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + class pfb_top_block(gr.top_block): def __init__(self): gr.top_block.__init__(self) @@ -44,8 +47,8 @@ class pfb_top_block(gr.top_block): # Create a set of taps for the PFB interpolator # This is based on the post-interpolation sample rate self._taps = filter.firdes.low_pass_2(self._interp, - self._interp*self._fs, - freq2+50, 50, + self._interp * self._fs, + freq2 + 50, 50, attenuation_dB=120, window=window.WIN_BLACKMAN_hARRIS) @@ -56,8 +59,8 @@ class pfb_top_block(gr.top_block): # internally as an interpolator. flt_size = 32 self._taps2 = filter.firdes.low_pass_2(flt_size, - flt_size*self._fs, - freq2+50, 150, + flt_size * self._fs, + freq2 + 50, 150, attenuation_dB=120, window=window.WIN_BLACKMAN_hARRIS) @@ -68,8 +71,10 @@ class pfb_top_block(gr.top_block): 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) - self.signal2 = analog.sig_source_c(self._fs, analog.GR_SIN_WAVE, freq2, 0.5) + self.signal1 = analog.sig_source_c( + self._fs, analog.GR_SIN_WAVE, freq1, 0.5) + self.signal2 = analog.sig_source_c( + self._fs, analog.GR_SIN_WAVE, freq2, 0.5) self.signal = blocks.add_cc() self.head = blocks.head(gr.sizeof_gr_complex, self._N) @@ -78,15 +83,16 @@ class pfb_top_block(gr.top_block): self.pfb = filter.pfb.interpolator_ccf(self._interp, self._taps) # Construct the PFB arbitrary resampler filter - self.pfb_ar = filter.pfb.arb_resampler_ccf(self._ainterp, self._taps2, flt_size) + self.pfb_ar = filter.pfb.arb_resampler_ccf( + self._ainterp, self._taps2, flt_size) self.snk_i = blocks.vector_sink_c() - #self.pfb_ar.pfb.print_taps() - #self.pfb.pfb.print_taps() + # self.pfb_ar.pfb.print_taps() + # self.pfb.pfb.print_taps() # Connect the blocks - self.connect(self.signal1, self.head, (self.signal,0)) - self.connect(self.signal2, (self.signal,1)) + self.connect(self.signal1, self.head, (self.signal, 0)) + self.connect(self.signal2, (self.signal, 1)) self.connect(self.signal, self.pfb) self.connect(self.signal, self.pfb_ar) self.connect(self.signal, self.snk_i) @@ -106,11 +112,10 @@ def main(): tend = time.time() print("Run time: %f" % (tend - tstart)) - if 1: - fig1 = pylab.figure(1, figsize=(12,10), facecolor="w") - fig2 = pylab.figure(2, figsize=(12,10), facecolor="w") - fig3 = pylab.figure(3, figsize=(12,10), facecolor="w") + fig1 = pylab.figure(1, figsize=(12, 10), facecolor="w") + fig2 = pylab.figure(2, figsize=(12, 10), facecolor="w") + fig3 = pylab.figure(3, figsize=(12, 10), facecolor="w") Ns = 10000 Ne = 10000 @@ -121,25 +126,24 @@ def main(): # Plot input signal fs = tb._fs - d = tb.snk_i.data()[Ns:Ns+Ne] + 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_in = 10.0*numpy.log10(abs(numpy.fft.fftshift(X))) + 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 * numpy.log10(abs(numpy.fft.fftshift(X))) f_in = numpy.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_xlim([min(f_in), max(f_in) + 1]) sp1_f.set_ylim([-200.0, 50.0]) - sp1_f.set_title("Input Signal", weight="bold") sp1_f.set_xlabel("Frequency (Hz)") sp1_f.set_ylabel("Power (dBW)") Ts = 1.0 / fs - Tmax = len(d)*Ts + Tmax = len(d) * Ts t_in = numpy.arange(0, Tmax, Ts) x_in = numpy.array(d) @@ -152,19 +156,19 @@ def main(): sp1_t.set_xlabel("Time (s)") sp1_t.set_ylabel("Amplitude") - # Plot output of PFB interpolator - fs_int = tb._fs*tb._interp + fs_int = tb._fs * tb._interp 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*numpy.log10(abs(numpy.fft.fftshift(X))) - f_o = numpy.arange(-fs_int / 2.0, fs_int / 2.0, fs_int / float(X_o.size)) + d = tb.snk1.data()[Ns:Ns + (tb._interp * Ne)] + 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 * numpy.log10(abs(numpy.fft.fftshift(X))) + f_o = numpy.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_xlim([min(f_o), max(f_o) + 1]) sp2_f.set_ylim([-200.0, 50.0]) sp2_f.set_title("Output Signal from PFB Interpolator", weight="bold") @@ -172,7 +176,7 @@ def main(): sp2_f.set_ylabel("Power (dBW)") Ts_int = 1.0 / fs_int - Tmax = len(d)*Ts_int + Tmax = len(d) * Ts_int t_o = numpy.arange(0, Tmax, Ts_int) x_o1 = numpy.array(d) @@ -185,27 +189,28 @@ def main(): sp2_t.set_xlabel("Time (s)") sp2_t.set_ylabel("Amplitude") - # Plot output of PFB arbitrary resampler fs_aint = tb._fs * tb._ainterp 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, - window = lambda d: d*winfunc(fftlen), - scale_by_freq=True) - X_o = 10.0*numpy.log10(abs(numpy.fft.fftshift(X))) - f_o = numpy.arange(-fs_aint / 2.0, fs_aint / 2.0, fs_aint / float(X_o.size)) + d = tb.snk2.data()[Ns:Ns + (tb._interp * Ne)] + 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 * numpy.log10(abs(numpy.fft.fftshift(X))) + f_o = numpy.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_xlim([min(f_o), max(f_o) + 1]) sp3_f.set_ylim([-200.0, 50.0]) - sp3_f.set_title("Output Signal from PFB Arbitrary Resampler", weight="bold") + sp3_f.set_title( + "Output Signal from PFB Arbitrary Resampler", weight="bold") sp3_f.set_xlabel("Frequency (Hz)") sp3_f.set_ylabel("Power (dBW)") Ts_aint = 1.0 / fs_aint - Tmax = len(d)*Ts_aint + Tmax = len(d) * Ts_aint t_o = numpy.arange(0, Tmax, Ts_aint) x_o2 = numpy.array(d) @@ -215,7 +220,8 @@ def main(): #p3_f = sp3_f.plot(t_o, x_o2.imag, "r-o") sp3_f.set_ylim([-2.5, 2.5]) - sp3_f.set_title("Output Signal from PFB Arbitrary Resampler", weight="bold") + sp3_f.set_title( + "Output Signal from PFB Arbitrary Resampler", weight="bold") sp3_f.set_xlabel("Time (s)") sp3_f.set_ylabel("Amplitude") @@ -227,4 +233,3 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/reconstruction.py b/gr-filter/examples/reconstruction.py index 8b65f70deb..2a34f9e33f 100644 --- a/gr-filter/examples/reconstruction.py +++ b/gr-filter/examples/reconstruction.py @@ -29,11 +29,12 @@ except ImportError: fftlen = 8192 + def main(): N = 10000 fs = 2000.0 Ts = 1.0 / fs - t = numpy.arange(0, N*Ts, Ts) + t = numpy.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. @@ -42,12 +43,11 @@ def main(): # Build the filter(s) bw = 1000 tb = 400 - proto_taps = filter.firdes.low_pass_2(1, nchans*fs, + proto_taps = filter.firdes.low_pass_2(1, nchans * fs, bw, tb, 80, window.WIN_BLACKMAN_hARRIS) print("Filter length: ", len(proto_taps)) - # Create a modulated signal npwr = 0.01 data = numpy.random.randint(0, 256, N) @@ -62,7 +62,7 @@ def main(): channelizer = filter.pfb.channelizer_ccf(nchans, proto_taps, 2) # Put the pieces back together again - syn_taps = [nchans*t for t in proto_taps] + syn_taps = [nchans * t for t in proto_taps] synthesizer = filter.pfb_synthesizer_ccf(nchans, syn_taps, True) src_snk = blocks.vector_sink_c() snk = blocks.vector_sink_c() @@ -70,7 +70,7 @@ def main(): # 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, + synthesizer.set_channel_map([0, 1, 2, 3, 4, 15, 16, 17, 18, 19]) tb = gr.top_block() @@ -79,34 +79,33 @@ def main(): vsnk = [] for i in range(nchans): - tb.connect((channelizer,i), (synthesizer, i)) + tb.connect((channelizer, i), (synthesizer, i)) vsnk.append(blocks.vector_sink_c()) - tb.connect((channelizer,i), vsnk[i]) + tb.connect((channelizer, i), vsnk[i]) tb.connect(synthesizer, snk) tb.run() - sin = numpy.array(src_snk.data()[1000:]) + sin = numpy.array(src_snk.data()[1000:]) sout = numpy.array(snk.data()[1000:]) - # Plot original signal - fs_in = nchans*fs - f1 = pyplot.figure(1, figsize=(16,12), facecolor='w') - s11 = f1.add_subplot(2,2,1) + fs_in = nchans * fs + f1 = pyplot.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 = 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 = 2 - s13 = f1.add_subplot(2,2,3) + skip = 2 + 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]) @@ -116,29 +115,29 @@ def main(): nrows = int(numpy.sqrt(nchans)) ncols = int(numpy.ceil(float(nchans) / float(nrows))) - f2 = pyplot.figure(2, figsize=(16,12), facecolor='w') + f2 = pyplot.figure(2, figsize=(16, 12), facecolor='w') for n in range(nchans): - s = f2.add_subplot(nrows, ncols, n+1) + 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 = pyplot.figure(3, figsize=(16,12), facecolor='w') - s31 = f3.add_subplot(2,2,1) + fs_out = 2 * nchans * fs + f3 = pyplot.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 = 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 = 0 - skip = 4 - s33 = f3.add_subplot(2,2,3) + 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]) @@ -152,4 +151,3 @@ if __name__ == "__main__": main() except KeyboardInterrupt: pass - diff --git a/gr-filter/examples/resampler.py b/gr-filter/examples/resampler.py index 0208bac188..282eaa1286 100644 --- a/gr-filter/examples/resampler.py +++ b/gr-filter/examples/resampler.py @@ -23,15 +23,17 @@ except ImportError: try: from matplotlib import pyplot except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + class mytb(gr.top_block): def __init__(self, fs_in, fs_out, fc, N=10000): 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) @@ -59,6 +61,7 @@ class mytb(gr.top_block): self.connect(self.head, self.resamp_0, self.snk_0) self.connect(self.head, self.resamp_1, self.snk_1) + def main(): fs_in = 8000 fs_out = 20000 @@ -68,22 +71,21 @@ def main(): tb = mytb(fs_in, fs_out, fc, N) tb.run() - # Plot PSD of signals nfftsize = 2048 - fig1 = pyplot.figure(1, figsize=(10,10), facecolor="w") - sp1 = fig1.add_subplot(2,1,1) + fig1 = pyplot.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) + 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 = 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]) @@ -92,16 +94,16 @@ def main(): # Plot signals in time Ts_in = 1.0 / fs_in Ts_out = 1.0 / fs_out - t_in = numpy.arange(0, len(tb.snk_in.data())*Ts_in, Ts_in) - t_out = numpy.arange(0, len(tb.snk_0.data())*Ts_out, Ts_out) + t_in = numpy.arange(0, len(tb.snk_in.data()) * Ts_in, Ts_in) + t_out = numpy.arange(0, len(tb.snk_0.data()) * Ts_out, Ts_out) - fig2 = pyplot.figure(2, figsize=(10,10), facecolor="w") - sp21 = fig2.add_subplot(2,1,1) + fig2 = pyplot.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_xlim([t_in[100], t_in[200]]) - sp22 = fig2.add_subplot(2,1,2) + sp22 = fig2.add_subplot(2, 1, 2) sp22.plot(t_out, tb.snk_0.data(), label="With our filter") sp22.plot(t_out, tb.snk_1.data(), @@ -113,6 +115,6 @@ def main(): pyplot.show() + if __name__ == "__main__": main() - diff --git a/gr-filter/examples/synth_filter.py b/gr-filter/examples/synth_filter.py index 2e8509feea..8c4f6e13ba 100644 --- a/gr-filter/examples/synth_filter.py +++ b/gr-filter/examples/synth_filter.py @@ -23,9 +23,11 @@ except ImportError: try: from matplotlib import pyplot except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + def main(): N = 1000000 fs = 8000 @@ -39,7 +41,7 @@ def main(): sigs.append(s) taps = filter.firdes.low_pass_2(len(freqs), fs, - fs/float(nchans)/2, 100, 100) + fs / float(nchans) / 2, 100, 100) print("Num. Taps = %d (taps per filter = %d)" % (len(taps), len(taps) / nchans)) filtbank = filter.pfb_synthesizer_ccf(nchans, taps) @@ -50,26 +52,27 @@ def main(): tb = gr.top_block() tb.connect(filtbank, head, snk) - for i,si in enumerate(sigs): + for i, si in enumerate(sigs): tb.connect(si, (filtbank, i)) tb.run() if 1: f1 = pyplot.figure(1) - s1 = f1.add_subplot(1,1,1) + s1 = f1.add_subplot(1, 1, 1) s1.plot(snk.data()[1000:]) fftlen = 2048 f2 = pyplot.figure(2) - s2 = f2.add_subplot(1,1,1) + s2 = f2.add_subplot(1, 1, 1) winfunc = numpy.blackman s2.psd(snk.data()[10000:], NFFT=fftlen, - Fs = nchans*fs, + Fs=nchans * fs, noverlap=fftlen / 4, - window = lambda d: d*winfunc(fftlen)) + window=lambda d: d * winfunc(fftlen)) pyplot.show() + if __name__ == "__main__": main() diff --git a/gr-filter/examples/synth_to_chan.py b/gr-filter/examples/synth_to_chan.py index 9a64e14ebf..450197e09e 100644 --- a/gr-filter/examples/synth_to_chan.py +++ b/gr-filter/examples/synth_to_chan.py @@ -23,9 +23,11 @@ except ImportError: try: from matplotlib import pyplot except ImportError: - sys.stderr.write("Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") + sys.stderr.write( + "Error: Program requires matplotlib (see: matplotlib.sourceforge.net).\n") sys.exit(1) + def main(): N = 1000000 fs = 8000 @@ -37,14 +39,17 @@ def main(): fmtx = list() for fi in freqs: s = analog.sig_source_f(fs, analog.GR_SIN_WAVE, fi, 1) - fm = analog.nbfm_tx(fs, 4*fs, max_dev=10000, tau=75e-6, fh=0.925*(4*fs)/2.0) + fm = analog.nbfm_tx(fs, 4 * fs, max_dev=10000, + tau=75e-6, fh=0.925 * (4 * fs) / 2.0) sigs.append(s) fmtx.append(fm) - syntaps = filter.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + 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)) - chtaps = filter.firdes.low_pass_2(len(freqs), fs, fs/float(nchans)/2, 100, 100) + 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)) filtbank = filter.pfb_synthesizer_ccf(nchans, syntaps) @@ -58,13 +63,13 @@ def main(): tb = gr.top_block() - tb.connect(noise, (addnoise,0)) + tb.connect(noise, (addnoise, 0)) tb.connect(filtbank, head, (addnoise, 1)) tb.connect(addnoise, channelizer) tb.connect(addnoise, snk_synth) snk = list() - for i,si in enumerate(sigs): + for i, si in enumerate(sigs): tb.connect(si, fmtx[i], (filtbank, i)) for i in range(nchans): @@ -78,8 +83,8 @@ def main(): data = snk[channel].data()[1000:] f1 = pyplot.figure(1) - s1 = f1.add_subplot(1,1,1) - s1.plot(data[10000:10200] ) + s1 = f1.add_subplot(1, 1, 1) + s1.plot(data[10000:10200]) s1.set_title(("Output Signal from Channel %d" % channel)) fftlen = 2048 @@ -87,22 +92,23 @@ def main(): #winfunc = numpy.hamming f2 = pyplot.figure(2) - s2 = f2.add_subplot(1,1,1) + s2 = f2.add_subplot(1, 1, 1) s2.psd(data, NFFT=fftlen, - Fs = nchans*fs, + Fs=nchans * fs, noverlap=fftlen / 4, - window = lambda d: d*winfunc(fftlen)) + window=lambda d: d * winfunc(fftlen)) s2.set_title(("Output PSD from Channel %d" % channel)) f3 = pyplot.figure(3) - s3 = f3.add_subplot(1,1,1) + s3 = f3.add_subplot(1, 1, 1) s3.psd(snk_synth.data()[1000:], NFFT=fftlen, - Fs = nchans*fs, + Fs=nchans * fs, noverlap=fftlen / 4, - window = lambda d: d*winfunc(fftlen)) + window=lambda d: d * winfunc(fftlen)) s3.set_title("Output of Synthesis Filter") pyplot.show() + if __name__ == "__main__": main() diff --git a/gr-filter/python/filter/design/api_object.py b/gr-filter/python/filter/design/api_object.py index 2ba7afa7f5..cfcbdfcb3d 100644 --- a/gr-filter/python/filter/design/api_object.py +++ b/gr-filter/python/filter/design/api_object.py @@ -12,15 +12,17 @@ class ApiObject(object): return multiple filter parameters in future e.g Cascaded Filters ''' - def __init__(self, filtcount = 1): + + def __init__(self, filtcount=1): self.filtercount = filtcount self.restype = [''] * self.filtercount - self.params = [''] * self.filtercount - self.taps = [''] * self.filtercount + self.params = [''] * self.filtercount + self.taps = [''] * self.filtercount ''' Updates params dictionary for the given filter number ''' + def update_params(self, params, filtno): if (filtno <= self.filtercount): self.params[filtno - 1] = params @@ -28,16 +30,17 @@ class ApiObject(object): ''' Updates filter type for the given filter number ''' + def update_filttype(self, filttype, filtno): if (filtno <= self.filtercount): self.filttype[filtno - 1] = filttype - ''' updates taps for the given filter number. taps will contain a list of coefficients in the case of fir design and (b,a) tuple in the case of iir design ''' + def update_taps(self, taps, filtno): if (filtno <= self.filtercount): self.taps[filtno - 1] = taps @@ -45,6 +48,7 @@ class ApiObject(object): ''' updates all of them in a single call ''' + def update_all(self, filttype, params, taps, filtno): if (filtno <= self.filtercount): self.taps[filtno - 1] = taps diff --git a/gr-filter/python/filter/design/filter_design.py b/gr-filter/python/filter/design/filter_design.py index f815ba1a83..f6d03b59ed 100644 --- a/gr-filter/python/filter/design/filter_design.py +++ b/gr-filter/python/filter/design/filter_design.py @@ -19,48 +19,56 @@ from gnuradio import filter, fft try: import numpy as np except ImportError: - raise SystemExit('Please install NumPy to run this script (https://www.np.org/)') + raise SystemExit( + 'Please install NumPy to run this script (https://www.np.org/)') try: import numpy.fft as fft_detail except ImportError: raise SystemExit('Could not import fft implementation of numpy') - + try: from numpy import poly1d except ImportError: - raise SystemExit('Please install NumPy to run this script (https://www.np.org)') + raise SystemExit( + 'Please install NumPy to run this script (https://www.np.org)') try: from scipy import signal except ImportError: - raise SystemExit('Please install SciPy to run this script (https://www.scipy.org)') + raise SystemExit( + 'Please install SciPy to run this script (https://www.scipy.org)') try: from PyQt5 import Qt, QtCore, QtWidgets except ImportError: - raise SystemExit('Please install PyQt5 to run this script (https://www.riverbankcomputing.com/software/pyqt/download5)') + raise SystemExit( + 'Please install PyQt5 to run this script (https://www.riverbankcomputing.com/software/pyqt/download5)') try: import pyqtgraph as pg except ImportError: - raise SystemExit('Please install pyqtgraph to run this script (http://www.pyqtgraph.org)') + raise SystemExit( + 'Please install pyqtgraph to run this script (http://www.pyqtgraph.org)') try: from gnuradio.filter.pyqt_filter_stacked import Ui_MainWindow except ImportError: - raise SystemExit('Could not import from pyqt_filter_stacked. Please build with "pyuic5 pyqt_filter_stacked.ui -o pyqt_filter_stacked.py"') + raise SystemExit( + 'Could not import from pyqt_filter_stacked. Please build with "pyuic5 pyqt_filter_stacked.ui -o pyqt_filter_stacked.py"') try: from gnuradio.filter.banditems import * except ImportError: - raise SystemExit('Could not import from banditems. Please check whether banditems.py is in the library path') + raise SystemExit( + 'Could not import from banditems. Please check whether banditems.py is in the library path') try: from gnuradio.filter.polezero_plot import * except ImportError: - raise SystemExit('Could not import from polezero_plot. Please check whether polezero_plot.py is in the library path') + raise SystemExit( + 'Could not import from polezero_plot. Please check whether polezero_plot.py is in the library path') # Behavior is not quite working on 3.8 - TODO # try: @@ -71,12 +79,14 @@ except ImportError: try: from gnuradio.filter.api_object import * except ImportError: - raise SystemExit('Could not import from api_object. Please check whether api_object.py is in the library path') + raise SystemExit( + 'Could not import from api_object. Please check whether api_object.py is in the library path') try: from gnuradio.filter.fir_design import * except ImportError: - raise SystemExit('Could not import from fir_design. Please check whether fir_design.py is in the library path') + raise SystemExit( + 'Could not import from fir_design. Please check whether fir_design.py is in the library path') try: _fromUtf8 = QtCore.QString.fromUtf8 @@ -84,6 +94,8 @@ except AttributeError: def _fromUtf8(s): return s # Gnuradio Filter design tool main window + + class gr_plot_filter(QtWidgets.QMainWindow): def __init__(self, options, callback=None, restype=""): QtWidgets.QWidget.__init__(self, None) @@ -91,9 +103,12 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.callback = callback # Set Global pyqtgraph options - pg.setConfigOption('foreground', 'k') # Default foreground color for text, lines, axes, etc. - pg.setConfigOption('background', None) # Default background for GraphicsView. - pg.setConfigOptions(antialias=True) # Draw lines with smooth edges at the cost of reduced performance. + # Default foreground color for text, lines, axes, etc. + pg.setConfigOption('foreground', 'k') + # Default background for GraphicsView. + pg.setConfigOption('background', None) + # Draw lines with smooth edges at the cost of reduced performance. + pg.setConfigOptions(antialias=True) self.gui.setupUi(self) @@ -111,11 +126,16 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.action_save.setEnabled(False) self.gui.action_open.triggered.connect(self.action_open_dialog) - self.gui.filterTypeComboBox.currentIndexChanged['const QString&'].connect(self.changed_filter_type) - self.gui.iirfilterBandComboBox.currentIndexChanged['const QString&'].connect(self.changed_iirfilter_band) - self.gui.filterDesignTypeComboBox.currentIndexChanged['const QString&'].connect(self.changed_filter_design_type) - self.gui.fselectComboBox.currentIndexChanged['const QString&'].connect(self.changed_fselect) - self.gui.iirfilterTypeComboBox.currentIndexChanged['const QString&'].connect(self.set_order) + self.gui.filterTypeComboBox.currentIndexChanged['const QString&'].connect( + self.changed_filter_type) + self.gui.iirfilterBandComboBox.currentIndexChanged['const QString&'].connect( + self.changed_iirfilter_band) + self.gui.filterDesignTypeComboBox.currentIndexChanged['const QString&'].connect( + self.changed_filter_design_type) + self.gui.fselectComboBox.currentIndexChanged['const QString&'].connect( + self.changed_fselect) + self.gui.iirfilterTypeComboBox.currentIndexChanged['const QString&'].connect( + self.set_order) self.gui.designButton.released.connect(self.design) @@ -127,11 +147,14 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.actionSpec_Widget.triggered.connect(self.action_spec_widget) - self.gui.actionResponse_Widget.triggered.connect(self.action_response_widget) + self.gui.actionResponse_Widget.triggered.connect( + self.action_response_widget) - self.gui.actionDesign_Widget.triggered.connect(self.action_design_widget) + self.gui.actionDesign_Widget.triggered.connect( + self.action_design_widget) - self.gui.actionMagnitude_Response.triggered.connect(self.set_actmagresponse) + self.gui.actionMagnitude_Response.triggered.connect( + self.set_actmagresponse) self.gui.actionGrid_2.triggered.connect(self.set_actgrid) @@ -139,7 +162,8 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.actionGroup_Delay.triggered.connect(self.set_actgdelay) - self.gui.actionFilter_Coefficients.triggered.connect(self.set_actfcoeff) + self.gui.actionFilter_Coefficients.triggered.connect( + self.set_actfcoeff) self.gui.actionBand_Diagram.triggered.connect(self.set_actband) @@ -213,9 +237,9 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.checkStep.stateChanged['int'].connect(self.set_stepres) self.gridenable = False - self.mfoverlay = False - self.mtoverlay = False - self.iir = False + self.mfoverlay = False + self.mtoverlay = False + self.iir = False self.mfmagresponse = True self.mfphaseresponse = False @@ -226,7 +250,6 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.mtstep = False self.mtimpulse = False - self.gui.designButton.setShortcut(QtCore.Qt.Key_Return) self.taps = [] @@ -270,13 +293,12 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.plots['PDELAY'] = self.gui.pdelayPlot # for i in self.plots: - # self.plots[i] = pg.PlotWidget(enableMenu=False, viewBox=CustomViewBox()) - # self.plots[i].plotItem.vb = CustomViewBox() - + # self.plots[i] = pg.PlotWidget(enableMenu=False, viewBox=CustomViewBox()) + # self.plots[i].plotItem.vb = CustomViewBox() + self.mplots['mFREQ'] = self.gui.mfreqPlot self.mplots['mTIME'] = self.gui.mtimePlot - # for i in self.mplots: # self.mplots[i] = pg.PlotWidget(enableMenu=False, viewBox=CustomViewBox()) @@ -292,32 +314,48 @@ class gr_plot_filter(QtWidgets.QMainWindow): # self.gui.mtimeTab.layout().addWidget(self.mplots['mTIME']) # Set Axis Labels. - self.labelstyle11b = {'font-family': 'Helvetica', 'font-size': '11pt', 'font-weight': 'bold'} + self.labelstyle11b = {'font-family': 'Helvetica', + 'font-size': '11pt', 'font-weight': 'bold'} - self.plots['FREQ'].setLabel('bottom', 'Frequency', units='Hz', **self.labelstyle11b) - self.plots['FREQ'].setLabel('left', 'Magnitude', units='dB', **self.labelstyle11b) + self.plots['FREQ'].setLabel( + 'bottom', 'Frequency', units='Hz', **self.labelstyle11b) + self.plots['FREQ'].setLabel( + 'left', 'Magnitude', units='dB', **self.labelstyle11b) - self.plots['TIME'].setLabel('bottom', 'Tap number', **self.labelstyle11b) + self.plots['TIME'].setLabel( + 'bottom', 'Tap number', **self.labelstyle11b) self.plots['TIME'].setLabel('left', 'Amplitude', **self.labelstyle11b) - self.plots['PHASE'].setLabel('bottom', 'Frequency', units='Hz', **self.labelstyle11b) - self.plots['PHASE'].setLabel('left', 'Phase', units='Radians', **self.labelstyle11b) + self.plots['PHASE'].setLabel( + 'bottom', 'Frequency', units='Hz', **self.labelstyle11b) + self.plots['PHASE'].setLabel( + 'left', 'Phase', units='Radians', **self.labelstyle11b) - self.plots['GROUP'].setLabel('bottom', 'Frequency', units='Hz', **self.labelstyle11b) - self.plots['GROUP'].setLabel('left', 'Delay', units='seconds', **self.labelstyle11b) + self.plots['GROUP'].setLabel( + 'bottom', 'Frequency', units='Hz', **self.labelstyle11b) + self.plots['GROUP'].setLabel( + 'left', 'Delay', units='seconds', **self.labelstyle11b) - self.plots['IMPRES'].setLabel('bottom', 'n', units='Samples', **self.labelstyle11b) - self.plots['IMPRES'].setLabel('left', 'Amplitude', **self.labelstyle11b) + self.plots['IMPRES'].setLabel( + 'bottom', 'n', units='Samples', **self.labelstyle11b) + self.plots['IMPRES'].setLabel( + 'left', 'Amplitude', **self.labelstyle11b) - self.plots['STEPRES'].setLabel('bottom', 'n', units='Samples', **self.labelstyle11b) - self.plots['STEPRES'].setLabel('left', 'Amplitude', **self.labelstyle11b) + self.plots['STEPRES'].setLabel( + 'bottom', 'n', units='Samples', **self.labelstyle11b) + self.plots['STEPRES'].setLabel( + 'left', 'Amplitude', **self.labelstyle11b) - self.plots['PDELAY'].setLabel('bottom', 'Frequency', units='Hz', **self.labelstyle11b) - self.plots['PDELAY'].setLabel('left', 'Phase Delay', units='Radians', **self.labelstyle11b) + self.plots['PDELAY'].setLabel( + 'bottom', 'Frequency', units='Hz', **self.labelstyle11b) + self.plots['PDELAY'].setLabel( + 'left', 'Phase Delay', units='Radians', **self.labelstyle11b) - self.labelstyle9b = {'font-family': 'Helvetica', 'font-size': '9pt', 'font-weight': 'bold'} + self.labelstyle9b = {'font-family': 'Helvetica', + 'font-size': '9pt', 'font-weight': 'bold'} - self.mplots['mTIME'].setLabel('bottom', 'n', units='Samples/taps', **self.labelstyle9b) + self.mplots['mTIME'].setLabel( + 'bottom', 'n', units='Samples/taps', **self.labelstyle9b) self.mplots['mTIME'].setLabel('left', 'Amplitude', **self.labelstyle9b) # Set up axes. @@ -337,9 +375,12 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.rcurve = self.plots['TIME'].plot(title="Real") self.icurve = self.plots['TIME'].plot(title="Imag") self.mtimecurve = self.mplots['mTIME'].plot(title="PSD") - self.mtimecurve_stems = self.mplots['mTIME'].plot(connect='pairs', name='Stems') - self.mtimecurve_i_stems = self.mplots['mTIME'].plot(connect='pairs', name='Stems') - self.mtimecurve_i = self.mplots['mTIME'].plot(title="Impulse Response Imag") + self.mtimecurve_stems = self.mplots['mTIME'].plot( + connect='pairs', name='Stems') + self.mtimecurve_i_stems = self.mplots['mTIME'].plot( + connect='pairs', name='Stems') + self.mtimecurve_i = self.mplots['mTIME'].plot( + title="Impulse Response Imag") self.plots['FREQ'].enableAutoRange(enable=True) self.freqcurve = self.plots['FREQ'].plot(title="PSD") @@ -349,38 +390,45 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.mfreqcurve = self.primary_freq_overlay.plot(title="PSD") self.secondary_freq_overlay_vb = CustomViewBox() self.primary_freq_overlay.scene().addItem(self.secondary_freq_overlay_vb) - self.primary_freq_overlay.getAxis('right').linkToView(self.secondary_freq_overlay_vb) + self.primary_freq_overlay.getAxis('right').linkToView( + self.secondary_freq_overlay_vb) self.mfreqcurve2 = pg.PlotCurveItem() # self.secondary_freq_overlay_vb.setGeometry(self.primary_freq_overlay.plotItem.vb.sceneBoundingRect()) self.secondary_freq_overlay_vb.setXLink(self.primary_freq_overlay) self.secondary_freq_overlay_vb.addItem(self.mfreqcurve2) - self.primary_freq_overlay.plotItem.vb.sigResized.connect(self.updateViews) + self.primary_freq_overlay.plotItem.vb.sigResized.connect( + self.updateViews) self.phasecurve = self.plots['PHASE'].plot(title="Phase") self.groupcurve = self.plots['GROUP'].plot(title="Group Delay") - self.imprescurve_stems = self.plots['IMPRES'].plot(connect='pairs', name='Stems') + self.imprescurve_stems = self.plots['IMPRES'].plot( + connect='pairs', name='Stems') self.imprescurve = self.plots['IMPRES'].plot(title="Impulse Response") - self.imprescurve_i_stems = self.plots['IMPRES'].plot(connect='pairs', name='Stems') + self.imprescurve_i_stems = self.plots['IMPRES'].plot( + connect='pairs', name='Stems') - self.imprescurve_i = self.plots['IMPRES'].plot(title="Impulse Response Imag") + self.imprescurve_i = self.plots['IMPRES'].plot( + title="Impulse Response Imag") - self.steprescurve_stems = self.plots['STEPRES'].plot(connect='pairs', name='Stems') + self.steprescurve_stems = self.plots['STEPRES'].plot( + connect='pairs', name='Stems') self.steprescurve = self.plots['STEPRES'].plot(title="Step Response") - self.steprescurve_i_stems = self.plots['STEPRES'].plot(connect='pairs', name='Stems') + self.steprescurve_i_stems = self.plots['STEPRES'].plot( + connect='pairs', name='Stems') - self.steprescurve_i = self.plots['STEPRES'].plot(title="Step Response Imag") + self.steprescurve_i = self.plots['STEPRES'].plot( + title="Step Response Imag") self.pdelaycurve = self.plots['PDELAY'].plot(title="Phase Delay") # Disable Ideal Band for now # self.idbanditems = IdealBandItems() - self.set_defaultpen() @@ -398,7 +446,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Populate the Band-diagram scene. self.scene = QtWidgets.QGraphicsScene() - self.scene.setSceneRect(0,0,250,250) + self.scene.setSceneRect(0, 0, 250, 250) lightback = QtGui.qRgb(0xf8, 0xf8, 0xff) backbrush = Qt.QBrush(Qt.QColor(lightback)) self.scene.setBackgroundBrush(backbrush) @@ -489,15 +537,13 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.nTapsEdit.setText("0") - self.filterWindows = {"Hamming Window" : fft.window.WIN_HAMMING, - "Hann Window" : fft.window.WIN_HANN, - "Blackman Window" : fft.window.WIN_BLACKMAN, - "Rectangular Window" : fft.window.WIN_RECTANGULAR, - "Kaiser Window" : fft.window.WIN_KAISER, - "Blackman-harris Window" : fft.window.WIN_BLACKMAN_hARRIS} - self.EQUIRIPPLE_FILT = 6 # const for equiripple filter window types. - - + self.filterWindows = {"Hamming Window": fft.window.WIN_HAMMING, + "Hann Window": fft.window.WIN_HANN, + "Blackman Window": fft.window.WIN_BLACKMAN, + "Rectangular Window": fft.window.WIN_RECTANGULAR, + "Kaiser Window": fft.window.WIN_KAISER, + "Blackman-harris Window": fft.window.WIN_BLACKMAN_hARRIS} + self.EQUIRIPPLE_FILT = 6 # const for equiripple filter window types. # Disable functionality that is not quite working in 3.8 self.gui.checkKeepcur.setEnabled(False) @@ -507,7 +553,8 @@ class gr_plot_filter(QtWidgets.QMainWindow): def updateViews(self): # for linking overlay graphs on GridView freq plots - self.secondary_freq_overlay_vb.setGeometry(self.primary_freq_overlay.plotItem.vb.sceneBoundingRect()) + self.secondary_freq_overlay_vb.setGeometry( + self.primary_freq_overlay.plotItem.vb.sceneBoundingRect()) # Set up curve pens, lines, and symbols. def set_defaultpen(self): @@ -585,7 +632,6 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.mtimecurve_i.setSymbolBrush(Qt.QBrush(Qt.Qt.gray)) self.mtimecurve_i.setSymbolSize(8) - def changed_fselect(self, ftype): if(ftype == "FIR"): self.gui.iirfilterTypeComboBox.hide() @@ -595,7 +641,8 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.globalParamsBox.show() self.gui.filterTypeComboBox.show() self.gui.filterTypeWidget.setCurrentWidget(self.gui.firlpfPage) - self.gui.tabGroup.addTab(self.gui.timeTab, _fromUtf8("Filter Taps")) + self.gui.tabGroup.addTab( + self.gui.timeTab, _fromUtf8("Filter Taps")) self.gui.mttapsPush.setEnabled(True) self.gui.addpolePush.setEnabled(False) self.gui.maddpolePush.setEnabled(False) @@ -607,54 +654,61 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.gui.adComboBox.show() self.gui.iirfilterBandComboBox.show() self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirlpfPage) - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.timeTab)) + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.timeTab)) self.gui.mttapsPush.setEnabled(False) self.gui.addpolePush.setEnabled(True) self.gui.maddpolePush.setEnabled(True) -#self.design() +# self.design() def set_order(self, ftype): if(ftype == "Bessel"): self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbesselPage) - self.changed_iirfilter_band(self.gui.iirfilterBandComboBox.currentText()) + self.changed_iirfilter_band( + self.gui.iirfilterBandComboBox.currentText()) else: - self.changed_iirfilter_band(self.gui.iirfilterBandComboBox.currentText()) + self.changed_iirfilter_band( + self.gui.iirfilterBandComboBox.currentText()) -#self.design() +# self.design() def changed_iirfilter_band(self, ftype): iirftype = self.gui.iirfilterTypeComboBox.currentText() if(ftype == "Low Pass"): if(iirftype == "Bessel"): - self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbesselPage) + self.gui.filterTypeWidget.setCurrentWidget( + self.gui.iirbesselPage) self.gui.iirbesselcritLabel2.hide() self.gui.iirbesselcritEdit2.hide() else: self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirlpfPage) elif(ftype == "Band Pass"): if(iirftype == "Bessel"): - self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbesselPage) + self.gui.filterTypeWidget.setCurrentWidget( + self.gui.iirbesselPage) self.gui.iirbesselcritLabel2.show() self.gui.iirbesselcritEdit2.show() else: self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbpfPage) elif(ftype == "Band Stop"): if(iirftype == "Bessel"): - self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbesselPage) + self.gui.filterTypeWidget.setCurrentWidget( + self.gui.iirbesselPage) self.gui.iirbesselcritLabel2.show() self.gui.iirbesselcritEdit2.show() else: self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbsfPage) elif(ftype == "High Pass"): if(iirftype == "Bessel"): - self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirbesselPage) + self.gui.filterTypeWidget.setCurrentWidget( + self.gui.iirbesselPage) self.gui.iirbesselcritLabel2.hide() self.gui.iirbesselcritEdit2.hide() else: self.gui.filterTypeWidget.setCurrentWidget(self.gui.iirhpfPage) -#self.design() +# self.design() def changed_filter_type(self, ftype): if(ftype == "Low Pass"): @@ -684,7 +738,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): elif(ftype == "Half Band"): self.gui.filterTypeWidget.setCurrentWidget(self.gui.firhbPage) -#self.design() +# self.design() def changed_filter_design_type(self, design): if(design == "Equiripple"): @@ -692,7 +746,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): else: self.set_windowed() -#self.design() +# self.design() def set_equiripple(self): # Stop sending the signal for this function. @@ -747,7 +801,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): items = self.gui.filterTypeComboBox.count() for i in range(items): self.gui.filterTypeComboBox.removeItem(0) - + self.gui.filterTypeComboBox.addItems(self.firFilters) # If the last filter type was valid for this window type, @@ -763,9 +817,9 @@ class gr_plot_filter(QtWidgets.QMainWindow): def design(self): ret = True - fs,r = getfloat(self.gui.sampleRateEdit.text()) + fs, r = getfloat(self.gui.sampleRateEdit.text()) ret = r and ret - gain,r = getfloat(self.gui.filterGainEdit.text()) + gain, r = getfloat(self.gui.filterGainEdit.text()) ret = r and ret winstr = self.gui.filterDesignTypeComboBox.currentText() @@ -773,7 +827,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): fsel = self.gui.fselectComboBox.currentText() if (fsel == "FIR"): - self.b, self.a = [],[] + self.b, self.a = [], [] if(ret): self.design_fir(ftype, fs, gain, winstr) elif (fsel.startswith("IIR")): @@ -783,8 +837,8 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.design_iir() if len(w): reply = QtWidgets.QMessageBox.information(self, "BadCoefficients", - str(w[-1].message), - QtWidgets.QMessageBox.Ok) + str(w[-1].message), + QtWidgets.QMessageBox.Ok) # Do FIR design. def design_fir(self, ftype, fs, gain, winstr): @@ -792,25 +846,25 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.cpicker.set_iir(False) self.cpicker2.set_iir(False) if(winstr == "Equiripple"): - designer = {"Low Pass" : design_opt_lpf, - "Band Pass" : design_opt_bpf, - "Complex Band Pass" : design_opt_cbpf, - "Band Notch" : design_opt_bnf, - "Half Band" : design_opt_hb, - "High Pass" : design_opt_hpf} - taps,params,r = designer[ftype](fs, gain, self) - - else: - designer = {"Low Pass" : design_win_lpf, - "Band Pass" : design_win_bpf, - "Complex Band Pass" : design_win_cbpf, - "Band Notch" : design_win_bnf, - "High Pass" : design_win_hpf, - "Half Band" : design_win_hb, - "Root Raised Cosine" : design_win_rrc, - "Gaussian" : design_win_gaus} + designer = {"Low Pass": design_opt_lpf, + "Band Pass": design_opt_bpf, + "Complex Band Pass": design_opt_cbpf, + "Band Notch": design_opt_bnf, + "Half Band": design_opt_hb, + "High Pass": design_opt_hpf} + taps, params, r = designer[ftype](fs, gain, self) + + else: + designer = {"Low Pass": design_win_lpf, + "Band Pass": design_win_bpf, + "Complex Band Pass": design_win_cbpf, + "Band Notch": design_win_bnf, + "High Pass": design_win_hpf, + "Half Band": design_win_hb, + "Root Raised Cosine": design_win_rrc, + "Gaussian": design_win_gaus} wintype = int(self.filterWindows[winstr]) - taps,params,r = designer[ftype](fs, gain, wintype, self) + taps, params, r = designer[ftype](fs, gain, wintype, self) if(r): if self.gridview: self.params = params @@ -819,7 +873,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.set_mttaps() self.gui.nTapsEdit.setText(str(self.taps.size)) else: - self.draw_plots(taps,params) + self.draw_plots(taps, params) zeros = self.get_zeros() poles = self.get_poles() self.gui.pzPlot.insertZeros(zeros) @@ -848,46 +902,49 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.cpicker.set_iir(True) self.cpicker2.set_iir(True) - iirft = {"Elliptic" : 'ellip', - "Butterworth" : 'butter', - "Chebyshev-1" : 'cheby1', - "Chebyshev-2" : 'cheby2', - "Bessel" : 'bessel' } + iirft = {"Elliptic": 'ellip', + "Butterworth": 'butter', + "Chebyshev-1": 'cheby1', + "Chebyshev-2": 'cheby2', + "Bessel": 'bessel'} - sanalog = {"Analog (rad/second)" : 1, - "Digital (normalized 0-1)" : 0 } + sanalog = {"Analog (rad/second)": 1, + "Digital (normalized 0-1)": 0} - paramtype = { 1 : "analog", - 0 : "digital" } + paramtype = {1: "analog", + 0: "digital"} iirabbr = { - "Low Pass" : "lpf", - "High Pass" : "hpf", - "Band Pass" : "bpf", - "Band Stop" : "bnf" } - - iirboxes = {"Low Pass" : [float(self.gui.iirendofLpfPassBandEdit.text()), - float(self.gui.iirstartofLpfStopBandEdit.text()), - float(self.gui.iirLpfPassBandAttenEdit.text()), - float(self.gui.iirLpfStopBandRippleEdit.text())], - - "High Pass" : [float(self.gui.iirstartofHpfPassBandEdit.text()), - float(self.gui.iirendofHpfStopBandEdit.text()), - float(self.gui.iirHpfPassBandAttenEdit.text()), - float(self.gui.iirHpfStopBandRippleEdit.text())], - - "Band Pass" : [float(self.gui.iirstartofBpfPassBandEdit.text()), - float(self.gui.iirendofBpfPassBandEdit.text()), - float(self.gui.iirendofBpfStopBandEdit1.text()), - float(self.gui.iirstartofBpfStopBandEdit2.text()), - float(self.gui.iirBpfPassBandAttenEdit.text()), - float(self.gui.iirBpfStopBandRippleEdit.text())], - - "Band Stop" : [float(self.gui.iirendofBsfPassBandEdit1.text()), - float(self.gui.iirstartofBsfPassBandEdit2.text()), - float(self.gui.iirstartofBsfStopBandEdit.text()), - float(self.gui.iirendofBsfStopBandEdit.text()), - float(self.gui.iirBsfPassBandAttenEdit.text()), - float(self.gui.iirBsfStopBandRippleEdit.text())] } + "Low Pass": "lpf", + "High Pass": "hpf", + "Band Pass": "bpf", + "Band Stop": "bnf"} + + iirboxes = {"Low Pass": [float(self.gui.iirendofLpfPassBandEdit.text()), + float(self.gui.iirstartofLpfStopBandEdit.text()), + float(self.gui.iirLpfPassBandAttenEdit.text()), + float(self.gui.iirLpfStopBandRippleEdit.text())], + + "High Pass": [float(self.gui.iirstartofHpfPassBandEdit.text()), + float(self.gui.iirendofHpfStopBandEdit.text()), + float(self.gui.iirHpfPassBandAttenEdit.text()), + float(self.gui.iirHpfStopBandRippleEdit.text())], + + "Band Pass": [float(self.gui.iirstartofBpfPassBandEdit.text()), + float(self.gui.iirendofBpfPassBandEdit.text()), + float(self.gui.iirendofBpfStopBandEdit1.text()), + float( + self.gui.iirstartofBpfStopBandEdit2.text()), + float(self.gui.iirBpfPassBandAttenEdit.text()), + float(self.gui.iirBpfStopBandRippleEdit.text())], + + "Band Stop": [float(self.gui.iirendofBsfPassBandEdit1.text()), + float( + self.gui.iirstartofBsfPassBandEdit2.text()), + float( + self.gui.iirstartofBsfStopBandEdit.text()), + float(self.gui.iirendofBsfStopBandEdit.text()), + float(self.gui.iirBsfPassBandAttenEdit.text()), + float(self.gui.iirBsfStopBandRippleEdit.text())]} # Remove Ideal band-diagrams if IIR. # self.set_drawideal() @@ -895,7 +952,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): params.append(iirboxes[iirbtype][i]) if len(iirboxes[iirbtype]) == 6: - params = [params[:2],params[2:4],params[4],params[5]] + params = [params[:2], params[2:4], params[4], params[5]] if(iirftype == "Bessel"): if iirbtype == "Low Pass" or iirbtype == "High Pass": @@ -911,7 +968,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): analog=sanalog[atype], ftype=iirft[iirftype], output='ba') except Exception as e: reply = QtWidgets.QMessageBox.information(self, "IIR design error", e.args[0], - QtWidgets.QMessageBox.Ok) + QtWidgets.QMessageBox.Ok) (self.z, self.p, self.k) = signal.tf2zpk(self.b, self.a) @@ -923,7 +980,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): analog=sanalog[atype], ftype=iirft[iirftype], output='ba') except Exception as e: reply = QtWidgets.QMessageBox.information(self, "IIR design error", e.args[0], - QtWidgets.QMessageBox.Ok) + QtWidgets.QMessageBox.Ok) (self.z, self.p, self.k) = signal.tf2zpk(self.b, self.a) # Create parameters. @@ -947,12 +1004,12 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.callback(retobj) # IIR Filter design plot updates. - def iir_plot_all(self,z,p,k): - self.b,self.a = signal.zpk2tf(z,p,k) - w,h = signal.freqz(self.b,self.a) - self.fftdB = 20 * np.log10 (abs(h)) + def iir_plot_all(self, z, p, k): + self.b, self.a = signal.zpk2tf(z, p, k) + w, h = signal.freqz(self.b, self.a) + self.fftdB = 20 * np.log10(abs(h)) self.freq = w / max(w) - self.fftDeg = np.unwrap(np.arctan2(np.imag(h),np.real(h))) + self.fftDeg = np.unwrap(np.arctan2(np.imag(h), np.real(h))) self.groupDelay = -np.diff(self.fftDeg) self.phaseDelay = -self.fftDeg[1:] / self.freq[1:] if self.gridview: @@ -966,9 +1023,8 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.update_step_curves() self.update_imp_curves() - def nfft_edit_changed(self, nfft): - infft,r = getint(nfft) + infft, r = getint(nfft) if(r and (infft != self.nfftpts)): self.nfftpts = infft self.update_freq_curves() @@ -988,7 +1044,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.freq = np.linspace(start=0, stop=fs, num=Npts, endpoint=False) with warnings.catch_warnings(record=True) as w: warnings.simplefilter("always") - self.fftdB = 20.0*np.log10(abs(fftpts)) + self.fftdB = 20.0 * np.log10(abs(fftpts)) if any(self.fftdB == float('-inf')): sys.stderr.write('Filter design failed (taking log10 of 0).\n') self.fftdB = np.zeros([len(fftpts)]) @@ -1009,33 +1065,30 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.icurve.setData(np.arange(ntaps), self.taps.imag) else: self.rcurve.setData(np.arange(ntaps), self.taps) - self.icurve.setData([],[]); + self.icurve.setData([], []) if self.mttaps: if(type(self.taps[0]) == scipy.complex128): self.mtimecurve_stems.setData(np.repeat(np.arange(ntaps), 2), - np.dstack((np.zeros(self.taps.real.shape[0], dtype=int), - self.taps.real)).flatten()) + np.dstack((np.zeros(self.taps.real.shape[0], dtype=int), + self.taps.real)).flatten()) self.mtimecurve.setData(np.arange(ntaps), self.taps.real) - self.mtimecurve_i_stems.setData(np.repeat(np.arange(ntaps), 2), np.dstack((np.zeros(self.taps.imag.shape[0], dtype=int), - self.taps.imag)).flatten()) + self.taps.imag)).flatten()) self.mtimecurve_i.setData(np.arange(ntaps), self.taps.imag) else: self.mtimecurve.setData(np.arange(ntaps), self.taps) self.mtimecurve_stems.setData(np.repeat(np.arange(ntaps), 2), - np.dstack((np.zeros(self.taps.shape[0], dtype=int), - self.taps)).flatten()) - - self.mtimecurve_i_stems.setData([],[]) - self.mtimecurve_i.setData([],[]) - + np.dstack((np.zeros(self.taps.shape[0], dtype=int), + self.taps)).flatten()) + self.mtimecurve_i_stems.setData([], []) + self.mtimecurve_i.setData([], []) # Configure plots. if self.mtoverlay: @@ -1056,7 +1109,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Data. if self.iir: - stepres = self.step_response(self.b,self.a) + stepres = self.step_response(self.b, self.a) ntaps = 50 else: stepres = self.step_response(self.taps) @@ -1068,7 +1121,6 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.steprescurve.setData(np.arange(ntaps), stepres.real) - self.steprescurve_i_stems.setData(np.repeat(np.arange(ntaps), 2), np.dstack((np.zeros(stepres.imag.shape[0], dtype=int), stepres.imag)).flatten()) @@ -1080,31 +1132,30 @@ class gr_plot_filter(QtWidgets.QMainWindow): stepres)).flatten()) self.steprescurve.setData(np.arange(ntaps), stepres) - self.steprescurve_i_stems.setData([],[]) - self.steprescurve_i.setData([],[]) + self.steprescurve_i_stems.setData([], []) + self.steprescurve_i.setData([], []) if self.mtstep: if(type(stepres[0]) == np.complex128): self.mtimecurve_stems.setData(np.repeat(np.arange(ntaps), 2), - np.dstack((np.zeros(stepres.real.shape[0], dtype=int), - stepres.real)).flatten()) + np.dstack((np.zeros(stepres.real.shape[0], dtype=int), + stepres.real)).flatten()) self.mtimecurve.setData(np.arange(ntaps), stepres.real) - self.mtimecurve_i_stems.setData(np.repeat(np.arange(ntaps), 2), np.dstack((np.zeros(stepres.imag.shape[0], dtype=int), - stepres.imag)).flatten()) + stepres.imag)).flatten()) self.mtimecurve_i.setData(np.arange(ntaps), stepres.imag) else: self.mtimecurve_stems.setData(np.repeat(np.arange(ntaps), 2), - np.dstack((np.zeros(stepres.shape[0], dtype=int), - stepres)).flatten()) + np.dstack((np.zeros(stepres.shape[0], dtype=int), + stepres)).flatten()) self.mtimecurve.setData(np.arange(ntaps), stepres) - self.mtimecurve_i_stems.setData([],[]) - self.mtimecurve_i.setData([],[]) + self.mtimecurve_i_stems.setData([], []) + self.mtimecurve_i.setData([], []) # Configure plots. if self.mtoverlay: @@ -1137,7 +1188,6 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.imprescurve.setData(np.arange(ntaps), impres.real) - self.imprescurve_i_stems.setData(np.repeat(np.arange(ntaps), 2), np.dstack((np.zeros(impres.imag.shape[0], dtype=int), impres.imag)).flatten()) @@ -1151,25 +1201,24 @@ class gr_plot_filter(QtWidgets.QMainWindow): if self.mtimpulse: if(type(impres[0]) == np.complex128): self.mtimecurve_stems.setData(np.repeat(np.arange(ntaps), 2), - np.dstack((np.zeros(impres.real.shape[0], dtype=int), - impres.real)).flatten()) + np.dstack((np.zeros(impres.real.shape[0], dtype=int), + impres.real)).flatten()) self.mtimecurve.setData(np.arange(ntaps), impres.real) - self.mtimecurve_i_stems.setData(np.repeat(np.arange(ntaps), 2), np.dstack((np.zeros(impres.imag.shape[0], dtype=int), - impres.imag)).flatten()) + impres.imag)).flatten()) self.mtimecurve_i.setData(np.arange(ntaps), impres.imag) else: self.mtimecurve_stems.setData(np.repeat(np.arange(ntaps), 2), - np.dstack((np.zeros(impres.shape[0], dtype=int), - impres)).flatten()) + np.dstack((np.zeros(impres.shape[0], dtype=int), + impres)).flatten()) self.mtimecurve.setData(np.arange(ntaps), impres) - self.mtimecurve_i_stems.setData([],[]) - self.mtimecurve_i.setData([],[]) + self.mtimecurve_i_stems.setData([], []) + self.mtimecurve_i.setData([], []) # Configure plots. if self.mtoverlay: @@ -1197,11 +1246,11 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.mfphasedelay = True self.update_pdelay_curves(True) - self.mplots['mFREQ'].showAxis('right', True) + self.mplots['mFREQ'].showAxis('right', True) else: self.mplots['mFREQ'].setMouseEnabled(x=False, y=False) - self.mplots['mFREQ'].showAxis('right', False) - self.mfreqcurve2.setData([],[]) + self.mplots['mFREQ'].showAxis('right', False) + self.mfreqcurve2.setData([], []) def update_freq_curves(self, secondary=False): npts = len(self.fftdB) @@ -1211,28 +1260,29 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Data. if self.iir: - self.freqcurve.setData(self.freq[:npts-1], self.fftdB[:npts-1]) + self.freqcurve.setData(self.freq[:npts - 1], self.fftdB[:npts - 1]) else: - self.freqcurve.setData(self.freq[:int(npts//2)], self.fftdB[:int(npts//2)]) + self.freqcurve.setData( + self.freq[:int(npts // 2)], self.fftdB[:int(npts // 2)]) if self.mfmagresponse: curve = self.mfreqcurve - if secondary: + if secondary: curve = self.mfreqcurve2 if self.iir: - curve.setData(self.freq[:npts-1], self.fftdB[:npts-1]) + curve.setData(self.freq[:npts - 1], self.fftdB[:npts - 1]) else: - curve.setData(self.freq[:int(npts//2)], self.fftdB[:int(npts//2)]) - + curve.setData(self.freq[:int(npts // 2)], + self.fftdB[:int(npts // 2)]) # Set axes to new scales. # Set plot limits and reset axis zoom. if self.iir: - xmax = self.freq[npts-1] + xmax = self.freq[npts - 1] else: - xmax = self.freq[npts//2] + xmax = self.freq[npts // 2] xmin = self.freq[0] @@ -1240,15 +1290,16 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.plot_auto_limit(self.mplots['mFREQ'], xMin=xmin, xMax=xmax) if secondary: - self.mplots['mFREQ'].setLabel('right', 'Magnitude', units='dB', **self.labelstyle9b) + self.mplots['mFREQ'].setLabel( + 'right', 'Magnitude', units='dB', **self.labelstyle9b) else: - self.mplots['mFREQ'].setLabel('left', 'Magnitude', units='dB', **self.labelstyle9b) + self.mplots['mFREQ'].setLabel( + 'left', 'Magnitude', units='dB', **self.labelstyle9b) if not secondary: self.plot_secondary() self.last_mfreq_plot = 'freq' - def update_phase_curves(self, secondary=False): npts = len(self.fftDeg) @@ -1257,27 +1308,28 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Data. if self.iir: - self.phasecurve.setData(self.freq[:npts-1], self.fftDeg[:npts-1]) + self.phasecurve.setData( + self.freq[:npts - 1], self.fftDeg[:npts - 1]) else: - self.phasecurve.setData(self.freq[:int(npts//2)], self.fftDeg[:int(npts//2)]) + self.phasecurve.setData( + self.freq[:int(npts // 2)], self.fftDeg[:int(npts // 2)]) if self.mfphaseresponse: curve = self.mfreqcurve - if secondary: + if secondary: curve = self.mfreqcurve2 if self.iir: - curve.setData(self.freq[:npts-1], self.fftDeg[:npts-1]) + curve.setData(self.freq[:npts - 1], self.fftDeg[:npts - 1]) else: - curve.setData(self.freq[:int(npts//2)], self.fftDeg[:int(npts//2)]) - - + curve.setData(self.freq[:int(npts // 2)], + self.fftDeg[:int(npts // 2)]) # Set plot limits and reset axis zoom. if self.iir: - xmax = self.freq[npts-1] + xmax = self.freq[npts - 1] else: - xmax = self.freq[npts//2] + xmax = self.freq[npts // 2] xmin = self.freq[0] @@ -1286,10 +1338,11 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Axis title. if secondary: - self.mplots['mFREQ'].setLabel('right', 'Phase', units='Radians', **self.labelstyle9b) + self.mplots['mFREQ'].setLabel( + 'right', 'Phase', units='Radians', **self.labelstyle9b) else: - self.mplots['mFREQ'].setLabel('left', 'Phase', units='Radians', **self.labelstyle9b) - + self.mplots['mFREQ'].setLabel( + 'left', 'Phase', units='Radians', **self.labelstyle9b) if not secondary: self.plot_secondary() @@ -1303,20 +1356,22 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Data. if self.iir: - self.groupcurve.setData(self.freq[:npts-1], self.groupDelay[:npts-1]) + self.groupcurve.setData( + self.freq[:npts - 1], self.groupDelay[:npts - 1]) else: - self.groupcurve.setData(self.freq[:int(npts//2)], self.groupDelay[:int(npts//2)]) + self.groupcurve.setData( + self.freq[:int(npts // 2)], self.groupDelay[:int(npts // 2)]) if self.mfgroupdelay: curve = self.mfreqcurve - if secondary: + if secondary: curve = self.mfreqcurve2 if self.iir: - curve.setData(self.freq[:npts-1], self.groupDelay[:npts-1]) + curve.setData(self.freq[:npts - 1], self.groupDelay[:npts - 1]) else: - curve.setData(self.freq[:int(npts//2)], self.groupDelay[:int(npts//2)]) - + curve.setData(self.freq[:int(npts // 2)], + self.groupDelay[:int(npts // 2)]) # Configure plots. if self.mtoverlay: @@ -1327,9 +1382,9 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set plot limits and reset axis zoom. if self.iir: - xmax = self.freq[npts-1] + xmax = self.freq[npts - 1] else: - xmax = self.freq[npts//2] + xmax = self.freq[npts // 2] xmin = self.freq[0] @@ -1338,11 +1393,11 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Axis title. if secondary: - self.mplots['mFREQ'].setLabel('right', 'Delay', units='seconds', **self.labelstyle9b) + self.mplots['mFREQ'].setLabel( + 'right', 'Delay', units='seconds', **self.labelstyle9b) else: - self.mplots['mFREQ'].setLabel('left', 'Delay', units='seconds', **self.labelstyle9b) - - + self.mplots['mFREQ'].setLabel( + 'left', 'Delay', units='seconds', **self.labelstyle9b) if not secondary: self.plot_secondary() @@ -1356,25 +1411,27 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Data. if self.iir: - self.pdelaycurve.setData(self.freq[:npts-1], self.phaseDelay[:npts-1]) + self.pdelaycurve.setData( + self.freq[:npts - 1], self.phaseDelay[:npts - 1]) else: - self.pdelaycurve.setData(self.freq[:int(npts//2)], self.phaseDelay[:int(npts//2)]) - + self.pdelaycurve.setData( + self.freq[:int(npts // 2)], self.phaseDelay[:int(npts // 2)]) + if self.mfphasedelay: curve = self.mfreqcurve - if secondary: + if secondary: curve = self.mfreqcurve2 if self.iir: - curve.setData(self.freq[:npts-1], self.phaseDelay[:npts-1]) + curve.setData(self.freq[:npts - 1], self.phaseDelay[:npts - 1]) else: - curve.setData(self.freq[:int(npts//2)], self.phaseDelay[:int(npts//2)]) - + curve.setData(self.freq[:int(npts // 2)], + self.phaseDelay[:int(npts // 2)]) # Set plot limits and reset axis zoom. if self.iir: - xmax = self.freq[npts-1] + xmax = self.freq[npts - 1] else: - xmax = self.freq[npts//2] + xmax = self.freq[npts // 2] xmin = self.freq[0] @@ -1383,9 +1440,11 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set Axis title. if secondary: - self.mplots['mFREQ'].setLabel('right', 'Phase Delay', **self.labelstyle9b) + self.mplots['mFREQ'].setLabel( + 'right', 'Phase Delay', **self.labelstyle9b) else: - self.mplots['mFREQ'].setLabel('left', 'Phase Delay', **self.labelstyle9b) + self.mplots['mFREQ'].setLabel( + 'left', 'Phase Delay', **self.labelstyle9b) if not secondary: self.plot_secondary() @@ -1482,7 +1541,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.plots[i].showGrid(x=True, y=True) def set_actgrid(self): - if (self.gui.actionGrid_2.isChecked() == 0 ): + if (self.gui.actionGrid_2.isChecked() == 0): self.gridenable = False for i in self.plots: @@ -1500,31 +1559,35 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.plots[i].showGrid(x=True, y=True) def set_magresponse(self): - if (self.gui.checkMagres.checkState() == 0 ): + if (self.gui.checkMagres.checkState() == 0): self.magres = False - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.freqTab)) + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.freqTab)) else: self.magres = True - self.gui.tabGroup.addTab(self.gui.freqTab, _fromUtf8("Magnitude Response")) + self.gui.tabGroup.addTab( + self.gui.freqTab, _fromUtf8("Magnitude Response")) self.update_freq_curves() def set_actmagresponse(self): - if (self.gui.actionMagnitude_Response.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.freqTab)) + if (self.gui.actionMagnitude_Response.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.freqTab)) else: - self.gui.tabGroup.addTab(self.gui.freqTab, _fromUtf8("Magnitude Response")) + self.gui.tabGroup.addTab( + self.gui.freqTab, _fromUtf8("Magnitude Response")) self.update_freq_curves() def set_switchview(self): - if (self.gui.actionGridview.isChecked() == 0 ): + if (self.gui.actionGridview.isChecked() == 0): self.gridview = 0 self.set_defaultpen() self.set_actgrid() self.gui.stackedWindows.setCurrentIndex(0) if self.iir: - self.iir_plot_all(self.z,self.p,self.k) + self.iir_plot_all(self.z, self.p, self.k) else: - self.draw_plots(self.taps,self.params) + self.draw_plots(self.taps, self.params) else: self.gridview = 1 self.set_actgrid() @@ -1534,7 +1597,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): # self.set_drawideal() def set_plotselect(self): - if (self.gui.actionPlot_select.isChecked() == 0 ): + if (self.gui.actionPlot_select.isChecked() == 0): self.gui.mfgroupBox.hide() self.gui.mtgroupBox.hide() self.gui.pzgroupBox.hide() @@ -1570,7 +1633,6 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.mfgroupdelay = False self.mfphaseresponse = False - self.update_freq_curves() def set_mfphaseresponse(self): @@ -1610,13 +1672,13 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.update_pdelay_curves() - def ifinlist(self,a,dlist): + def ifinlist(self, a, dlist): for d in dlist: - if self.compare_instances(a,d): + if self.compare_instances(a, d): return True return False - def compare_instances(self,a,b): + def compare_instances(self, a, b): if a is b: return True else: @@ -1694,63 +1756,77 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.mttaps = False self.mtstep = False - self.update_imp_curves() - def set_gdelay(self): - if (self.gui.checkGdelay.checkState() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.groupTab)) + if (self.gui.checkGdelay.checkState() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.groupTab)) else: - self.gui.tabGroup.addTab(self.gui.groupTab, _fromUtf8("Group Delay")) + self.gui.tabGroup.addTab( + self.gui.groupTab, _fromUtf8("Group Delay")) self.update_freq_curves() def set_actgdelay(self): - if (self.gui.actionGroup_Delay.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.groupTab)) + if (self.gui.actionGroup_Delay.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.groupTab)) else: - self.gui.tabGroup.addTab(self.gui.groupTab, _fromUtf8("Group Delay")) + self.gui.tabGroup.addTab( + self.gui.groupTab, _fromUtf8("Group Delay")) self.update_freq_curves() def set_phase(self): - if (self.gui.checkPhase.checkState() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.phaseTab)) + if (self.gui.checkPhase.checkState() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.phaseTab)) else: - self.gui.tabGroup.addTab(self.gui.phaseTab, _fromUtf8("Phase Response")) + self.gui.tabGroup.addTab( + self.gui.phaseTab, _fromUtf8("Phase Response")) self.update_freq_curves() def set_actphase(self): - if (self.gui.actionPhase_Respone.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.phaseTab)) + if (self.gui.actionPhase_Respone.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.phaseTab)) else: - self.gui.tabGroup.addTab(self.gui.phaseTab, _fromUtf8("Phase Response")) + self.gui.tabGroup.addTab( + self.gui.phaseTab, _fromUtf8("Phase Response")) self.update_freq_curves() def set_fcoeff(self): - if (self.gui.checkFcoeff.checkState() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.fcTab)) + if (self.gui.checkFcoeff.checkState() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.fcTab)) else: - self.gui.tabGroup.addTab(self.gui.fcTab, _fromUtf8("Filter Coefficients")) + self.gui.tabGroup.addTab( + self.gui.fcTab, _fromUtf8("Filter Coefficients")) self.update_fcoeff() def set_actfcoeff(self): - if (self.gui.actionFilter_Coefficients.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.fcTab)) + if (self.gui.actionFilter_Coefficients.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.fcTab)) else: - self.gui.tabGroup.addTab(self.gui.fcTab, _fromUtf8("Filter Coefficients")) + self.gui.tabGroup.addTab( + self.gui.fcTab, _fromUtf8("Filter Coefficients")) self.update_fcoeff() def set_band(self): - if (self.gui.checkBand.checkState() == 0 ): - self.gui.filterspecView.removeTab(self.gui.filterspecView.indexOf(self.gui.bandDiagram)) + if (self.gui.checkBand.checkState() == 0): + self.gui.filterspecView.removeTab( + self.gui.filterspecView.indexOf(self.gui.bandDiagram)) else: - self.gui.filterspecView.addTab(self.gui.bandDiagram, _fromUtf8("Band Diagram")) + self.gui.filterspecView.addTab( + self.gui.bandDiagram, _fromUtf8("Band Diagram")) def set_actband(self): - if (self.gui.actionBand_Diagram.isChecked() == 0 ): - self.gui.filterspecView.removeTab(self.gui.filterspecView.indexOf(self.gui.bandDiagram)) + if (self.gui.actionBand_Diagram.isChecked() == 0): + self.gui.filterspecView.removeTab( + self.gui.filterspecView.indexOf(self.gui.bandDiagram)) else: - self.gui.filterspecView.addTab(self.gui.bandDiagram, _fromUtf8("Band Diagram")) + self.gui.filterspecView.addTab( + self.gui.bandDiagram, _fromUtf8("Band Diagram")) # def set_drawideal(self): # fsel = self.gui.fselectComboBox.currentText() @@ -1768,54 +1844,70 @@ class gr_plot_filter(QtWidgets.QMainWindow): # plot.replot() def set_pzplot(self): - if (self.gui.checkPzplot.checkState() == 0 ): - self.gui.filterspecView.removeTab(self.gui.filterspecView.indexOf(self.gui.poleZero)) + if (self.gui.checkPzplot.checkState() == 0): + self.gui.filterspecView.removeTab( + self.gui.filterspecView.indexOf(self.gui.poleZero)) else: - self.gui.filterspecView.addTab(self.gui.poleZero, _fromUtf8("Pole-Zero Plot")) + self.gui.filterspecView.addTab( + self.gui.poleZero, _fromUtf8("Pole-Zero Plot")) def set_actpzplot(self): - if (self.gui.actionPole_Zero_Plot_2.isChecked() == 0 ): - self.gui.filterspecView.removeTab(self.gui.filterspecView.indexOf(self.gui.poleZero)) + if (self.gui.actionPole_Zero_Plot_2.isChecked() == 0): + self.gui.filterspecView.removeTab( + self.gui.filterspecView.indexOf(self.gui.poleZero)) else: - self.gui.filterspecView.addTab(self.gui.poleZero, _fromUtf8("Pole-Zero Plot")) + self.gui.filterspecView.addTab( + self.gui.poleZero, _fromUtf8("Pole-Zero Plot")) def set_pdelay(self): - if (self.gui.checkPzplot.checkState() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.pdelayTab)) + if (self.gui.checkPzplot.checkState() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.pdelayTab)) else: - self.gui.tabGroup.addTab(self.gui.pdelayTab, _fromUtf8("Phase Delay")) + self.gui.tabGroup.addTab( + self.gui.pdelayTab, _fromUtf8("Phase Delay")) def set_actpdelay(self): - if (self.gui.actionPhase_Delay.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.pdelayTab)) + if (self.gui.actionPhase_Delay.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.pdelayTab)) else: - self.gui.tabGroup.addTab(self.gui.pdelayTab, _fromUtf8("Phase Delay")) + self.gui.tabGroup.addTab( + self.gui.pdelayTab, _fromUtf8("Phase Delay")) def set_impres(self): - if (self.gui.checkImpulse.checkState() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.impresTab)) + if (self.gui.checkImpulse.checkState() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.impresTab)) else: - self.gui.tabGroup.addTab(self.gui.impresTab, _fromUtf8("Impulse Response")) + self.gui.tabGroup.addTab( + self.gui.impresTab, _fromUtf8("Impulse Response")) def set_actimpres(self): - if (self.gui.actionImpulse_Response.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.impresTab)) + if (self.gui.actionImpulse_Response.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.impresTab)) else: - self.gui.tabGroup.addTab(self.gui.impresTab, _fromUtf8("Impulse Response")) + self.gui.tabGroup.addTab( + self.gui.impresTab, _fromUtf8("Impulse Response")) def set_stepres(self): - if (self.gui.checkStep.checkState() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.stepresTab)) + if (self.gui.checkStep.checkState() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.stepresTab)) else: - self.gui.tabGroup.addTab(self.gui.stepresTab, _fromUtf8("Step Response")) + self.gui.tabGroup.addTab( + self.gui.stepresTab, _fromUtf8("Step Response")) def set_actstepres(self): - if (self.gui.actionStep_Response.isChecked() == 0 ): - self.gui.tabGroup.removeTab(self.gui.tabGroup.indexOf(self.gui.stepresTab)) + if (self.gui.actionStep_Response.isChecked() == 0): + self.gui.tabGroup.removeTab( + self.gui.tabGroup.indexOf(self.gui.stepresTab)) else: - self.gui.tabGroup.addTab(self.gui.stepresTab, _fromUtf8("Step Response")) + self.gui.tabGroup.addTab( + self.gui.stepresTab, _fromUtf8("Step Response")) - def populate_bandview(self,fitems): + def populate_bandview(self, fitems): for item in fitems: if (item.isWidgetType()): self.scene.addWidget(item) @@ -1826,34 +1918,34 @@ class gr_plot_filter(QtWidgets.QMainWindow): for item in list(self.scene.items()): self.scene.removeItem(item) - def set_fatten(self,atten): + def set_fatten(self, atten): ftype = self.gui.filterTypeComboBox.currentText() if (ftype == "Low Pass"): - boxatten,r = getfloat(self.gui.lpfStopBandAttenEdit.text()) - self.gui.lpfStopBandAttenEdit.setText(str(atten+boxatten)) + boxatten, r = getfloat(self.gui.lpfStopBandAttenEdit.text()) + self.gui.lpfStopBandAttenEdit.setText(str(atten + boxatten)) if ftype == "High Pass": - boxatten,r = getfloat(self.gui.hpfStopBandAttenEdit.text()) - self.gui.hpfStopBandAttenEdit.setText(str(atten+boxatten)) + boxatten, r = getfloat(self.gui.hpfStopBandAttenEdit.text()) + self.gui.hpfStopBandAttenEdit.setText(str(atten + boxatten)) if ftype == "Band Pass": - boxatten,r = getfloat(self.gui.bpfStopBandAttenEdit.text()) - self.gui.bpfStopBandAttenEdit.setText(str(atten+boxatten)) + boxatten, r = getfloat(self.gui.bpfStopBandAttenEdit.text()) + self.gui.bpfStopBandAttenEdit.setText(str(atten + boxatten)) if ftype == "Band Notch": - boxatten,r = getfloat(self.gui.bnfStopBandAttenEdit.text()) - self.gui.bnfStopBandAttenEdit.setText(str(atten+boxatten)) + boxatten, r = getfloat(self.gui.bnfStopBandAttenEdit.text()) + self.gui.bnfStopBandAttenEdit.setText(str(atten + boxatten)) if ftype == "Complex Band Pass": - boxatten,r = getfloat(self.gui.bpfStopBandAttenEdit.text()) - self.gui.bpfStopBandAttenEdit.setText(str(atten+boxatten)) + boxatten, r = getfloat(self.gui.bpfStopBandAttenEdit.text()) + self.gui.bpfStopBandAttenEdit.setText(str(atten + boxatten)) def set_curvetaps(self, zeros_poles): zr, pl = zeros_poles if self.iir: self.z = zr self.p = pl - self.iir_plot_all(self.z,self.p,self.k) + self.iir_plot_all(self.z, self.p, self.k) self.gui.mpzPlot.insertZeros(zr) self.gui.mpzPlot.insertPoles(pl) self.update_fcoeff() @@ -1862,10 +1954,10 @@ class gr_plot_filter(QtWidgets.QMainWindow): retobj.update_all("iir", self.params, (self.b, self.a), 1) self.callback(retobj) else: - hz = poly1d(zr,r=1) + hz = poly1d(zr, r=1) # print hz.c. - self.taps = hz.c*self.taps[0] - self.draw_plots(self.taps,self.params) + self.taps = hz.c * self.taps[0] + self.draw_plots(self.taps, self.params) self.update_fcoeff() # update the pzplot in other view. zeros = self.get_zeros() @@ -1883,7 +1975,7 @@ class gr_plot_filter(QtWidgets.QMainWindow): if self.iir: self.z = zr self.p = pl - self.iir_plot_all(self.z,self.p,self.k) + self.iir_plot_all(self.z, self.p, self.k) self.gui.pzPlot.insertZeros(zr) self.gui.pzPlot.insertPoles(pl) self.update_fcoeff() @@ -1892,15 +1984,15 @@ class gr_plot_filter(QtWidgets.QMainWindow): retobj.update_all("iir", self.params, (self.b, self.a), 1) self.callback(retobj) else: - hz = poly1d(zr,r=1) + hz = poly1d(zr, r=1) # print hz.c. - self.taps = hz.c*self.taps[0] + self.taps = hz.c * self.taps[0] if self.gridview: self.update_fft(self.taps, self.params) self.set_mfmagresponse() self.set_mttaps() else: - self.draw_plots(self.taps,self.params) + self.draw_plots(self.taps, self.params) self.update_fcoeff() # update the pzplot in other view. zeros = self.get_zeros() @@ -1918,22 +2010,23 @@ class gr_plot_filter(QtWidgets.QMainWindow): if x == None: self.gui.pzstatusBar.showMessage("") else: - self.gui.pzstatusBar.showMessage("X: "+str(x)+" Y: "+str(y)) + self.gui.pzstatusBar.showMessage("X: " + str(x) + " Y: " + str(y)) def set_mstatusbar(self, point): x, y = point if x == None: self.gui.mpzstatusBar.showMessage("") else: - self.gui.mpzstatusBar.showMessage("X: "+str(x)+" Y: "+str(y)) + self.gui.mpzstatusBar.showMessage( + "X: " + str(x) + " Y: " + str(y)) def get_zeros(self): - hz = poly1d(self.taps,r=0) + hz = poly1d(self.taps, r=0) return hz.r def get_poles(self): if len(self.taps): - hp = zeros(len(self.taps)-1,complex) + hp = zeros(len(self.taps) - 1, complex) return hp else: return [] @@ -1960,40 +2053,44 @@ class gr_plot_filter(QtWidgets.QMainWindow): return step def update_fcoeff(self): - fcoeff="" + fcoeff = "" if self.iir: - fcoeff="b = " + ','.join(str(e) for e in self.b) +"\na = " + ','.join(str(e) for e in self.a) + fcoeff = "b = " + \ + ','.join(str(e) for e in self.b) + "\na = " + \ + ','.join(str(e) for e in self.a) else: - fcoeff="taps = " + ','.join(str(e) for e in self.taps) + fcoeff = "taps = " + ','.join(str(e) for e in self.taps) self.gui.filterCoeff.setText(fcoeff) self.gui.mfilterCoeff.setText(fcoeff) def action_save_dialog(self): - file_dialog_output = QtWidgets.QFileDialog.getSaveFileName(self, "Save CSV Filter File", ".", "") + file_dialog_output = QtWidgets.QFileDialog.getSaveFileName( + self, "Save CSV Filter File", ".", "") filename = file_dialog_output[0] try: handle = open(filename, "w") except IOError: reply = QtWidgets.QMessageBox.information(self, 'File Name', - ("Could not save to file: %s" % filename), - QtWidgets.QMessageBox.Ok) + ("Could not save to file: %s" % + filename), + QtWidgets.QMessageBox.Ok) return csvhandle = csv.writer(handle, delimiter=",") # Indicate FIR/IIR for easy reading. if self.iir: - csvhandle.writerow(["restype","iir"]) + csvhandle.writerow(["restype", "iir"]) else: - csvhandle.writerow(["restype","fir"]) + csvhandle.writerow(["restype", "fir"]) for k in list(self.params.keys()): csvhandle.writerow([k, self.params[k]]) if self.iir: - csvhandle.writerow(["b",] + list(self.b)) - csvhandle.writerow(["a",] + list(self.a)) + csvhandle.writerow(["b", ] + list(self.b)) + csvhandle.writerow(["a", ] + list(self.a)) else: - csvhandle.writerow(["taps",] + list(self.taps)) + csvhandle.writerow(["taps", ] + list(self.taps)) handle.close() self.gui.action_save.setEnabled(False) # Iterate through all plots and delete the curves @@ -2007,7 +2104,8 @@ class gr_plot_filter(QtWidgets.QMainWindow): self.replot_all() def action_open_dialog(self): - file_dialog_output = QtWidgets.QFileDialog.getOpenFileName(self, "Open CSV Filter File", ".", "") + file_dialog_output = QtWidgets.QFileDialog.getOpenFileName( + self, "Open CSV Filter File", ".", "") if(len(file_dialog_output) == 0): return # file_dialog_output returns tuple of (filename, file filter) @@ -2016,12 +2114,13 @@ class gr_plot_filter(QtWidgets.QMainWindow): handle = open(filename, "r") except IOError: reply = QtWidgets.QMessageBox.information(self, 'File Name', - ("Could not open file: %s" % filename), - QtWidgets.QMessageBox.Ok) + ("Could not open file: %s" % + filename), + QtWidgets.QMessageBox.Ok) return csvhandle = csv.reader(handle, delimiter=",") - b_a={} + b_a = {} taps = [] params = {} for row in csvhandle: @@ -2029,22 +2128,22 @@ class gr_plot_filter(QtWidgets.QMainWindow): restype = row[1] elif(row[0] == "taps"): testcpx = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1]) - if(len(testcpx) > 0): # it's a complex + if(len(testcpx) > 0): # it's a complex taps = [complex(r) for r in row[1:]] else: taps = [float(r) for r in row[1:]] elif(row[0] == "b" or row[0] == "a"): testcpx = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1]) - if(len(testcpx) > 0): # it's a complex + if(len(testcpx) > 0): # it's a complex b_a[row[0]] = [complex(r) for r in row[1:]] else: - b_a[row[0]]= [float(r) for r in row[1:]] + b_a[row[0]] = [float(r) for r in row[1:]] else: testcpx = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1]) - if(len(testcpx) > 0): # it's a complex + if(len(testcpx) > 0): # it's a complex params[row[0]] = complex(row[1]) - else: # assume it's a float. - try: # if it's not a float, its a string. + else: # assume it's a float. + try: # if it's not a float, its a string. params[row[0]] = float(row[1]) except ValueError: params[row[0]] = row[1] @@ -2068,133 +2167,152 @@ class gr_plot_filter(QtWidgets.QMainWindow): # Set up GUI parameters for each filter type. if(params["filttype"] == "lpf"): self.gui.filterTypeComboBox.setCurrentIndex(0) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.endofLpfPassBandEdit.setText(str(params["pbend"])) self.gui.startofLpfStopBandEdit.setText(str(params["sbstart"])) self.gui.lpfStopBandAttenEdit.setText(str(params["atten"])) if(params["wintype"] == self.EQUIRIPPLE_FILT): - self.gui.lpfPassBandRippleEdit.setText(str(params["ripple"])) + self.gui.lpfPassBandRippleEdit.setText( + str(params["ripple"])) elif(params["filttype"] == "bpf"): self.gui.filterTypeComboBox.setCurrentIndex(1) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.startofBpfPassBandEdit.setText(str(params["pbstart"])) self.gui.endofBpfPassBandEdit.setText(str(params["pbend"])) self.gui.bpfTransitionEdit.setText(str(params["tb"])) self.gui.bpfStopBandAttenEdit.setText(str(params["atten"])) if(params["wintype"] == self.EQUIRIPPLE_FILT): - self.gui.bpfPassBandRippleEdit.setText(str(params["ripple"])) + self.gui.bpfPassBandRippleEdit.setText( + str(params["ripple"])) elif(params["filttype"] == "cbpf"): self.gui.filterTypeComboBox.setCurrentIndex(2) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.startofBpfPassBandEdit.setText(str(params["pbstart"])) self.gui.endofBpfPassBandEdit.setText(str(params["pbend"])) self.gui.bpfTransitionEdit.setText(str(params["tb"])) self.gui.bpfStopBandAttenEdit.setText(str(params["atten"])) if(params["wintype"] == self.EQUIRIPPLE_FILT): - self.gui.bpfPassBandRippleEdit.setText(str(params["ripple"])) + self.gui.bpfPassBandRippleEdit.setText( + str(params["ripple"])) elif(params["filttype"] == "bnf"): self.gui.filterTypeComboBox.setCurrentIndex(3) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.startofBnfStopBandEdit.setText(str(params["sbstart"])) self.gui.endofBnfStopBandEdit.setText(str(params["sbend"])) self.gui.bnfTransitionEdit.setText(str(params["tb"])) self.gui.bnfStopBandAttenEdit.setText(str(params["atten"])) if(params["wintype"] == self.EQUIRIPPLE_FILT): - self.gui.bnfPassBandRippleEdit.setText(str(params["ripple"])) + self.gui.bnfPassBandRippleEdit.setText( + str(params["ripple"])) elif(params["filttype"] == "hpf"): self.gui.filterTypeComboBox.setCurrentIndex(4) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.endofHpfStopBandEdit.setText(str(params["sbend"])) self.gui.startofHpfPassBandEdit.setText(str(params["pbstart"])) self.gui.hpfStopBandAttenEdit.setText(str(params["atten"])) if(params["wintype"] == self.EQUIRIPPLE_FILT): - self.gui.hpfPassBandRippleEdit.setText(str(params["ripple"])) + self.gui.hpfPassBandRippleEdit.setText( + str(params["ripple"])) elif(params["filttype"] == "rrc"): self.gui.filterTypeComboBox.setCurrentIndex(5) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.rrcSymbolRateEdit.setText(str(params["srate"])) self.gui.rrcAlphaEdit.setText(str(params["alpha"])) self.gui.rrcNumTapsEdit.setText(str(params["ntaps"])) elif(params["filttype"] == "gaus"): self.gui.filterTypeComboBox.setCurrentIndex(6) - self.gui.filterDesignTypeComboBox.setCurrentIndex(int(params["wintype"])) + self.gui.filterDesignTypeComboBox.setCurrentIndex( + int(params["wintype"])) self.gui.gausSymbolRateEdit.setText(str(params["srate"])) self.gui.gausBTEdit.setText(str(params["bt"])) self.gui.gausNumTapsEdit.setText(str(params["ntaps"])) else: self.iir = True - self.b, self.a = b_a["b"],b_a["a"] - (self.z,self.p,self.k) = signal.tf2zpk(self.b, self.a) + self.b, self.a = b_a["b"], b_a["a"] + (self.z, self.p, self.k) = signal.tf2zpk(self.b, self.a) self.gui.pzPlot.insertZeros(self.z) self.gui.pzPlot.insertPoles(self.p) self.gui.mpzPlot.insertZeros(self.z) self.gui.mpzPlot.insertPoles(self.p) - self.iir_plot_all(self.z,self.p,self.k) + self.iir_plot_all(self.z, self.p, self.k) self.update_fcoeff() self.gui.nTapsEdit.setText("-") self.params = params # Set GUI for IIR type. - iirft = { "ellip" : 0, - "butter" : 1, - "cheby1" : 2, - "cheby2" : 3, - "bessel" : 4 } - - paramtype = { "analog" : 1, - "digital" : 0 } + iirft = {"ellip": 0, + "butter": 1, + "cheby1": 2, + "cheby2": 3, + "bessel": 4} + + paramtype = {"analog": 1, + "digital": 0} bandpos = { - "lpf" : 0, - "bpf" : 1, - "bnf" : 2, - "hpf" : 3} - - iirboxes = {"lpf" : [self.gui.iirendofLpfPassBandEdit, - self.gui.iirstartofLpfStopBandEdit, - self.gui.iirLpfPassBandAttenEdit, - self.gui.iirLpfStopBandRippleEdit], - - "hpf" : [self.gui.iirstartofHpfPassBandEdit, - self.gui.iirendofHpfStopBandEdit, - self.gui.iirHpfPassBandAttenEdit, - self.gui.iirHpfStopBandRippleEdit], - - "bpf" : [self.gui.iirstartofBpfPassBandEdit, - self.gui.iirendofBpfPassBandEdit, - self.gui.iirendofBpfStopBandEdit1, - self.gui.iirstartofBpfStopBandEdit2, - self.gui.iirBpfPassBandAttenEdit, - self.gui.iirBpfStopBandRippleEdit], - - "bnf" : [self.gui.iirendofBsfPassBandEdit1, - self.gui.iirstartofBsfPassBandEdit2, - self.gui.iirstartofBsfStopBandEdit, - self.gui.iirendofBsfStopBandEdit, - self.gui.iirBsfPassBandAttenEdit, - self.gui.iirBsfStopBandRippleEdit] } + "lpf": 0, + "bpf": 1, + "bnf": 2, + "hpf": 3} + + iirboxes = {"lpf": [self.gui.iirendofLpfPassBandEdit, + self.gui.iirstartofLpfStopBandEdit, + self.gui.iirLpfPassBandAttenEdit, + self.gui.iirLpfStopBandRippleEdit], + + "hpf": [self.gui.iirstartofHpfPassBandEdit, + self.gui.iirendofHpfStopBandEdit, + self.gui.iirHpfPassBandAttenEdit, + self.gui.iirHpfStopBandRippleEdit], + + "bpf": [self.gui.iirstartofBpfPassBandEdit, + self.gui.iirendofBpfPassBandEdit, + self.gui.iirendofBpfStopBandEdit1, + self.gui.iirstartofBpfStopBandEdit2, + self.gui.iirBpfPassBandAttenEdit, + self.gui.iirBpfStopBandRippleEdit], + + "bnf": [self.gui.iirendofBsfPassBandEdit1, + self.gui.iirstartofBsfPassBandEdit2, + self.gui.iirstartofBsfStopBandEdit, + self.gui.iirendofBsfStopBandEdit, + self.gui.iirBsfPassBandAttenEdit, + self.gui.iirBsfStopBandRippleEdit]} self.gui.fselectComboBox.setCurrentIndex(1) - self.gui.iirfilterTypeComboBox.setCurrentIndex(iirft[params["filttype"]]) - self.gui.iirfilterBandComboBox.setCurrentIndex(bandpos[params["bandtype"]]) + self.gui.iirfilterTypeComboBox.setCurrentIndex( + iirft[params["filttype"]]) + self.gui.iirfilterBandComboBox.setCurrentIndex( + bandpos[params["bandtype"]]) if params["filttype"] == "bessel": - critfreq = [float(x) for x in params["critfreq"][1:-1].split(',')] + critfreq = [float(x) + for x in params["critfreq"][1:-1].split(',')] self.gui.besselordEdit.setText(str(params["filtord"])) self.gui.iirbesselcritEdit1.setText(str(critfreq[0])) self.gui.iirbesselcritEdit2.setText(str(critfreq[1])) else: - self.gui.adComboBox.setCurrentIndex(paramtype[params["paramtype"]]) + self.gui.adComboBox.setCurrentIndex( + paramtype[params["paramtype"]]) if len(iirboxes[params["bandtype"]]) == 4: - sdata = [params["pbedge"], params["sbedge"], params["gpass"], params["gstop"]] + sdata = [params["pbedge"], params["sbedge"], + params["gpass"], params["gstop"]] else: - pbedge = list(map(float, params["pbedge"][1:-1].split(','))) - sbedge = list(map(float, params["sbedge"][1:-1].split(','))) + pbedge = list( + map(float, params["pbedge"][1:-1].split(','))) + sbedge = list( + map(float, params["sbedge"][1:-1].split(','))) sdata = [pbedge[0], pbedge[1], sbedge[0], sbedge[1], params["gpass"], params["gstop"]] @@ -2236,16 +2354,17 @@ class CustomViewBox(pg.ViewBox): def setup_options(): - usage="%prog: [options] (input_filename)" + usage = "%prog: [options] (input_filename)" description = "" parser = OptionParser(conflict_handler="resolve", usage=usage, description=description) return parser + def launch(args, callback=None, restype=""): parser = setup_options() - (options, args) = parser.parse_args () + (options, args) = parser.parse_args() if callback is None: app = Qt.QApplication(args) @@ -2263,9 +2382,10 @@ def launch(args, callback=None, restype=""): gplt = gr_plot_filter(options, callback, restype) return gplt + def main(args): parser = setup_options() - (options, args) = parser.parse_args () + (options, args) = parser.parse_args() app = Qt.QApplication(args) gplt = gr_plot_filter(options) @@ -2273,5 +2393,6 @@ def main(args): app.deleteLater() sys.exit() + if __name__ == '__main__': main(sys.argv) diff --git a/gr-filter/python/filter/design/fir_design.py b/gr-filter/python/filter/design/fir_design.py index 64236e5a31..11beb9cdbf 100644 --- a/gr-filter/python/filter/design/fir_design.py +++ b/gr-filter/python/filter/design/fir_design.py @@ -27,7 +27,7 @@ def design_win_lpf(fs, gain, wintype, mainwin): try: taps = filter.firdes.low_pass_2(gain, fs, pb, tb, atten, wintype) - except (RuntimeError, IndexError) as e: + except (RuntimeError, IndexError) as e: reply = QtGui.QMessageBox.information(mainwin, "Runtime Error", e.args[0], QtGui.QMessageBox.Ok) return ([], [], ret) @@ -169,7 +169,8 @@ def design_win_hb(fs, gain, wintype, mainwin): return ([], [], False) if(ret): - taps = scipy.signal.firwin(int(filtord)+1, 0.5, window=filtwin[wintype]) + taps = scipy.signal.firwin( + int(filtord) + 1, 0.5, window=filtwin[wintype]) taps[abs(taps) <= 1e-6] = 0. params = {"fs": fs, "gain": gain, "wintype": wintype, "filttype": "hb", "ntaps": len(taps)} @@ -371,8 +372,8 @@ def design_opt_hb(fs, gain, mainwin): if(ret): try: - bands = [0, .25 - (trwidth/fs), .25 + (trwidth/fs), 0.5] - taps = scipy.signal.remez(int(filtord)+1, bands, [1, 0], [1, 1]) + bands = [0, .25 - (trwidth / fs), .25 + (trwidth / fs), 0.5] + taps = scipy.signal.remez(int(filtord) + 1, bands, [1, 0], [1, 1]) taps[abs(taps) <= 1e-6] = 0. except RuntimeError as e: reply = QtGui.QMessageBox.information(mainwin, "Filter Design Error", diff --git a/gr-filter/python/filter/file_taps_loader.py b/gr-filter/python/filter/file_taps_loader.py index 8bdff1efd4..87e4e1ab54 100644 --- a/gr-filter/python/filter/file_taps_loader.py +++ b/gr-filter/python/filter/file_taps_loader.py @@ -16,10 +16,12 @@ import os import numpy as np from gnuradio import gr + class file_taps_loader(gr.basic_block): """ Block to make filter taps created by the filter design tool available in grc. """ + def __init__(self, fpath, verbose): gr.basic_block.__init__( self, @@ -38,35 +40,40 @@ class file_taps_loader(gr.basic_block): Load a file that was generated with the filter design tool """ if not os.path.isfile(self.fpath): - raise RuntimeError(self.name() + ": Can not open " + "\"" + fpath + "\"" + ".") + raise RuntimeError( + self.name() + ": Can not open " + "\"" + fpath + "\"" + ".") with open(fpath) as csvfile: readcsv = csv.reader(csvfile, delimiter=',') for row in readcsv: if row[0] == "taps": regex = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[1]) - if regex: # it's a complex + if regex: # it's a complex # string to complex so numpy eats the taps cpx_row = [complex(x) for x in row[1:]] self.taps = tuple(np.array(cpx_row, dtype=complex)) - self.print_if(self.name() + ": Found complex taps in the file provided.\n") + self.print_if( + self.name() + ": Found complex taps in the file provided.\n") else: self.taps = tuple(np.array(row[1:], dtype=float)) - self.print_if(self.name() + ": Found real taps in the file provided.\n") + self.print_if( + self.name() + ": Found real taps in the file provided.\n") else: regex = re.findall(r"[+-]?\d+\.*\d*[Ee]?[-+]?\d+j", row[0]) - if regex: # it's a complex + if regex: # it's a complex # string to complex so numpy eats the taps cpx_row = [complex(x) for x in row[0:]] self.taps = tuple(np.array(cpx_row, dtype=complex)) - self.print_if(self.name() + ": Found complex taps in the file provided.\n") + self.print_if( + self.name() + ": Found complex taps in the file provided.\n") else: try: self.taps = tuple(np.array(row[0:], dtype=float)) - self.print_if(self.name() + ": Found real taps in the file provided.\n") + self.print_if( + self.name() + ": Found real taps in the file provided.\n") except ValueError: self.params.append(row) self.print_if( - self.name() + \ + self.name() + ": Loaded a filter with the following parameters (gr_filter_design format): \n") for param in self.params: self.print_if(param[0], ' ', param[1], '\n') diff --git a/gr-filter/python/filter/filterbank.py b/gr-filter/python/filter/filterbank.py index 39e39e5d24..afce5cb67f 100644 --- a/gr-filter/python/filter/filterbank.py +++ b/gr-filter/python/filter/filterbank.py @@ -13,6 +13,7 @@ from gnuradio import fft from gnuradio import blocks from .filter_python import fft_filter_ccc + def _generate_synthesis_taps(mpoints): return [] # FIXME @@ -31,6 +32,7 @@ class synthesis_filterbank(gr.hier_block2): See http://cnx.org/content/m10424/latest """ + def __init__(self, mpoints, taps=None): """ Takes M complex streams in, produces single complex stream out @@ -75,10 +77,10 @@ class synthesis_filterbank(gr.hier_block2): """ item_size = gr.sizeof_gr_complex gr.hier_block2.__init__(self, "synthesis_filterbank", - gr.io_signature(mpoints, mpoints, item_size), # Input signature + # Input signature + gr.io_signature(mpoints, mpoints, item_size), gr.io_signature(1, 1, item_size)) # Output signature - if taps is None: taps = _generate_synthesis_taps(mpoints) @@ -109,12 +111,14 @@ class synthesis_filterbank(gr.hier_block2): self.connect(self.ss2s, self) + class analysis_filterbank(gr.hier_block2): """ Uniformly modulated polyphase DFT filter bank: analysis See http://cnx.org/content/m10424/latest """ + def __init__(self, mpoints, taps=None): """ Takes 1 complex stream in, produces M complex streams out @@ -128,8 +132,9 @@ class analysis_filterbank(gr.hier_block2): """ item_size = gr.sizeof_gr_complex gr.hier_block2.__init__(self, "analysis_filterbank", - gr.io_signature(1, 1, item_size), # Input signature - gr.io_signature(mpoints, mpoints, item_size)) # Output signature + # Input signature + gr.io_signature(1, 1, item_size), + gr.io_signature(mpoints, mpoints, item_size)) # Output signature if taps is None: taps = _generate_synthesis_taps(mpoints) @@ -154,7 +159,7 @@ class analysis_filterbank(gr.hier_block2): # build mpoints fir filters... for i in range(mpoints): - f = fft_filter_ccc(1, sub_taps[mpoints-i-1]) + f = fft_filter_ccc(1, sub_taps[mpoints - i - 1]) self.connect((self.s2ss, i), f) self.connect(f, (self.ss2v, i)) self.connect((self.v2ss, i), (self, i)) diff --git a/gr-filter/python/filter/freq_xlating_fft_filter.py b/gr-filter/python/filter/freq_xlating_fft_filter.py index af5541f2a7..55c0d1797a 100644 --- a/gr-filter/python/filter/freq_xlating_fft_filter.py +++ b/gr-filter/python/filter/freq_xlating_fft_filter.py @@ -15,7 +15,7 @@ from gnuradio.blocks import rotator_cc from .filter_python import fft_filter_ccc -__all__ = [ 'freq_xlating_fft_filter_ccc' ] +__all__ = ['freq_xlating_fft_filter_ccc'] class freq_xlating_fft_filter_ccc(gr.hier_block2): @@ -29,10 +29,10 @@ class freq_xlating_fft_filter_ccc(gr.hier_block2): ) # Save args - self.decim = decim - self.taps = taps + self.decim = decim + self.taps = taps self.center_freq = center_freq - self.samp_rate = samp_rate + self.samp_rate = samp_rate # Sub blocks self._filter = fft_filter_ccc(decim, taps) @@ -44,7 +44,7 @@ class freq_xlating_fft_filter_ccc(gr.hier_block2): self._refresh() def _rotate_taps(self, taps, phase_inc): - return [ x * cmath.exp(i * phase_inc * 1j) for i,x in enumerate(taps) ] + return [x * cmath.exp(i * phase_inc * 1j) for i, x in enumerate(taps)] def _refresh(self): phase_inc = (2.0 * math.pi * self.center_freq) / self.samp_rate diff --git a/gr-filter/python/filter/gui/CustomViewBox.py b/gr-filter/python/filter/gui/CustomViewBox.py index 40e3b2f937..4920f72382 100644 --- a/gr-filter/python/filter/gui/CustomViewBox.py +++ b/gr-filter/python/filter/gui/CustomViewBox.py @@ -1,6 +1,7 @@ import pyqtgraph as pg from PyQt5 import QtCore + class CustomViewBox(pg.ViewBox): def __init__(self, *args, **kwds): pg.ViewBox.__init__(self, *args, **kwds) diff --git a/gr-filter/python/filter/gui/GrFilterPlotWidget.py b/gr-filter/python/filter/gui/GrFilterPlotWidget.py index 93793c3562..48db5ae76b 100644 --- a/gr-filter/python/filter/gui/GrFilterPlotWidget.py +++ b/gr-filter/python/filter/gui/GrFilterPlotWidget.py @@ -3,10 +3,11 @@ from .CustomViewBox import CustomViewBox class GrFilterPlotWidget(PlotWidget): - def __init__(self,parent=None, background='default', **kargs): - PlotWidget.__init__(self,parent,background,enableMenu=False,viewBox=CustomViewBox()) + def __init__(self, parent=None, background='default', **kargs): + PlotWidget.__init__(self, parent, background, + enableMenu=False, viewBox=CustomViewBox()) def drop_plotdata(self): for plitem in self.items(): - if isinstance(plitem, (graphicsItems.PlotCurveItem.PlotCurveItem, graphicsItems.ScatterPlotItem.ScatterPlotItem,graphicsItems.PlotDataItem.PlotDataItem)): + if isinstance(plitem, (graphicsItems.PlotCurveItem.PlotCurveItem, graphicsItems.ScatterPlotItem.ScatterPlotItem, graphicsItems.PlotDataItem.PlotDataItem)): plitem.clear() diff --git a/gr-filter/python/filter/gui/bandgraphicsview.py b/gr-filter/python/filter/gui/bandgraphicsview.py index 8c8f523116..ccc78dce45 100644 --- a/gr-filter/python/filter/gui/bandgraphicsview.py +++ b/gr-filter/python/filter/gui/bandgraphicsview.py @@ -8,9 +8,11 @@ from PyQt5 import QtWidgets, QtCore, Qt + class BandGraphicsView(QtWidgets.QGraphicsView): def resizeEvent(self, event): self.setAlignment(Qt.Qt.AlignCenter) - self.fitInView(self.scene().itemsBoundingRect(), QtCore.Qt.KeepAspectRatio) - self.scale(1.3,1.3) - self.setViewportMargins(10,10,10,10) + self.fitInView(self.scene().itemsBoundingRect(), + QtCore.Qt.KeepAspectRatio) + self.scale(1.3, 1.3) + self.setViewportMargins(10, 10, 10, 10) diff --git a/gr-filter/python/filter/gui/banditems.py b/gr-filter/python/filter/gui/banditems.py index 1b1289a77b..0d1b4c4c8b 100644 --- a/gr-filter/python/filter/gui/banditems.py +++ b/gr-filter/python/filter/gui/banditems.py @@ -10,7 +10,8 @@ try: from PyQt5 import Qt, QtCore, QtGui, QtWidgets except ImportError: - raise SystemExit('Please install PyQt5 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)') + raise SystemExit( + 'Please install PyQt5 to run this script (http://www.riverbankcomputing.co.uk/software/pyqt/download)') # Movable solid line for filter ideal-band diagram. @@ -31,12 +32,12 @@ class filtermovlineItem(QtWidgets.QGraphicsObject): def paint(self, painter, option, widget): painter.setPen(QtGui.QPen(QtCore.Qt.black, 2, QtCore.Qt.SolidLine)) painter.drawLine(self.x1, self.y1, self.x2, self.y2) - painter.drawLine(self.x1, self.y1, self.x1, self.y1-5) - painter.drawLine(self.x2, self.y2, self.x2, self.y2-5) + painter.drawLine(self.x1, self.y1, self.x1, self.y1 - 5) + painter.drawLine(self.x2, self.y2, self.x2, self.y2 - 5) if self.split: painter.drawLine(self.sx1, self.sy1, self.sx2, self.sy2) - painter.drawLine(self.sx1, self.sy1, self.sx1, self.sy1-5) - painter.drawLine(self.sx2, self.sy2, self.sx2, self.sy2-5) + painter.drawLine(self.sx1, self.sy1, self.sx1, self.sy1 - 5) + painter.drawLine(self.sx2, self.sy2, self.sx2, self.sy2 - 5) def boundingRect(self): return QtCore.QRectF(0, 0, 400, 400) @@ -189,7 +190,8 @@ hpfItems[0].setFlags(QtWidgets.QGraphicsItem.ItemIsSelectable | QtWidgets.QGraph hpfItems.append(hpfsLines()) # bpfitems list. -bpfItems.append(filtermovlineItem(6, 175, 110, 175, 0, -60, True, 300, 175, 400, 175)) +bpfItems.append(filtermovlineItem(6, 175, 110, 175, + 0, -60, True, 300, 175, 400, 175)) bpfItems[0].setFlags(QtWidgets.QGraphicsItem.ItemIsSelectable | QtWidgets.QGraphicsItem.ItemIsMovable | QtWidgets.QGraphicsItem.ItemSendsGeometryChanges) bpfItems.append(bpfsLines()) diff --git a/gr-filter/python/filter/gui/icons_rc.py b/gr-filter/python/filter/gui/icons_rc.py index eaa388ebe3..272aed1b63 100644 --- a/gr-filter/python/filter/gui/icons_rc.py +++ b/gr-filter/python/filter/gui/icons_rc.py @@ -2412,10 +2412,15 @@ else: rcc_version = 2 qt_resource_struct = qt_resource_struct_v2 + def qInitResources(): - QtCore.qRegisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + QtCore.qRegisterResourceData( + rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + def qCleanupResources(): - QtCore.qUnregisterResourceData(rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + QtCore.qUnregisterResourceData( + rcc_version, qt_resource_struct, qt_resource_name, qt_resource_data) + qInitResources() diff --git a/gr-filter/python/filter/gui/idealbanditems.py b/gr-filter/python/filter/gui/idealbanditems.py index 65a4d10044..ac0af5d301 100644 --- a/gr-filter/python/filter/gui/idealbanditems.py +++ b/gr-filter/python/filter/gui/idealbanditems.py @@ -15,9 +15,12 @@ import numpy class IdealBandItems(object): def __init__(self): # Set Global pyqtgraph options - pg.setConfigOption('foreground', 'k') # Default foreground color for text, lines, axes, etc. - pg.setConfigOption('background', None) # Default background for GraphicsView. - pg.setConfigOptions(antialias=True) # Draw lines with smooth edges at the cost of reduced performance. + # Default foreground color for text, lines, axes, etc. + pg.setConfigOption('foreground', 'k') + # Default background for GraphicsView. + pg.setConfigOption('background', None) + # Draw lines with smooth edges at the cost of reduced performance. + pg.setConfigOptions(antialias=True) self.win = pg.GraphicsWindow() self.plot = self.win.addPlot() @@ -36,139 +39,142 @@ class IdealBandItems(object): try: if (ftype == "Low Pass"): self.detach_unwantedcurves(plot) - x=[0, self.params["pbend"]] - y=[20.0*numpy.log10(self.params["gain"])]*2 + x = [0, self.params["pbend"]] + y = [20.0 * numpy.log10(self.params["gain"])] * 2 self.idealbandhcurves[0].setData(x, y) - x=[self.params["pbend"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["pbend"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[0].setData(x, y) - x = [self.params["sbstart"], self.params["fs"]/2.0] - y = [-self.params["atten"]]*2 + x = [self.params["sbstart"], self.params["fs"] / 2.0] + y = [-self.params["atten"]] * 2 self.idealbandhcurves[1].setData(x, y) - x = [self.params["sbstart"]]*2 + x = [self.params["sbstart"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[1].setData(x, y) elif ftype == "High Pass": self.detach_unwantedcurves(plot) - x=[self.params["pbstart"],self.params["fs"] / 2.0] - y=[20.0*numpy.log10(self.params["gain"])]*2 + x = [self.params["pbstart"], self.params["fs"] / 2.0] + y = [20.0 * numpy.log10(self.params["gain"])] * 2 self.idealbandhcurves[0].setData(x, y) - x=[self.params["pbstart"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["pbstart"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[0].setData(x, y) x = [0, self.params["sbend"]] - y = [-self.params["atten"]]*2 + y = [-self.params["atten"]] * 2 self.idealbandhcurves[1].setData(x, y) - x = [self.params["sbend"]]*2 + x = [self.params["sbend"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[1].setData(x, y) elif ftype == "Band Notch": x = [self.params["sbstart"], self.params["sbend"]] - y = [-self.params["atten"]]*2 + y = [-self.params["atten"]] * 2 self.idealbandhcurves[0].setData(x, y) - x = [self.params["sbstart"]]*2 + x = [self.params["sbstart"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[0].setData(x, y) - x = [self.params["sbend"]]*2 + x = [self.params["sbend"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[1].setData(x, y) - x=[0,self.params["sbstart"]-self.params["tb"]] - y=[20.0*numpy.log10(self.params["gain"])]*2 + x = [0, self.params["sbstart"] - self.params["tb"]] + y = [20.0 * numpy.log10(self.params["gain"])] * 2 self.idealbandhcurves[1].setData(x, y) - x=[self.params["sbstart"]-self.params["tb"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["sbstart"] - self.params["tb"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[2].setData(x, y) - x=[self.params["sbend"]+self.params["tb"],self.params["fs"] / 2.0] - y=[20.0*numpy.log10(self.params["gain"])]*2 + x = [self.params["sbend"] + self.params["tb"], + self.params["fs"] / 2.0] + y = [20.0 * numpy.log10(self.params["gain"])] * 2 self.idealbandhcurves[2].setData(x, y) - x=[self.params["sbend"]+self.params["tb"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["sbend"] + self.params["tb"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[3].setData(x, y) elif ftype == "Band Pass": - x=[self.params["pbstart"],self.params["pbend"]] - y=[20.0*numpy.log10(self.params["gain"])]*2 + x = [self.params["pbstart"], self.params["pbend"]] + y = [20.0 * numpy.log10(self.params["gain"])] * 2 self.idealbandhcurves[0].setData(x, y) - x=[self.params["pbstart"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["pbstart"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[0].setData(x, y) - x=[self.params["pbend"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["pbend"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[1].setData(x, y) - x = [0, self.params["pbstart"]-self.params["tb"]] - y = [-self.params["atten"]]*2 + x = [0, self.params["pbstart"] - self.params["tb"]] + y = [-self.params["atten"]] * 2 self.idealbandhcurves[1].setData(x, y) - x = [self.params["pbstart"]-self.params["tb"]]*2 + x = [self.params["pbstart"] - self.params["tb"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[2].setData(x, y) - x = [self.params["pbend"]+self.params["tb"], self.params["fs"]/2.0] - y = [-self.params["atten"]]*2 + x = [self.params["pbend"] + self.params["tb"], + self.params["fs"] / 2.0] + y = [-self.params["atten"]] * 2 self.idealbandhcurves[2].setData(x, y) - x = [self.params["pbend"]+self.params["tb"]]*2 + x = [self.params["pbend"] + self.params["tb"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[3].setData(x, y) elif ftype == "Complex Band Pass": - x=[self.params["pbstart"],self.params["pbend"]] - y=[20.0*numpy.log10(self.params["gain"])]*2 + x = [self.params["pbstart"], self.params["pbend"]] + y = [20.0 * numpy.log10(self.params["gain"])] * 2 self.idealbandhcurves[0].setData(x, y) - x=[self.params["pbstart"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["pbstart"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[0].setData(x, y) - x=[self.params["pbend"]]*2 - y=[20.0*numpy.log10(self.params["gain"]), - plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] + x = [self.params["pbend"]] * 2 + y = [20.0 * numpy.log10(self.params["gain"]), + plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[1].setData(x, y) - x = [0, self.params["pbstart"]-self.params["tb"]] - y = [-self.params["atten"]]*2 + x = [0, self.params["pbstart"] - self.params["tb"]] + y = [-self.params["atten"]] * 2 self.idealbandhcurves[1].setData(x, y) - x = [self.params["pbstart"]-self.params["tb"]]*2 + x = [self.params["pbstart"] - self.params["tb"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[2].setData(x, y) - x = [self.params["pbend"]+self.params["tb"], self.params["fs"]/2.0] - y = [-self.params["atten"]]*2 + x = [self.params["pbend"] + self.params["tb"], + self.params["fs"] / 2.0] + y = [-self.params["atten"]] * 2 self.idealbandhcurves[2].setData(x, y) - x = [self.params["pbend"]+self.params["tb"]]*2 + x = [self.params["pbend"] + self.params["tb"]] * 2 y = [-self.params["atten"], plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()] self.idealbandvcurves[3].setData(x, y) diff --git a/gr-filter/python/filter/gui/polezero_plot.py b/gr-filter/python/filter/gui/polezero_plot.py index 3b3b99b606..859cd5c2d6 100644 --- a/gr-filter/python/filter/gui/polezero_plot.py +++ b/gr-filter/python/filter/gui/polezero_plot.py @@ -22,9 +22,12 @@ class PzPlot(pg.PlotWidget): pg.PlotWidget.__init__(self, *args) # Set Global pyqtgraph options - pg.setConfigOption('foreground', 'k') # Default foreground color for text, lines, axes, etc. - pg.setConfigOption('background', None) # Default background for GraphicsView. - pg.setConfigOptions(antialias=True) # Draw lines with smooth edges at the cost of reduced performance. + # Default foreground color for text, lines, axes, etc. + pg.setConfigOption('foreground', 'k') + # Default background for GraphicsView. + pg.setConfigOption('background', None) + # Draw lines with smooth edges at the cost of reduced performance. + pg.setConfigOptions(antialias=True) self.ymax = 0 self.xmax = 0 @@ -76,44 +79,45 @@ class PzPlot(pg.PlotWidget): if self.ymin >= -1: self.ymin = -1.5 - self.setRange(xRange=[self.xmin, self.xmax], yRange=[self.ymin, self.ymax]) + self.setRange(xRange=[self.xmin, self.xmax], + yRange=[self.ymin, self.ymax]) def insertPoles(self, roots): - if len(roots): - self.__insertPole(Qt.Qt.black, roots.real, roots.imag) - ymax = max(roots.imag) - ymax = max(ymax, self.ymax) - ymin = min(roots.imag) - ymin = min(ymin, self.ymin) - xmax = max(roots.real) - xmax = max(xmax, self.xmax) - xmin = min(roots.real) - xmin = min(xmin, self.xmin) - - # To make the plot look good. - if xmax <= 1.3: - xmax = 2 - else: - xmax = 1.2 * xmax + if len(roots): + self.__insertPole(Qt.Qt.black, roots.real, roots.imag) + ymax = max(roots.imag) + ymax = max(ymax, self.ymax) + ymin = min(roots.imag) + ymin = min(ymin, self.ymin) + xmax = max(roots.real) + xmax = max(xmax, self.xmax) + xmin = min(roots.real) + xmin = min(xmin, self.xmin) - if xmin >= -1.3: - xmin = -2 - else: - xmin = 1.2 * xmin + # To make the plot look good. + if xmax <= 1.3: + xmax = 2 + else: + xmax = 1.2 * xmax - if ymax <= 1: - ymax = 1.5 - else: - ymax = 1.2 * ymax + if xmin >= -1.3: + xmin = -2 + else: + xmin = 1.2 * xmin - if ymin >= -1: - ymin = -1.5 - else: - ymin = 1.2 * ymin + if ymax <= 1: + ymax = 1.5 + else: + ymax = 1.2 * ymax + + if ymin >= -1: + ymin = -1.5 + else: + ymin = 1.2 * ymin - self.setRange(xRange=[xmin, xmax], yRange=[ymin, ymax]) - self.drawUnitcircle() - self.replot() + self.setRange(xRange=[xmin, xmax], yRange=[ymin, ymax]) + self.drawUnitcircle() + self.replot() def __insertZero(self, color, px, py): curve = self.plot(name="Zero") @@ -135,8 +139,8 @@ class PzPlot(pg.PlotWidget): def removeallCurves(self): # TODO for curve in self.itemList(): - # if isinstance(curve, Qwt.QwtPlotCurve): - # curve.detach() + # if isinstance(curve, Qwt.QwtPlotCurve): + # curve.detach() self.replot() @@ -319,8 +323,8 @@ class CanvasPicker(Qt.QObject): yData = delete(yData, self.__selectedPoint) # One less to accommodate previous delete. if(self.__selectedcPoint != -1): - xData = delete(xData, self.__selectedcPoint-1) - yData = delete(yData, self.__selectedcPoint-1) + xData = delete(xData, self.__selectedcPoint - 1) + yData = delete(yData, self.__selectedcPoint - 1) curve.setData(xData, yData) self.__plot.replot() @@ -330,7 +334,8 @@ class CanvasPicker(Qt.QObject): if isinstance(c, Qwt.QwtPlotCurve): px.append([c.x(i) for i in range(c.dataSize())]) py.append([c.y(i) for i in range(c.dataSize())]) - tp = (vectorize(complex)(px[0], py[0]), vectorize(complex)(px[1], py[1])) + tp = (vectorize(complex)(px[0], py[0]), + vectorize(complex)(px[1], py[1])) self.curveChanged.emit(tp) def __moveBy(self, dx, dy): @@ -379,7 +384,8 @@ class CanvasPicker(Qt.QObject): if isinstance(c, Qwt.QwtPlotCurve): px.append([c.x(i) for i in range(c.dataSize())]) py.append([c.y(i) for i in range(c.dataSize())]) - tp = (vectorize(complex)(px[0], py[0]), vectorize(complex)(px[1], py[1])) + tp = (vectorize(complex)(px[0], py[0]), + vectorize(complex)(px[1], py[1])) self.curveChanged.emit(tp) self.__showCursor(True) @@ -409,23 +415,23 @@ class CanvasPicker(Qt.QObject): else: extrapoints = 1 - xData = zeros(editcurve.dataSize()+extrapoints, Float) - yData = zeros(editcurve.dataSize()+extrapoints, Float) + xData = zeros(editcurve.dataSize() + extrapoints, Float) + yData = zeros(editcurve.dataSize() + extrapoints, Float) for i in range(editcurve.dataSize()): xData[i] = editcurve.x(i) yData[i] = editcurve.y(i) - xData[i+1] = self.__plot.invTransform(editcurve.xAxis(), pos.x()) - yData[i+1] = self.__plot.invTransform(editcurve.yAxis(), pos.y()) + xData[i + 1] = self.__plot.invTransform(editcurve.xAxis(), pos.x()) + yData[i + 1] = self.__plot.invTransform(editcurve.yAxis(), pos.y()) if self.changeConjugate: - xData[i+2] = xData[i+1] - yData[i+2] = -yData[i+1] - self.__addedcZero = i+2 + xData[i + 2] = xData[i + 1] + yData[i + 2] = -yData[i + 1] + self.__addedcZero = i + 2 editcurve.setData(xData, yData) - self.__addedZero = i+1 + self.__addedZero = i + 1 symbol = Qwt.QwtSymbol(editcurve.symbol()) newSymbol = Qwt.QwtSymbol(symbol) newSymbol.setPen(Qt.QPen(Qt.Qt.red)) @@ -446,7 +452,8 @@ class CanvasPicker(Qt.QObject): if isinstance(c, Qwt.QwtPlotCurve): px.append([c.x(i) for i in range(c.dataSize())]) py.append([c.y(i) for i in range(c.dataSize())]) - tp = (vectorize(complex)(px[0], py[0]), vectorize(complex)(px[1], py[1])) + tp = (vectorize(complex)(px[0], py[0]), + vectorize(complex)(px[1], py[1])) self.curveChanged.emit(tp) self.__showCursor(True) diff --git a/gr-filter/python/filter/gui/pyqt_filter_stacked.py b/gr-filter/python/filter/gui/pyqt_filter_stacked.py index 9bd2ab8148..48095ee36d 100644 --- a/gr-filter/python/filter/gui/pyqt_filter_stacked.py +++ b/gr-filter/python/filter/gui/pyqt_filter_stacked.py @@ -6,8 +6,13 @@ # # WARNING! All changes made in this file will be lost! +from .GrFilterPlotWidget import GrFilterPlotWidget +from . import icons_rc +from .polezero_plot import PzPlot +from .bandgraphicsview import BandGraphicsView from PyQt5 import QtCore, QtGui, QtWidgets + class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") @@ -17,36 +22,44 @@ class Ui_MainWindow(object): self.gridLayout = QtWidgets.QGridLayout(self.centralwidget) self.gridLayout.setObjectName("gridLayout") self.stackedWindows = QtWidgets.QStackedWidget(self.centralwidget) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.stackedWindows.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.stackedWindows.sizePolicy().hasHeightForWidth()) self.stackedWindows.setSizePolicy(sizePolicy) self.stackedWindows.setObjectName("stackedWindows") self.classic = QtWidgets.QWidget() - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.classic.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.classic.sizePolicy().hasHeightForWidth()) self.classic.setSizePolicy(sizePolicy) self.classic.setObjectName("classic") self.horizontalLayout = QtWidgets.QHBoxLayout(self.classic) self.horizontalLayout.setObjectName("horizontalLayout") self.splitter = QtWidgets.QSplitter(self.classic) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.splitter.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.splitter.sizePolicy().hasHeightForWidth()) self.splitter.setSizePolicy(sizePolicy) self.splitter.setMinimumSize(QtCore.QSize(600, 0)) self.splitter.setOrientation(QtCore.Qt.Vertical) self.splitter.setObjectName("splitter") self.tabGroup = QtWidgets.QTabWidget(self.splitter) self.tabGroup.setEnabled(True) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.tabGroup.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.tabGroup.sizePolicy().hasHeightForWidth()) self.tabGroup.setSizePolicy(sizePolicy) self.tabGroup.setTabsClosable(False) self.tabGroup.setMovable(False) @@ -116,10 +129,12 @@ class Ui_MainWindow(object): self.horizontalLayout_17.addWidget(self.pdelayPlot) self.tabGroup.addTab(self.pdelayTab, "") self.filterspecView = QtWidgets.QTabWidget(self.splitter) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.filterspecView.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.filterspecView.sizePolicy().hasHeightForWidth()) self.filterspecView.setSizePolicy(sizePolicy) self.filterspecView.setMinimumSize(QtCore.QSize(613, 250)) self.filterspecView.setBaseSize(QtCore.QSize(0, 100)) @@ -127,19 +142,23 @@ class Ui_MainWindow(object): self.filterspecView.setTabsClosable(False) self.filterspecView.setObjectName("filterspecView") self.bandDiagram = QtWidgets.QWidget() - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.bandDiagram.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.bandDiagram.sizePolicy().hasHeightForWidth()) self.bandDiagram.setSizePolicy(sizePolicy) self.bandDiagram.setObjectName("bandDiagram") self.horizontalLayout_13 = QtWidgets.QHBoxLayout(self.bandDiagram) self.horizontalLayout_13.setObjectName("horizontalLayout_13") self.bandView = BandGraphicsView(self.bandDiagram) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.bandView.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.bandView.sizePolicy().hasHeightForWidth()) self.bandView.setSizePolicy(sizePolicy) self.bandView.setMinimumSize(QtCore.QSize(525, 249)) self.bandView.setObjectName("bandView") @@ -163,7 +182,8 @@ class Ui_MainWindow(object): self.verticalLayout_3.setObjectName("verticalLayout_3") self.addzeroPush = QtWidgets.QToolButton(self.pzgroupBox) icon = QtGui.QIcon() - icon.addPixmap(QtGui.QPixmap(":/icons/add_zero.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon.addPixmap(QtGui.QPixmap(":/icons/add_zero.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.addzeroPush.setIcon(icon) self.addzeroPush.setIconSize(QtCore.QSize(16, 16)) self.addzeroPush.setCheckable(True) @@ -171,21 +191,24 @@ class Ui_MainWindow(object): self.verticalLayout_3.addWidget(self.addzeroPush) self.addpolePush = QtWidgets.QToolButton(self.pzgroupBox) icon1 = QtGui.QIcon() - icon1.addPixmap(QtGui.QPixmap(":/icons/add_pole.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon1.addPixmap(QtGui.QPixmap(":/icons/add_pole.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.addpolePush.setIcon(icon1) self.addpolePush.setCheckable(True) self.addpolePush.setObjectName("addpolePush") self.verticalLayout_3.addWidget(self.addpolePush) self.delPush = QtWidgets.QToolButton(self.pzgroupBox) icon2 = QtGui.QIcon() - icon2.addPixmap(QtGui.QPixmap(":/icons/remove_red.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon2.addPixmap(QtGui.QPixmap(":/icons/remove_red.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.delPush.setIcon(icon2) self.delPush.setCheckable(True) self.delPush.setObjectName("delPush") self.verticalLayout_3.addWidget(self.delPush) self.conjPush = QtWidgets.QToolButton(self.pzgroupBox) icon3 = QtGui.QIcon() - icon3.addPixmap(QtGui.QPixmap(":/icons/conjugate.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon3.addPixmap(QtGui.QPixmap(":/icons/conjugate.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.conjPush.setIcon(icon3) self.conjPush.setIconSize(QtCore.QSize(16, 16)) self.conjPush.setCheckable(True) @@ -193,10 +216,12 @@ class Ui_MainWindow(object): self.verticalLayout_3.addWidget(self.conjPush) self.gridLayout_2.addWidget(self.pzgroupBox, 0, 2, 1, 1) self.pzPlot = PzPlot(self.poleZero) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.pzPlot.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.pzPlot.sizePolicy().hasHeightForWidth()) self.pzPlot.setSizePolicy(sizePolicy) self.pzPlot.setFrameShape(QtWidgets.QFrame.StyledPanel) self.pzPlot.setFrameShadow(QtWidgets.QFrame.Sunken) @@ -263,34 +288,41 @@ class Ui_MainWindow(object): self.sysParamsBox.setGeometry(QtCore.QRect(10, 390, 161, 91)) self.sysParamsBox.setObjectName("sysParamsBox") self.formLayout_4 = QtWidgets.QFormLayout(self.sysParamsBox) - self.formLayout_4.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_4.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_4.setObjectName("formLayout_4") self.nfftLabel = QtWidgets.QLabel(self.sysParamsBox) self.nfftLabel.setMinimumSize(QtCore.QSize(150, 0)) self.nfftLabel.setObjectName("nfftLabel") - self.formLayout_4.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.nfftLabel) + self.formLayout_4.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.nfftLabel) self.nfftEdit = QtWidgets.QLineEdit(self.sysParamsBox) self.nfftEdit.setObjectName("nfftEdit") - self.formLayout_4.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.nfftEdit) + self.formLayout_4.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.nfftEdit) self.groupSpecs.raise_() self.responseBox.raise_() self.sysParamsBox.raise_() self.horizontalLayout.addWidget(self.quickFrame) self.stackedWindows.addWidget(self.classic) self.modern = QtWidgets.QWidget() - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.modern.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.modern.sizePolicy().hasHeightForWidth()) self.modern.setSizePolicy(sizePolicy) self.modern.setObjectName("modern") self.horizontalLayout_5 = QtWidgets.QHBoxLayout(self.modern) self.horizontalLayout_5.setObjectName("horizontalLayout_5") self.splitter_3 = QtWidgets.QSplitter(self.modern) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.splitter_3.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.splitter_3.sizePolicy().hasHeightForWidth()) self.splitter_3.setSizePolicy(sizePolicy) self.splitter_3.setOrientation(QtCore.Qt.Vertical) self.splitter_3.setObjectName("splitter_3") @@ -301,10 +333,12 @@ class Ui_MainWindow(object): self.mfreqTabgroup.setTabsClosable(False) self.mfreqTabgroup.setObjectName("mfreqTabgroup") self.mfreqTab = QtWidgets.QWidget() - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.mfreqTab.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.mfreqTab.sizePolicy().hasHeightForWidth()) self.mfreqTab.setSizePolicy(sizePolicy) self.mfreqTab.setObjectName("mfreqTab") self.horizontalLayout_2 = QtWidgets.QHBoxLayout(self.mfreqTab) @@ -322,7 +356,8 @@ class Ui_MainWindow(object): self.verticalLayout_2.setObjectName("verticalLayout_2") self.mfmagPush = QtWidgets.QToolButton(self.mfgroupBox) icon4 = QtGui.QIcon() - icon4.addPixmap(QtGui.QPixmap(":/icons/mag_response.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon4.addPixmap(QtGui.QPixmap(":/icons/mag_response.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mfmagPush.setIcon(icon4) self.mfmagPush.setIconSize(QtCore.QSize(16, 16)) self.mfmagPush.setCheckable(False) @@ -330,7 +365,8 @@ class Ui_MainWindow(object): self.verticalLayout_2.addWidget(self.mfmagPush) self.mfphasePush = QtWidgets.QToolButton(self.mfgroupBox) icon5 = QtGui.QIcon() - icon5.addPixmap(QtGui.QPixmap(":/icons/phase_response.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon5.addPixmap(QtGui.QPixmap(":/icons/phase_response.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mfphasePush.setIcon(icon5) self.mfphasePush.setIconSize(QtCore.QSize(16, 16)) self.mfphasePush.setCheckable(False) @@ -338,7 +374,8 @@ class Ui_MainWindow(object): self.verticalLayout_2.addWidget(self.mfphasePush) self.mfgpdlyPush = QtWidgets.QToolButton(self.mfgroupBox) icon6 = QtGui.QIcon() - icon6.addPixmap(QtGui.QPixmap(":/icons/group_delay.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon6.addPixmap(QtGui.QPixmap(":/icons/group_delay.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mfgpdlyPush.setIcon(icon6) self.mfgpdlyPush.setIconSize(QtCore.QSize(16, 16)) self.mfgpdlyPush.setCheckable(False) @@ -346,7 +383,8 @@ class Ui_MainWindow(object): self.verticalLayout_2.addWidget(self.mfgpdlyPush) self.mfphdlyPush = QtWidgets.QToolButton(self.mfgroupBox) icon7 = QtGui.QIcon() - icon7.addPixmap(QtGui.QPixmap(":/icons/phase_delay.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon7.addPixmap(QtGui.QPixmap(":/icons/phase_delay.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mfphdlyPush.setIcon(icon7) self.mfphdlyPush.setIconSize(QtCore.QSize(16, 16)) self.mfphdlyPush.setCheckable(False) @@ -354,7 +392,8 @@ class Ui_MainWindow(object): self.verticalLayout_2.addWidget(self.mfphdlyPush) self.mfoverlayPush = QtWidgets.QToolButton(self.mfgroupBox) icon8 = QtGui.QIcon() - icon8.addPixmap(QtGui.QPixmap(":/icons/overlay.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon8.addPixmap(QtGui.QPixmap(":/icons/overlay.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mfoverlayPush.setIcon(icon8) self.mfoverlayPush.setIconSize(QtCore.QSize(16, 16)) self.mfoverlayPush.setCheckable(True) @@ -365,10 +404,12 @@ class Ui_MainWindow(object): self.mtimeTabgroup = QtWidgets.QTabWidget(self.splitter_2) self.mtimeTabgroup.setObjectName("mtimeTabgroup") self.mtimeTab = QtWidgets.QWidget() - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.mtimeTab.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.mtimeTab.sizePolicy().hasHeightForWidth()) self.mtimeTab.setSizePolicy(sizePolicy) self.mtimeTab.setObjectName("mtimeTab") self.horizontalLayout_3 = QtWidgets.QHBoxLayout(self.mtimeTab) @@ -386,7 +427,8 @@ class Ui_MainWindow(object): self.verticalLayout_5.setObjectName("verticalLayout_5") self.mttapsPush = QtWidgets.QToolButton(self.mtgroupBox) icon9 = QtGui.QIcon() - icon9.addPixmap(QtGui.QPixmap(":/icons/filtr_taps.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon9.addPixmap(QtGui.QPixmap(":/icons/filtr_taps.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mttapsPush.setIcon(icon9) self.mttapsPush.setIconSize(QtCore.QSize(16, 16)) self.mttapsPush.setCheckable(False) @@ -394,7 +436,8 @@ class Ui_MainWindow(object): self.verticalLayout_5.addWidget(self.mttapsPush) self.mtstepPush = QtWidgets.QToolButton(self.mtgroupBox) icon10 = QtGui.QIcon() - icon10.addPixmap(QtGui.QPixmap(":/icons/step_response.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon10.addPixmap(QtGui.QPixmap(":/icons/step_response.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mtstepPush.setIcon(icon10) self.mtstepPush.setIconSize(QtCore.QSize(16, 16)) self.mtstepPush.setCheckable(False) @@ -402,7 +445,8 @@ class Ui_MainWindow(object): self.verticalLayout_5.addWidget(self.mtstepPush) self.mtimpPush = QtWidgets.QToolButton(self.mtgroupBox) icon11 = QtGui.QIcon() - icon11.addPixmap(QtGui.QPixmap(":/icons/impulse.svg"), QtGui.QIcon.Normal, QtGui.QIcon.Off) + icon11.addPixmap(QtGui.QPixmap(":/icons/impulse.svg"), + QtGui.QIcon.Normal, QtGui.QIcon.Off) self.mtimpPush.setIcon(icon11) self.mtimpPush.setIconSize(QtCore.QSize(16, 16)) self.mtimpPush.setCheckable(False) @@ -411,10 +455,12 @@ class Ui_MainWindow(object): self.horizontalLayout_3.addWidget(self.mtgroupBox) self.mtimeTabgroup.addTab(self.mtimeTab, "") self.mfilterspecView = QtWidgets.QTabWidget(self.splitter_3) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Expanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.mfilterspecView.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.mfilterspecView.sizePolicy().hasHeightForWidth()) self.mfilterspecView.setSizePolicy(sizePolicy) self.mfilterspecView.setMinimumSize(QtCore.QSize(0, 100)) self.mfilterspecView.setBaseSize(QtCore.QSize(0, 100)) @@ -422,19 +468,23 @@ class Ui_MainWindow(object): self.mfilterspecView.setTabsClosable(False) self.mfilterspecView.setObjectName("mfilterspecView") self.mbandDiagram = QtWidgets.QWidget() - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.mbandDiagram.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.mbandDiagram.sizePolicy().hasHeightForWidth()) self.mbandDiagram.setSizePolicy(sizePolicy) self.mbandDiagram.setObjectName("mbandDiagram") self.horizontalLayout_15 = QtWidgets.QHBoxLayout(self.mbandDiagram) self.horizontalLayout_15.setObjectName("horizontalLayout_15") self.mbandView = BandGraphicsView(self.mbandDiagram) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(1) - sizePolicy.setHeightForWidth(self.mbandView.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.mbandView.sizePolicy().hasHeightForWidth()) self.mbandView.setSizePolicy(sizePolicy) self.mbandView.setMinimumSize(QtCore.QSize(525, 249)) self.mbandView.setObjectName("mbandView") @@ -479,10 +529,12 @@ class Ui_MainWindow(object): self.mpzstatusBar.setObjectName("mpzstatusBar") self.gridLayout_3.addWidget(self.mpzstatusBar, 1, 0, 1, 3) self.mpzPlot = PzPlot(self.mpoleZero) - sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) + sizePolicy = QtWidgets.QSizePolicy( + QtWidgets.QSizePolicy.MinimumExpanding, QtWidgets.QSizePolicy.MinimumExpanding) sizePolicy.setHorizontalStretch(0) sizePolicy.setVerticalStretch(0) - sizePolicy.setHeightForWidth(self.mpzPlot.sizePolicy().hasHeightForWidth()) + sizePolicy.setHeightForWidth( + self.mpzPlot.sizePolicy().hasHeightForWidth()) self.mpzPlot.setSizePolicy(sizePolicy) self.mpzPlot.setFrameShape(QtWidgets.QFrame.StyledPanel) self.mpzPlot.setFrameShadow(QtWidgets.QFrame.Sunken) @@ -561,54 +613,68 @@ class Ui_MainWindow(object): self.globalParamsBox.setTitle("") self.globalParamsBox.setObjectName("globalParamsBox") self.formLayout_12 = QtWidgets.QFormLayout(self.globalParamsBox) - self.formLayout_12.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_12.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_12.setObjectName("formLayout_12") self.sampleRateLabel = QtWidgets.QLabel(self.globalParamsBox) self.sampleRateLabel.setMaximumSize(QtCore.QSize(16777215, 30)) self.sampleRateLabel.setObjectName("sampleRateLabel") - self.formLayout_12.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.sampleRateLabel) + self.formLayout_12.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.sampleRateLabel) self.sampleRateEdit = QtWidgets.QLineEdit(self.globalParamsBox) self.sampleRateEdit.setMaximumSize(QtCore.QSize(16777215, 30)) self.sampleRateEdit.setObjectName("sampleRateEdit") - self.formLayout_12.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.sampleRateEdit) + self.formLayout_12.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.sampleRateEdit) self.filterGainLabel = QtWidgets.QLabel(self.globalParamsBox) self.filterGainLabel.setObjectName("filterGainLabel") - self.formLayout_12.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.filterGainLabel) + self.formLayout_12.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.filterGainLabel) self.filterGainEdit = QtWidgets.QLineEdit(self.globalParamsBox) self.filterGainEdit.setObjectName("filterGainEdit") - self.formLayout_12.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.filterGainEdit) + self.formLayout_12.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.filterGainEdit) self.verticalLayout.addWidget(self.globalParamsBox) self.filterTypeWidget = QtWidgets.QStackedWidget(self.filterFrame) self.filterTypeWidget.setObjectName("filterTypeWidget") self.firlpfPage = QtWidgets.QWidget() self.firlpfPage.setObjectName("firlpfPage") self.formLayout = QtWidgets.QFormLayout(self.firlpfPage) - self.formLayout.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout.setObjectName("formLayout") self.endofLpfPassBandLabel = QtWidgets.QLabel(self.firlpfPage) self.endofLpfPassBandLabel.setObjectName("endofLpfPassBandLabel") - self.formLayout.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.endofLpfPassBandLabel) + self.formLayout.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.endofLpfPassBandLabel) self.endofLpfPassBandEdit = QtWidgets.QLineEdit(self.firlpfPage) self.endofLpfPassBandEdit.setObjectName("endofLpfPassBandEdit") - self.formLayout.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.endofLpfPassBandEdit) + self.formLayout.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.endofLpfPassBandEdit) self.startofLpfStopBandLabel = QtWidgets.QLabel(self.firlpfPage) self.startofLpfStopBandLabel.setObjectName("startofLpfStopBandLabel") - self.formLayout.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.startofLpfStopBandLabel) + self.formLayout.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.startofLpfStopBandLabel) self.startofLpfStopBandEdit = QtWidgets.QLineEdit(self.firlpfPage) self.startofLpfStopBandEdit.setObjectName("startofLpfStopBandEdit") - self.formLayout.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.startofLpfStopBandEdit) + self.formLayout.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.startofLpfStopBandEdit) self.lpfStopBandAttenLabel = QtWidgets.QLabel(self.firlpfPage) self.lpfStopBandAttenLabel.setObjectName("lpfStopBandAttenLabel") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.lpfStopBandAttenLabel) + self.formLayout.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.lpfStopBandAttenLabel) self.lpfStopBandAttenEdit = QtWidgets.QLineEdit(self.firlpfPage) self.lpfStopBandAttenEdit.setObjectName("lpfStopBandAttenEdit") - self.formLayout.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.lpfStopBandAttenEdit) + self.formLayout.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.lpfStopBandAttenEdit) self.lpfPassBandRippleLabel = QtWidgets.QLabel(self.firlpfPage) self.lpfPassBandRippleLabel.setObjectName("lpfPassBandRippleLabel") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.lpfPassBandRippleLabel) + self.formLayout.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.lpfPassBandRippleLabel) self.lpfPassBandRippleEdit = QtWidgets.QLineEdit(self.firlpfPage) self.lpfPassBandRippleEdit.setObjectName("lpfPassBandRippleEdit") - self.formLayout.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.lpfPassBandRippleEdit) + self.formLayout.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.lpfPassBandRippleEdit) self.filterTypeWidget.addWidget(self.firlpfPage) self.firbpfPage = QtWidgets.QWidget() self.firbpfPage.setObjectName("firbpfPage") @@ -616,100 +682,130 @@ class Ui_MainWindow(object): self.formLayout_2.setObjectName("formLayout_2") self.startofBpfPassBandLabel = QtWidgets.QLabel(self.firbpfPage) self.startofBpfPassBandLabel.setObjectName("startofBpfPassBandLabel") - self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.startofBpfPassBandLabel) + self.formLayout_2.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.startofBpfPassBandLabel) self.startofBpfPassBandEdit = QtWidgets.QLineEdit(self.firbpfPage) self.startofBpfPassBandEdit.setObjectName("startofBpfPassBandEdit") - self.formLayout_2.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.startofBpfPassBandEdit) + self.formLayout_2.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.startofBpfPassBandEdit) self.endofBpfPassBandLabel = QtWidgets.QLabel(self.firbpfPage) self.endofBpfPassBandLabel.setObjectName("endofBpfPassBandLabel") - self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.endofBpfPassBandLabel) + self.formLayout_2.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.endofBpfPassBandLabel) self.endofBpfPassBandEdit = QtWidgets.QLineEdit(self.firbpfPage) self.endofBpfPassBandEdit.setObjectName("endofBpfPassBandEdit") - self.formLayout_2.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.endofBpfPassBandEdit) + self.formLayout_2.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.endofBpfPassBandEdit) self.bpfStopBandAttenEdit = QtWidgets.QLineEdit(self.firbpfPage) self.bpfStopBandAttenEdit.setObjectName("bpfStopBandAttenEdit") - self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.bpfStopBandAttenEdit) + self.formLayout_2.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.bpfStopBandAttenEdit) self.bpfStopBandAttenLabel = QtWidgets.QLabel(self.firbpfPage) self.bpfStopBandAttenLabel.setObjectName("bpfStopBandAttenLabel") - self.formLayout_2.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.bpfStopBandAttenLabel) + self.formLayout_2.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.bpfStopBandAttenLabel) self.bpfTransitionLabel = QtWidgets.QLabel(self.firbpfPage) self.bpfTransitionLabel.setObjectName("bpfTransitionLabel") - self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.bpfTransitionLabel) + self.formLayout_2.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.bpfTransitionLabel) self.bpfTransitionEdit = QtWidgets.QLineEdit(self.firbpfPage) self.bpfTransitionEdit.setObjectName("bpfTransitionEdit") - self.formLayout_2.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.bpfTransitionEdit) + self.formLayout_2.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.bpfTransitionEdit) self.bpfPassBandRippleEdit = QtWidgets.QLineEdit(self.firbpfPage) self.bpfPassBandRippleEdit.setObjectName("bpfPassBandRippleEdit") - self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.bpfPassBandRippleEdit) + self.formLayout_2.setWidget( + 4, QtWidgets.QFormLayout.FieldRole, self.bpfPassBandRippleEdit) self.bpfPassBandRippleLabel = QtWidgets.QLabel(self.firbpfPage) self.bpfPassBandRippleLabel.setObjectName("bpfPassBandRippleLabel") - self.formLayout_2.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.bpfPassBandRippleLabel) + self.formLayout_2.setWidget( + 4, QtWidgets.QFormLayout.LabelRole, self.bpfPassBandRippleLabel) self.filterTypeWidget.addWidget(self.firbpfPage) self.firbnfPage = QtWidgets.QWidget() self.firbnfPage.setObjectName("firbnfPage") self.formLayout_5 = QtWidgets.QFormLayout(self.firbnfPage) - self.formLayout_5.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_5.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_5.setObjectName("formLayout_5") self.startofBnfStopBandLabel = QtWidgets.QLabel(self.firbnfPage) self.startofBnfStopBandLabel.setObjectName("startofBnfStopBandLabel") - self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.startofBnfStopBandLabel) + self.formLayout_5.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.startofBnfStopBandLabel) self.startofBnfStopBandEdit = QtWidgets.QLineEdit(self.firbnfPage) self.startofBnfStopBandEdit.setObjectName("startofBnfStopBandEdit") - self.formLayout_5.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.startofBnfStopBandEdit) + self.formLayout_5.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.startofBnfStopBandEdit) self.endofBnfStopBandLabel = QtWidgets.QLabel(self.firbnfPage) self.endofBnfStopBandLabel.setObjectName("endofBnfStopBandLabel") - self.formLayout_5.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.endofBnfStopBandLabel) + self.formLayout_5.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.endofBnfStopBandLabel) self.endofBnfStopBandEdit = QtWidgets.QLineEdit(self.firbnfPage) self.endofBnfStopBandEdit.setObjectName("endofBnfStopBandEdit") - self.formLayout_5.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.endofBnfStopBandEdit) + self.formLayout_5.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.endofBnfStopBandEdit) self.bnfTransitionLabel = QtWidgets.QLabel(self.firbnfPage) self.bnfTransitionLabel.setObjectName("bnfTransitionLabel") - self.formLayout_5.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.bnfTransitionLabel) + self.formLayout_5.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.bnfTransitionLabel) self.bnfTransitionEdit = QtWidgets.QLineEdit(self.firbnfPage) self.bnfTransitionEdit.setObjectName("bnfTransitionEdit") - self.formLayout_5.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.bnfTransitionEdit) + self.formLayout_5.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.bnfTransitionEdit) self.bnfStopBandAttenLabel = QtWidgets.QLabel(self.firbnfPage) self.bnfStopBandAttenLabel.setObjectName("bnfStopBandAttenLabel") - self.formLayout_5.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.bnfStopBandAttenLabel) + self.formLayout_5.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.bnfStopBandAttenLabel) self.bnfStopBandAttenEdit = QtWidgets.QLineEdit(self.firbnfPage) self.bnfStopBandAttenEdit.setObjectName("bnfStopBandAttenEdit") - self.formLayout_5.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.bnfStopBandAttenEdit) + self.formLayout_5.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.bnfStopBandAttenEdit) self.bnfPassBandRippleLabel = QtWidgets.QLabel(self.firbnfPage) self.bnfPassBandRippleLabel.setObjectName("bnfPassBandRippleLabel") - self.formLayout_5.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.bnfPassBandRippleLabel) + self.formLayout_5.setWidget( + 4, QtWidgets.QFormLayout.LabelRole, self.bnfPassBandRippleLabel) self.bnfPassBandRippleEdit = QtWidgets.QLineEdit(self.firbnfPage) self.bnfPassBandRippleEdit.setObjectName("bnfPassBandRippleEdit") - self.formLayout_5.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.bnfPassBandRippleEdit) + self.formLayout_5.setWidget( + 4, QtWidgets.QFormLayout.FieldRole, self.bnfPassBandRippleEdit) self.filterTypeWidget.addWidget(self.firbnfPage) self.firhpfPage = QtWidgets.QWidget() self.firhpfPage.setObjectName("firhpfPage") self.formLayout_3 = QtWidgets.QFormLayout(self.firhpfPage) - self.formLayout_3.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_3.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_3.setObjectName("formLayout_3") self.endofHpfStopBandLabel = QtWidgets.QLabel(self.firhpfPage) self.endofHpfStopBandLabel.setObjectName("endofHpfStopBandLabel") - self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.endofHpfStopBandLabel) + self.formLayout_3.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.endofHpfStopBandLabel) self.endofHpfStopBandEdit = QtWidgets.QLineEdit(self.firhpfPage) self.endofHpfStopBandEdit.setObjectName("endofHpfStopBandEdit") - self.formLayout_3.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.endofHpfStopBandEdit) + self.formLayout_3.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.endofHpfStopBandEdit) self.startofHpfPassBandLabel = QtWidgets.QLabel(self.firhpfPage) self.startofHpfPassBandLabel.setObjectName("startofHpfPassBandLabel") - self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.startofHpfPassBandLabel) + self.formLayout_3.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.startofHpfPassBandLabel) self.startofHpfPassBandEdit = QtWidgets.QLineEdit(self.firhpfPage) self.startofHpfPassBandEdit.setObjectName("startofHpfPassBandEdit") - self.formLayout_3.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.startofHpfPassBandEdit) + self.formLayout_3.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.startofHpfPassBandEdit) self.hpfStopBandAttenLabel = QtWidgets.QLabel(self.firhpfPage) self.hpfStopBandAttenLabel.setObjectName("hpfStopBandAttenLabel") - self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.hpfStopBandAttenLabel) + self.formLayout_3.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.hpfStopBandAttenLabel) self.hpfStopBandAttenEdit = QtWidgets.QLineEdit(self.firhpfPage) self.hpfStopBandAttenEdit.setObjectName("hpfStopBandAttenEdit") - self.formLayout_3.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.hpfStopBandAttenEdit) + self.formLayout_3.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.hpfStopBandAttenEdit) self.hpfPassBandRippleLabel = QtWidgets.QLabel(self.firhpfPage) self.hpfPassBandRippleLabel.setObjectName("hpfPassBandRippleLabel") - self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.hpfPassBandRippleLabel) + self.formLayout_3.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.hpfPassBandRippleLabel) self.hpfPassBandRippleEdit = QtWidgets.QLineEdit(self.firhpfPage) self.hpfPassBandRippleEdit.setObjectName("hpfPassBandRippleEdit") - self.formLayout_3.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.hpfPassBandRippleEdit) + self.formLayout_3.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.hpfPassBandRippleEdit) self.filterTypeWidget.addWidget(self.firhpfPage) self.rrcPage = QtWidgets.QWidget() self.rrcPage.setObjectName("rrcPage") @@ -717,22 +813,28 @@ class Ui_MainWindow(object): self.formLayout_6.setObjectName("formLayout_6") self.rrcSymbolRateLabel = QtWidgets.QLabel(self.rrcPage) self.rrcSymbolRateLabel.setObjectName("rrcSymbolRateLabel") - self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.rrcSymbolRateLabel) + self.formLayout_6.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.rrcSymbolRateLabel) self.rrcAlphaLabel = QtWidgets.QLabel(self.rrcPage) self.rrcAlphaLabel.setObjectName("rrcAlphaLabel") - self.formLayout_6.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.rrcAlphaLabel) + self.formLayout_6.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.rrcAlphaLabel) self.rrcNumTapsLabel = QtWidgets.QLabel(self.rrcPage) self.rrcNumTapsLabel.setObjectName("rrcNumTapsLabel") - self.formLayout_6.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.rrcNumTapsLabel) + self.formLayout_6.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.rrcNumTapsLabel) self.rrcSymbolRateEdit = QtWidgets.QLineEdit(self.rrcPage) self.rrcSymbolRateEdit.setObjectName("rrcSymbolRateEdit") - self.formLayout_6.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.rrcSymbolRateEdit) + self.formLayout_6.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.rrcSymbolRateEdit) self.rrcAlphaEdit = QtWidgets.QLineEdit(self.rrcPage) self.rrcAlphaEdit.setObjectName("rrcAlphaEdit") - self.formLayout_6.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.rrcAlphaEdit) + self.formLayout_6.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.rrcAlphaEdit) self.rrcNumTapsEdit = QtWidgets.QLineEdit(self.rrcPage) self.rrcNumTapsEdit.setObjectName("rrcNumTapsEdit") - self.formLayout_6.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.rrcNumTapsEdit) + self.formLayout_6.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.rrcNumTapsEdit) self.filterTypeWidget.addWidget(self.rrcPage) self.gausPage = QtWidgets.QWidget() self.gausPage.setObjectName("gausPage") @@ -740,22 +842,28 @@ class Ui_MainWindow(object): self.formLayout_7.setObjectName("formLayout_7") self.gausSymbolRateLabel = QtWidgets.QLabel(self.gausPage) self.gausSymbolRateLabel.setObjectName("gausSymbolRateLabel") - self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.gausSymbolRateLabel) + self.formLayout_7.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.gausSymbolRateLabel) self.gausSymbolRateEdit = QtWidgets.QLineEdit(self.gausPage) self.gausSymbolRateEdit.setObjectName("gausSymbolRateEdit") - self.formLayout_7.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.gausSymbolRateEdit) + self.formLayout_7.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.gausSymbolRateEdit) self.gausBTLabel = QtWidgets.QLabel(self.gausPage) self.gausBTLabel.setObjectName("gausBTLabel") - self.formLayout_7.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.gausBTLabel) + self.formLayout_7.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.gausBTLabel) self.gausBTEdit = QtWidgets.QLineEdit(self.gausPage) self.gausBTEdit.setObjectName("gausBTEdit") - self.formLayout_7.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.gausBTEdit) + self.formLayout_7.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.gausBTEdit) self.gausNumTapsLabel = QtWidgets.QLabel(self.gausPage) self.gausNumTapsLabel.setObjectName("gausNumTapsLabel") - self.formLayout_7.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.gausNumTapsLabel) + self.formLayout_7.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.gausNumTapsLabel) self.gausNumTapsEdit = QtWidgets.QLineEdit(self.gausPage) self.gausNumTapsEdit.setObjectName("gausNumTapsEdit") - self.formLayout_7.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.gausNumTapsEdit) + self.formLayout_7.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.gausNumTapsEdit) self.filterTypeWidget.addWidget(self.gausPage) self.iirlpfPage = QtWidgets.QWidget() self.iirlpfPage.setObjectName("iirlpfPage") @@ -763,28 +871,39 @@ class Ui_MainWindow(object): self.formLayout_15.setObjectName("formLayout_15") self.iirendofLpfPassBandLabel = QtWidgets.QLabel(self.iirlpfPage) self.iirendofLpfPassBandLabel.setObjectName("iirendofLpfPassBandLabel") - self.formLayout_15.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.iirendofLpfPassBandLabel) + self.formLayout_15.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.iirendofLpfPassBandLabel) self.iirendofLpfPassBandEdit = QtWidgets.QLineEdit(self.iirlpfPage) self.iirendofLpfPassBandEdit.setObjectName("iirendofLpfPassBandEdit") - self.formLayout_15.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.iirendofLpfPassBandEdit) + self.formLayout_15.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.iirendofLpfPassBandEdit) self.iirstartofLpfStopBandLabel = QtWidgets.QLabel(self.iirlpfPage) - self.iirstartofLpfStopBandLabel.setObjectName("iirstartofLpfStopBandLabel") - self.formLayout_15.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.iirstartofLpfStopBandLabel) + self.iirstartofLpfStopBandLabel.setObjectName( + "iirstartofLpfStopBandLabel") + self.formLayout_15.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.iirstartofLpfStopBandLabel) self.iirstartofLpfStopBandEdit = QtWidgets.QLineEdit(self.iirlpfPage) - self.iirstartofLpfStopBandEdit.setObjectName("iirstartofLpfStopBandEdit") - self.formLayout_15.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.iirstartofLpfStopBandEdit) + self.iirstartofLpfStopBandEdit.setObjectName( + "iirstartofLpfStopBandEdit") + self.formLayout_15.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.iirstartofLpfStopBandEdit) self.iirLpfPassBandAttenLabel = QtWidgets.QLabel(self.iirlpfPage) self.iirLpfPassBandAttenLabel.setObjectName("iirLpfPassBandAttenLabel") - self.formLayout_15.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.iirLpfPassBandAttenLabel) + self.formLayout_15.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.iirLpfPassBandAttenLabel) self.iirLpfPassBandAttenEdit = QtWidgets.QLineEdit(self.iirlpfPage) self.iirLpfPassBandAttenEdit.setObjectName("iirLpfPassBandAttenEdit") - self.formLayout_15.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.iirLpfPassBandAttenEdit) + self.formLayout_15.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.iirLpfPassBandAttenEdit) self.iirLpfStopBandRippleLabel = QtWidgets.QLabel(self.iirlpfPage) - self.iirLpfStopBandRippleLabel.setObjectName("iirLpfStopBandRippleLabel") - self.formLayout_15.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.iirLpfStopBandRippleLabel) + self.iirLpfStopBandRippleLabel.setObjectName( + "iirLpfStopBandRippleLabel") + self.formLayout_15.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.iirLpfStopBandRippleLabel) self.iirLpfStopBandRippleEdit = QtWidgets.QLineEdit(self.iirlpfPage) self.iirLpfStopBandRippleEdit.setObjectName("iirLpfStopBandRippleEdit") - self.formLayout_15.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.iirLpfStopBandRippleEdit) + self.formLayout_15.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.iirLpfStopBandRippleEdit) self.filterTypeWidget.addWidget(self.iirlpfPage) self.iirhpfPage = QtWidgets.QWidget() self.iirhpfPage.setObjectName("iirhpfPage") @@ -792,170 +911,232 @@ class Ui_MainWindow(object): self.formLayout_9.setObjectName("formLayout_9") self.iirendofHpfStopBandLabel = QtWidgets.QLabel(self.iirhpfPage) self.iirendofHpfStopBandLabel.setObjectName("iirendofHpfStopBandLabel") - self.formLayout_9.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.iirendofHpfStopBandLabel) + self.formLayout_9.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.iirendofHpfStopBandLabel) self.iirendofHpfStopBandEdit = QtWidgets.QLineEdit(self.iirhpfPage) self.iirendofHpfStopBandEdit.setObjectName("iirendofHpfStopBandEdit") - self.formLayout_9.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.iirendofHpfStopBandEdit) + self.formLayout_9.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.iirendofHpfStopBandEdit) self.iirstartofHpfPassBandLabel = QtWidgets.QLabel(self.iirhpfPage) - self.iirstartofHpfPassBandLabel.setObjectName("iirstartofHpfPassBandLabel") - self.formLayout_9.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.iirstartofHpfPassBandLabel) + self.iirstartofHpfPassBandLabel.setObjectName( + "iirstartofHpfPassBandLabel") + self.formLayout_9.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.iirstartofHpfPassBandLabel) self.iirstartofHpfPassBandEdit = QtWidgets.QLineEdit(self.iirhpfPage) - self.iirstartofHpfPassBandEdit.setObjectName("iirstartofHpfPassBandEdit") - self.formLayout_9.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.iirstartofHpfPassBandEdit) + self.iirstartofHpfPassBandEdit.setObjectName( + "iirstartofHpfPassBandEdit") + self.formLayout_9.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.iirstartofHpfPassBandEdit) self.iirHpfPassBandAttenLabel = QtWidgets.QLabel(self.iirhpfPage) self.iirHpfPassBandAttenLabel.setObjectName("iirHpfPassBandAttenLabel") - self.formLayout_9.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.iirHpfPassBandAttenLabel) + self.formLayout_9.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.iirHpfPassBandAttenLabel) self.iirHpfPassBandAttenEdit = QtWidgets.QLineEdit(self.iirhpfPage) self.iirHpfPassBandAttenEdit.setObjectName("iirHpfPassBandAttenEdit") - self.formLayout_9.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.iirHpfPassBandAttenEdit) + self.formLayout_9.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.iirHpfPassBandAttenEdit) self.iirHpfStopBandRippleLabel = QtWidgets.QLabel(self.iirhpfPage) - self.iirHpfStopBandRippleLabel.setObjectName("iirHpfStopBandRippleLabel") - self.formLayout_9.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.iirHpfStopBandRippleLabel) + self.iirHpfStopBandRippleLabel.setObjectName( + "iirHpfStopBandRippleLabel") + self.formLayout_9.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.iirHpfStopBandRippleLabel) self.iirHpfStopBandRippleEdit = QtWidgets.QLineEdit(self.iirhpfPage) self.iirHpfStopBandRippleEdit.setObjectName("iirHpfStopBandRippleEdit") - self.formLayout_9.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.iirHpfStopBandRippleEdit) + self.formLayout_9.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.iirHpfStopBandRippleEdit) self.filterTypeWidget.addWidget(self.iirhpfPage) self.iirbpfPage = QtWidgets.QWidget() self.iirbpfPage.setObjectName("iirbpfPage") self.formLayout_10 = QtWidgets.QFormLayout(self.iirbpfPage) self.formLayout_10.setObjectName("formLayout_10") self.iirendofBpfStopBandLabel1 = QtWidgets.QLabel(self.iirbpfPage) - self.iirendofBpfStopBandLabel1.setObjectName("iirendofBpfStopBandLabel1") - self.formLayout_10.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.iirendofBpfStopBandLabel1) + self.iirendofBpfStopBandLabel1.setObjectName( + "iirendofBpfStopBandLabel1") + self.formLayout_10.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.iirendofBpfStopBandLabel1) self.iirendofBpfStopBandEdit1 = QtWidgets.QLineEdit(self.iirbpfPage) self.iirendofBpfStopBandEdit1.setObjectName("iirendofBpfStopBandEdit1") - self.formLayout_10.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.iirendofBpfStopBandEdit1) + self.formLayout_10.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.iirendofBpfStopBandEdit1) self.iirstartofBpfPassBandLabel = QtWidgets.QLabel(self.iirbpfPage) - self.iirstartofBpfPassBandLabel.setObjectName("iirstartofBpfPassBandLabel") - self.formLayout_10.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.iirstartofBpfPassBandLabel) + self.iirstartofBpfPassBandLabel.setObjectName( + "iirstartofBpfPassBandLabel") + self.formLayout_10.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.iirstartofBpfPassBandLabel) self.iirstartofBpfPassBandEdit = QtWidgets.QLineEdit(self.iirbpfPage) - self.iirstartofBpfPassBandEdit.setObjectName("iirstartofBpfPassBandEdit") - self.formLayout_10.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.iirstartofBpfPassBandEdit) + self.iirstartofBpfPassBandEdit.setObjectName( + "iirstartofBpfPassBandEdit") + self.formLayout_10.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.iirstartofBpfPassBandEdit) self.iirendofBpfPassBandLabel = QtWidgets.QLabel(self.iirbpfPage) self.iirendofBpfPassBandLabel.setObjectName("iirendofBpfPassBandLabel") - self.formLayout_10.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.iirendofBpfPassBandLabel) + self.formLayout_10.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.iirendofBpfPassBandLabel) self.iirendofBpfPassBandEdit = QtWidgets.QLineEdit(self.iirbpfPage) self.iirendofBpfPassBandEdit.setObjectName("iirendofBpfPassBandEdit") - self.formLayout_10.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.iirendofBpfPassBandEdit) + self.formLayout_10.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.iirendofBpfPassBandEdit) self.iirstartofBpfStopBandLabel2 = QtWidgets.QLabel(self.iirbpfPage) - self.iirstartofBpfStopBandLabel2.setObjectName("iirstartofBpfStopBandLabel2") - self.formLayout_10.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.iirstartofBpfStopBandLabel2) + self.iirstartofBpfStopBandLabel2.setObjectName( + "iirstartofBpfStopBandLabel2") + self.formLayout_10.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.iirstartofBpfStopBandLabel2) self.iirstartofBpfStopBandEdit2 = QtWidgets.QLineEdit(self.iirbpfPage) - self.iirstartofBpfStopBandEdit2.setObjectName("iirstartofBpfStopBandEdit2") - self.formLayout_10.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.iirstartofBpfStopBandEdit2) + self.iirstartofBpfStopBandEdit2.setObjectName( + "iirstartofBpfStopBandEdit2") + self.formLayout_10.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.iirstartofBpfStopBandEdit2) self.iirBpfPassBandAttenLabel = QtWidgets.QLabel(self.iirbpfPage) self.iirBpfPassBandAttenLabel.setObjectName("iirBpfPassBandAttenLabel") - self.formLayout_10.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.iirBpfPassBandAttenLabel) + self.formLayout_10.setWidget( + 4, QtWidgets.QFormLayout.LabelRole, self.iirBpfPassBandAttenLabel) self.iirBpfPassBandAttenEdit = QtWidgets.QLineEdit(self.iirbpfPage) self.iirBpfPassBandAttenEdit.setObjectName("iirBpfPassBandAttenEdit") - self.formLayout_10.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.iirBpfPassBandAttenEdit) + self.formLayout_10.setWidget( + 4, QtWidgets.QFormLayout.FieldRole, self.iirBpfPassBandAttenEdit) self.iirBpfStopBandRippleLabel = QtWidgets.QLabel(self.iirbpfPage) - self.iirBpfStopBandRippleLabel.setObjectName("iirBpfStopBandRippleLabel") - self.formLayout_10.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.iirBpfStopBandRippleLabel) + self.iirBpfStopBandRippleLabel.setObjectName( + "iirBpfStopBandRippleLabel") + self.formLayout_10.setWidget( + 5, QtWidgets.QFormLayout.LabelRole, self.iirBpfStopBandRippleLabel) self.iirBpfStopBandRippleEdit = QtWidgets.QLineEdit(self.iirbpfPage) self.iirBpfStopBandRippleEdit.setObjectName("iirBpfStopBandRippleEdit") - self.formLayout_10.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.iirBpfStopBandRippleEdit) + self.formLayout_10.setWidget( + 5, QtWidgets.QFormLayout.FieldRole, self.iirBpfStopBandRippleEdit) self.filterTypeWidget.addWidget(self.iirbpfPage) self.iirbsfPage = QtWidgets.QWidget() self.iirbsfPage.setObjectName("iirbsfPage") self.formLayout_11 = QtWidgets.QFormLayout(self.iirbsfPage) self.formLayout_11.setObjectName("formLayout_11") self.iirendofBsfPassBandLabel1 = QtWidgets.QLabel(self.iirbsfPage) - self.iirendofBsfPassBandLabel1.setObjectName("iirendofBsfPassBandLabel1") - self.formLayout_11.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.iirendofBsfPassBandLabel1) + self.iirendofBsfPassBandLabel1.setObjectName( + "iirendofBsfPassBandLabel1") + self.formLayout_11.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.iirendofBsfPassBandLabel1) self.iirendofBsfPassBandEdit1 = QtWidgets.QLineEdit(self.iirbsfPage) self.iirendofBsfPassBandEdit1.setObjectName("iirendofBsfPassBandEdit1") - self.formLayout_11.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.iirendofBsfPassBandEdit1) + self.formLayout_11.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.iirendofBsfPassBandEdit1) self.iirstartofBsfStopBandLabel = QtWidgets.QLabel(self.iirbsfPage) - self.iirstartofBsfStopBandLabel.setObjectName("iirstartofBsfStopBandLabel") - self.formLayout_11.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.iirstartofBsfStopBandLabel) + self.iirstartofBsfStopBandLabel.setObjectName( + "iirstartofBsfStopBandLabel") + self.formLayout_11.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.iirstartofBsfStopBandLabel) self.iirstartofBsfStopBandEdit = QtWidgets.QLineEdit(self.iirbsfPage) - self.iirstartofBsfStopBandEdit.setObjectName("iirstartofBsfStopBandEdit") - self.formLayout_11.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.iirstartofBsfStopBandEdit) + self.iirstartofBsfStopBandEdit.setObjectName( + "iirstartofBsfStopBandEdit") + self.formLayout_11.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.iirstartofBsfStopBandEdit) self.iirendofBsfStopBandLabel = QtWidgets.QLabel(self.iirbsfPage) self.iirendofBsfStopBandLabel.setObjectName("iirendofBsfStopBandLabel") - self.formLayout_11.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.iirendofBsfStopBandLabel) + self.formLayout_11.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.iirendofBsfStopBandLabel) self.iirendofBsfStopBandEdit = QtWidgets.QLineEdit(self.iirbsfPage) self.iirendofBsfStopBandEdit.setObjectName("iirendofBsfStopBandEdit") - self.formLayout_11.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.iirendofBsfStopBandEdit) + self.formLayout_11.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.iirendofBsfStopBandEdit) self.iirstartofBsfPassBandLabel2 = QtWidgets.QLabel(self.iirbsfPage) - self.iirstartofBsfPassBandLabel2.setObjectName("iirstartofBsfPassBandLabel2") - self.formLayout_11.setWidget(3, QtWidgets.QFormLayout.LabelRole, self.iirstartofBsfPassBandLabel2) + self.iirstartofBsfPassBandLabel2.setObjectName( + "iirstartofBsfPassBandLabel2") + self.formLayout_11.setWidget( + 3, QtWidgets.QFormLayout.LabelRole, self.iirstartofBsfPassBandLabel2) self.iirstartofBsfPassBandEdit2 = QtWidgets.QLineEdit(self.iirbsfPage) - self.iirstartofBsfPassBandEdit2.setObjectName("iirstartofBsfPassBandEdit2") - self.formLayout_11.setWidget(3, QtWidgets.QFormLayout.FieldRole, self.iirstartofBsfPassBandEdit2) + self.iirstartofBsfPassBandEdit2.setObjectName( + "iirstartofBsfPassBandEdit2") + self.formLayout_11.setWidget( + 3, QtWidgets.QFormLayout.FieldRole, self.iirstartofBsfPassBandEdit2) self.iirBsfPassBandAttenLabel = QtWidgets.QLabel(self.iirbsfPage) self.iirBsfPassBandAttenLabel.setObjectName("iirBsfPassBandAttenLabel") - self.formLayout_11.setWidget(4, QtWidgets.QFormLayout.LabelRole, self.iirBsfPassBandAttenLabel) + self.formLayout_11.setWidget( + 4, QtWidgets.QFormLayout.LabelRole, self.iirBsfPassBandAttenLabel) self.iirBsfPassBandAttenEdit = QtWidgets.QLineEdit(self.iirbsfPage) self.iirBsfPassBandAttenEdit.setObjectName("iirBsfPassBandAttenEdit") - self.formLayout_11.setWidget(4, QtWidgets.QFormLayout.FieldRole, self.iirBsfPassBandAttenEdit) + self.formLayout_11.setWidget( + 4, QtWidgets.QFormLayout.FieldRole, self.iirBsfPassBandAttenEdit) self.iirBsfStopBandRippleLabel = QtWidgets.QLabel(self.iirbsfPage) - self.iirBsfStopBandRippleLabel.setObjectName("iirBsfStopBandRippleLabel") - self.formLayout_11.setWidget(5, QtWidgets.QFormLayout.LabelRole, self.iirBsfStopBandRippleLabel) + self.iirBsfStopBandRippleLabel.setObjectName( + "iirBsfStopBandRippleLabel") + self.formLayout_11.setWidget( + 5, QtWidgets.QFormLayout.LabelRole, self.iirBsfStopBandRippleLabel) self.iirBsfStopBandRippleEdit = QtWidgets.QLineEdit(self.iirbsfPage) self.iirBsfStopBandRippleEdit.setObjectName("iirBsfStopBandRippleEdit") - self.formLayout_11.setWidget(5, QtWidgets.QFormLayout.FieldRole, self.iirBsfStopBandRippleEdit) + self.formLayout_11.setWidget( + 5, QtWidgets.QFormLayout.FieldRole, self.iirBsfStopBandRippleEdit) self.filterTypeWidget.addWidget(self.iirbsfPage) self.iirbesselPage = QtWidgets.QWidget() self.iirbesselPage.setObjectName("iirbesselPage") self.formLayout_13 = QtWidgets.QFormLayout(self.iirbesselPage) - self.formLayout_13.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_13.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_13.setObjectName("formLayout_13") self.besselordLabel = QtWidgets.QLabel(self.iirbesselPage) self.besselordLabel.setObjectName("besselordLabel") - self.formLayout_13.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.besselordLabel) + self.formLayout_13.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.besselordLabel) self.besselordEdit = QtWidgets.QLineEdit(self.iirbesselPage) self.besselordEdit.setObjectName("besselordEdit") - self.formLayout_13.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.besselordEdit) + self.formLayout_13.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.besselordEdit) self.iirbesselcritLabel1 = QtWidgets.QLabel(self.iirbesselPage) self.iirbesselcritLabel1.setObjectName("iirbesselcritLabel1") - self.formLayout_13.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.iirbesselcritLabel1) + self.formLayout_13.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.iirbesselcritLabel1) self.iirbesselcritEdit1 = QtWidgets.QLineEdit(self.iirbesselPage) self.iirbesselcritEdit1.setObjectName("iirbesselcritEdit1") - self.formLayout_13.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.iirbesselcritEdit1) + self.formLayout_13.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.iirbesselcritEdit1) self.iirbesselcritEdit2 = QtWidgets.QLineEdit(self.iirbesselPage) self.iirbesselcritEdit2.setObjectName("iirbesselcritEdit2") - self.formLayout_13.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.iirbesselcritEdit2) + self.formLayout_13.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.iirbesselcritEdit2) self.iirbesselcritLabel2 = QtWidgets.QLabel(self.iirbesselPage) self.iirbesselcritLabel2.setObjectName("iirbesselcritLabel2") - self.formLayout_13.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.iirbesselcritLabel2) + self.formLayout_13.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.iirbesselcritLabel2) self.filterTypeWidget.addWidget(self.iirbesselPage) self.firhbPage = QtWidgets.QWidget() self.firhbPage.setObjectName("firhbPage") self.formLayout_14 = QtWidgets.QFormLayout(self.firhbPage) - self.formLayout_14.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_14.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_14.setObjectName("formLayout_14") self.firhbordLabel = QtWidgets.QLabel(self.firhbPage) self.firhbordLabel.setObjectName("firhbordLabel") - self.formLayout_14.setWidget(0, QtWidgets.QFormLayout.LabelRole, self.firhbordLabel) + self.formLayout_14.setWidget( + 0, QtWidgets.QFormLayout.LabelRole, self.firhbordLabel) self.firhbordEdit = QtWidgets.QLineEdit(self.firhbPage) self.firhbordEdit.setObjectName("firhbordEdit") - self.formLayout_14.setWidget(0, QtWidgets.QFormLayout.FieldRole, self.firhbordEdit) + self.formLayout_14.setWidget( + 0, QtWidgets.QFormLayout.FieldRole, self.firhbordEdit) self.firhbtrEditLabel2 = QtWidgets.QLabel(self.firhbPage) self.firhbtrEditLabel2.setObjectName("firhbtrEditLabel2") - self.formLayout_14.setWidget(2, QtWidgets.QFormLayout.LabelRole, self.firhbtrEditLabel2) + self.formLayout_14.setWidget( + 2, QtWidgets.QFormLayout.LabelRole, self.firhbtrEditLabel2) self.firhbtrEdit = QtWidgets.QLineEdit(self.firhbPage) self.firhbtrEdit.setObjectName("firhbtrEdit") - self.formLayout_14.setWidget(2, QtWidgets.QFormLayout.FieldRole, self.firhbtrEdit) + self.formLayout_14.setWidget( + 2, QtWidgets.QFormLayout.FieldRole, self.firhbtrEdit) self.filterTypeWidget.addWidget(self.firhbPage) self.verticalLayout.addWidget(self.filterTypeWidget) self.filterPropsBox = QtWidgets.QGroupBox(self.filterFrame) self.filterPropsBox.setObjectName("filterPropsBox") self.formLayout_8 = QtWidgets.QFormLayout(self.filterPropsBox) - self.formLayout_8.setFieldGrowthPolicy(QtWidgets.QFormLayout.AllNonFixedFieldsGrow) + self.formLayout_8.setFieldGrowthPolicy( + QtWidgets.QFormLayout.AllNonFixedFieldsGrow) self.formLayout_8.setObjectName("formLayout_8") self.nTapsLabel = QtWidgets.QLabel(self.filterPropsBox) self.nTapsLabel.setMinimumSize(QtCore.QSize(150, 0)) self.nTapsLabel.setObjectName("nTapsLabel") - self.formLayout_8.setWidget(1, QtWidgets.QFormLayout.LabelRole, self.nTapsLabel) + self.formLayout_8.setWidget( + 1, QtWidgets.QFormLayout.LabelRole, self.nTapsLabel) self.nTapsEdit = QtWidgets.QLabel(self.filterPropsBox) self.nTapsEdit.setMaximumSize(QtCore.QSize(100, 16777215)) self.nTapsEdit.setFrameShape(QtWidgets.QFrame.Box) self.nTapsEdit.setFrameShadow(QtWidgets.QFrame.Raised) self.nTapsEdit.setText("") self.nTapsEdit.setObjectName("nTapsEdit") - self.formLayout_8.setWidget(1, QtWidgets.QFormLayout.FieldRole, self.nTapsEdit) + self.formLayout_8.setWidget( + 1, QtWidgets.QFormLayout.FieldRole, self.nTapsEdit) self.verticalLayout.addWidget(self.filterPropsBox) self.designButton = QtWidgets.QPushButton(self.filterFrame) self.designButton.setMinimumSize(QtCore.QSize(0, 0)) @@ -1049,7 +1230,8 @@ class Ui_MainWindow(object): self.actionFilter_Coefficients = QtWidgets.QAction(MainWindow) self.actionFilter_Coefficients.setCheckable(True) self.actionFilter_Coefficients.setChecked(True) - self.actionFilter_Coefficients.setObjectName("actionFilter_Coefficients") + self.actionFilter_Coefficients.setObjectName( + "actionFilter_Coefficients") self.actionDesign_widget = QtWidgets.QAction(MainWindow) self.actionDesign_widget.setCheckable(True) self.actionDesign_widget.setChecked(True) @@ -1136,26 +1318,46 @@ class Ui_MainWindow(object): self.filterTypeWidget.setCurrentIndex(11) self.action_exit.triggered.connect(MainWindow.close) QtCore.QMetaObject.connectSlotsByName(MainWindow) - MainWindow.setTabOrder(self.filterTypeComboBox, self.filterDesignTypeComboBox) - MainWindow.setTabOrder(self.filterDesignTypeComboBox, self.endofLpfPassBandEdit) - MainWindow.setTabOrder(self.endofLpfPassBandEdit, self.startofLpfStopBandEdit) - MainWindow.setTabOrder(self.startofLpfStopBandEdit, self.lpfStopBandAttenEdit) - MainWindow.setTabOrder(self.lpfStopBandAttenEdit, self.lpfPassBandRippleEdit) - MainWindow.setTabOrder(self.lpfPassBandRippleEdit, self.startofBpfPassBandEdit) - MainWindow.setTabOrder(self.startofBpfPassBandEdit, self.endofBpfPassBandEdit) - MainWindow.setTabOrder(self.endofBpfPassBandEdit, self.bpfTransitionEdit) - MainWindow.setTabOrder(self.bpfTransitionEdit, self.bpfStopBandAttenEdit) - MainWindow.setTabOrder(self.bpfStopBandAttenEdit, self.bpfPassBandRippleEdit) - MainWindow.setTabOrder(self.bpfPassBandRippleEdit, self.startofBnfStopBandEdit) - MainWindow.setTabOrder(self.startofBnfStopBandEdit, self.endofBnfStopBandEdit) - MainWindow.setTabOrder(self.endofBnfStopBandEdit, self.bnfTransitionEdit) - MainWindow.setTabOrder(self.bnfTransitionEdit, self.bnfStopBandAttenEdit) - MainWindow.setTabOrder(self.bnfStopBandAttenEdit, self.bnfPassBandRippleEdit) - MainWindow.setTabOrder(self.bnfPassBandRippleEdit, self.endofHpfStopBandEdit) - MainWindow.setTabOrder(self.endofHpfStopBandEdit, self.startofHpfPassBandEdit) - MainWindow.setTabOrder(self.startofHpfPassBandEdit, self.hpfStopBandAttenEdit) - MainWindow.setTabOrder(self.hpfStopBandAttenEdit, self.hpfPassBandRippleEdit) - MainWindow.setTabOrder(self.hpfPassBandRippleEdit, self.rrcSymbolRateEdit) + MainWindow.setTabOrder(self.filterTypeComboBox, + self.filterDesignTypeComboBox) + MainWindow.setTabOrder( + self.filterDesignTypeComboBox, self.endofLpfPassBandEdit) + MainWindow.setTabOrder(self.endofLpfPassBandEdit, + self.startofLpfStopBandEdit) + MainWindow.setTabOrder(self.startofLpfStopBandEdit, + self.lpfStopBandAttenEdit) + MainWindow.setTabOrder(self.lpfStopBandAttenEdit, + self.lpfPassBandRippleEdit) + MainWindow.setTabOrder(self.lpfPassBandRippleEdit, + self.startofBpfPassBandEdit) + MainWindow.setTabOrder(self.startofBpfPassBandEdit, + self.endofBpfPassBandEdit) + MainWindow.setTabOrder(self.endofBpfPassBandEdit, + self.bpfTransitionEdit) + MainWindow.setTabOrder(self.bpfTransitionEdit, + self.bpfStopBandAttenEdit) + MainWindow.setTabOrder(self.bpfStopBandAttenEdit, + self.bpfPassBandRippleEdit) + MainWindow.setTabOrder(self.bpfPassBandRippleEdit, + self.startofBnfStopBandEdit) + MainWindow.setTabOrder(self.startofBnfStopBandEdit, + self.endofBnfStopBandEdit) + MainWindow.setTabOrder(self.endofBnfStopBandEdit, + self.bnfTransitionEdit) + MainWindow.setTabOrder(self.bnfTransitionEdit, + self.bnfStopBandAttenEdit) + MainWindow.setTabOrder(self.bnfStopBandAttenEdit, + self.bnfPassBandRippleEdit) + MainWindow.setTabOrder(self.bnfPassBandRippleEdit, + self.endofHpfStopBandEdit) + MainWindow.setTabOrder(self.endofHpfStopBandEdit, + self.startofHpfPassBandEdit) + MainWindow.setTabOrder(self.startofHpfPassBandEdit, + self.hpfStopBandAttenEdit) + MainWindow.setTabOrder(self.hpfStopBandAttenEdit, + self.hpfPassBandRippleEdit) + MainWindow.setTabOrder( + self.hpfPassBandRippleEdit, self.rrcSymbolRateEdit) MainWindow.setTabOrder(self.rrcSymbolRateEdit, self.rrcAlphaEdit) MainWindow.setTabOrder(self.rrcAlphaEdit, self.rrcNumTapsEdit) MainWindow.setTabOrder(self.rrcNumTapsEdit, self.gausSymbolRateEdit) @@ -1165,16 +1367,26 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): _translate = QtCore.QCoreApplication.translate - MainWindow.setWindowTitle(_translate("MainWindow", "GNU Radio Filter Design Tool")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.freqTab), _translate("MainWindow", "Magnitude Response")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.timeTab), _translate("MainWindow", "Filter Taps")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.phaseTab), _translate("MainWindow", "Phase Response")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.groupTab), _translate("MainWindow", "Group Delay")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.fcTab), _translate("MainWindow", "Filter Coefficients")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.impresTab), _translate("MainWindow", "Impulse Response")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.stepresTab), _translate("MainWindow", "Step Response")) - self.tabGroup.setTabText(self.tabGroup.indexOf(self.pdelayTab), _translate("MainWindow", "Phase Delay")) - self.filterspecView.setTabText(self.filterspecView.indexOf(self.bandDiagram), _translate("MainWindow", "Band Diagram")) + MainWindow.setWindowTitle(_translate( + "MainWindow", "GNU Radio Filter Design Tool")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.freqTab), _translate("MainWindow", "Magnitude Response")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.timeTab), _translate("MainWindow", "Filter Taps")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.phaseTab), _translate("MainWindow", "Phase Response")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.groupTab), _translate("MainWindow", "Group Delay")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.fcTab), _translate("MainWindow", "Filter Coefficients")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.impresTab), _translate("MainWindow", "Impulse Response")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.stepresTab), _translate("MainWindow", "Step Response")) + self.tabGroup.setTabText(self.tabGroup.indexOf( + self.pdelayTab), _translate("MainWindow", "Phase Delay")) + self.filterspecView.setTabText(self.filterspecView.indexOf( + self.bandDiagram), _translate("MainWindow", "Band Diagram")) self.addzeroPush.setToolTip(_translate("MainWindow", "Add zero")) self.addzeroPush.setText(_translate("MainWindow", "...")) self.addpolePush.setToolTip(_translate("MainWindow", "Add pole")) @@ -1183,23 +1395,28 @@ class Ui_MainWindow(object): self.delPush.setText(_translate("MainWindow", "...")) self.conjPush.setToolTip(_translate("MainWindow", "Conjugate")) self.conjPush.setText(_translate("MainWindow", "...")) - self.filterspecView.setTabText(self.filterspecView.indexOf(self.poleZero), _translate("MainWindow", "Pole-Zero Plot")) + self.filterspecView.setTabText(self.filterspecView.indexOf( + self.poleZero), _translate("MainWindow", "Pole-Zero Plot")) self.responseBox.setTitle(_translate("MainWindow", "Filter Responses")) - self.checkMagres.setText(_translate("MainWindow", "Magnitude Response")) + self.checkMagres.setText(_translate( + "MainWindow", "Magnitude Response")) self.checkPhase.setText(_translate("MainWindow", "Phase Response")) self.checkGdelay.setText(_translate("MainWindow", "Group Delay")) self.checkPdelay.setText(_translate("MainWindow", "Phase Delay")) self.checkImpulse.setText(_translate("MainWindow", "Impulse Response")) self.checkStep.setText(_translate("MainWindow", "Step Response")) self.checkGrid.setText(_translate("MainWindow", "Grid")) - self.checkFcoeff.setText(_translate("MainWindow", "Filter Coefficients")) - self.checkKeepcur.setText(_translate("MainWindow", "Buffer current plots")) + self.checkFcoeff.setText(_translate( + "MainWindow", "Filter Coefficients")) + self.checkKeepcur.setText(_translate( + "MainWindow", "Buffer current plots")) self.groupSpecs.setTitle(_translate("MainWindow", "Filter Specs")) self.checkBand.setText(_translate("MainWindow", "Band Diagram")) self.checkPzplot.setText(_translate("MainWindow", "Pole-Zero Plot")) self.sysParamsBox.setTitle(_translate("MainWindow", "Plot Parameter")) self.nfftLabel.setText(_translate("MainWindow", "Num FFT points")) - self.mfmagPush.setToolTip(_translate("MainWindow", "Magnitude Response")) + self.mfmagPush.setToolTip(_translate( + "MainWindow", "Magnitude Response")) self.mfmagPush.setText(_translate("MainWindow", "...")) self.mfphasePush.setToolTip(_translate("MainWindow", "Phase Response")) self.mfphasePush.setText(_translate("MainWindow", "...")) @@ -1209,15 +1426,18 @@ class Ui_MainWindow(object): self.mfphdlyPush.setText(_translate("MainWindow", "...")) self.mfoverlayPush.setToolTip(_translate("MainWindow", "Overlay")) self.mfoverlayPush.setText(_translate("MainWindow", "...")) - self.mfreqTabgroup.setTabText(self.mfreqTabgroup.indexOf(self.mfreqTab), _translate("MainWindow", "Frequency Response")) + self.mfreqTabgroup.setTabText(self.mfreqTabgroup.indexOf( + self.mfreqTab), _translate("MainWindow", "Frequency Response")) self.mttapsPush.setToolTip(_translate("MainWindow", "Filter Taps")) self.mttapsPush.setText(_translate("MainWindow", "...")) self.mtstepPush.setToolTip(_translate("MainWindow", "Step Response")) self.mtstepPush.setText(_translate("MainWindow", "...")) self.mtimpPush.setToolTip(_translate("MainWindow", "Impulse Response")) self.mtimpPush.setText(_translate("MainWindow", "...")) - self.mtimeTabgroup.setTabText(self.mtimeTabgroup.indexOf(self.mtimeTab), _translate("MainWindow", "Time responses")) - self.mfilterspecView.setTabText(self.mfilterspecView.indexOf(self.mbandDiagram), _translate("MainWindow", "Ideal Band")) + self.mtimeTabgroup.setTabText(self.mtimeTabgroup.indexOf( + self.mtimeTab), _translate("MainWindow", "Time responses")) + self.mfilterspecView.setTabText(self.mfilterspecView.indexOf( + self.mbandDiagram), _translate("MainWindow", "Ideal Band")) self.maddzeroPush.setToolTip(_translate("MainWindow", "Add zero")) self.maddzeroPush.setText(_translate("MainWindow", "...")) self.maddpolePush.setToolTip(_translate("MainWindow", "Add pole")) @@ -1226,140 +1446,216 @@ class Ui_MainWindow(object): self.mdelPush.setText(_translate("MainWindow", "...")) self.mconjPush.setToolTip(_translate("MainWindow", "Conjugate")) self.mconjPush.setText(_translate("MainWindow", "...")) - self.mfilterspecView.setTabText(self.mfilterspecView.indexOf(self.mpoleZero), _translate("MainWindow", "Pole-Zero Plot")) - self.mfilterspecView.setTabText(self.mfilterspecView.indexOf(self.mfcTab), _translate("MainWindow", "Filter Coefficients")) + self.mfilterspecView.setTabText(self.mfilterspecView.indexOf( + self.mpoleZero), _translate("MainWindow", "Pole-Zero Plot")) + self.mfilterspecView.setTabText(self.mfilterspecView.indexOf( + self.mfcTab), _translate("MainWindow", "Filter Coefficients")) self.fselectComboBox.setItemText(0, _translate("MainWindow", "FIR")) self.fselectComboBox.setItemText(1, _translate("MainWindow", "IIR")) - self.filterTypeComboBox.setItemText(0, _translate("MainWindow", "Low Pass")) - self.filterTypeComboBox.setItemText(1, _translate("MainWindow", "High Pass")) - self.filterTypeComboBox.setItemText(2, _translate("MainWindow", "Band Pass")) - self.filterTypeComboBox.setItemText(3, _translate("MainWindow", "Complex Band Pass")) - self.filterTypeComboBox.setItemText(4, _translate("MainWindow", "Band Notch")) - self.filterTypeComboBox.setItemText(5, _translate("MainWindow", "Root Raised Cosine")) - self.filterTypeComboBox.setItemText(6, _translate("MainWindow", "Gaussian")) - self.filterTypeComboBox.setItemText(7, _translate("MainWindow", "Half Band")) - self.iirfilterBandComboBox.setItemText(0, _translate("MainWindow", "Low Pass")) - self.iirfilterBandComboBox.setItemText(1, _translate("MainWindow", "Band Pass")) - self.iirfilterBandComboBox.setItemText(2, _translate("MainWindow", "Band Stop")) - self.iirfilterBandComboBox.setItemText(3, _translate("MainWindow", "High Pass")) - self.adComboBox.setItemText(0, _translate("MainWindow", "Digital (normalized 0-1)")) - self.adComboBox.setItemText(1, _translate("MainWindow", "Analog (rad/second)")) - self.filterDesignTypeComboBox.setItemText(0, _translate("MainWindow", "Hamming Window")) - self.filterDesignTypeComboBox.setItemText(1, _translate("MainWindow", "Hann Window")) - self.filterDesignTypeComboBox.setItemText(2, _translate("MainWindow", "Blackman Window")) - self.filterDesignTypeComboBox.setItemText(3, _translate("MainWindow", "Rectangular Window")) - self.filterDesignTypeComboBox.setItemText(4, _translate("MainWindow", "Kaiser Window")) - self.filterDesignTypeComboBox.setItemText(5, _translate("MainWindow", "Blackman-harris Window")) - self.filterDesignTypeComboBox.setItemText(6, _translate("MainWindow", "Equiripple")) - self.iirfilterTypeComboBox.setItemText(0, _translate("MainWindow", "Elliptic")) - self.iirfilterTypeComboBox.setItemText(1, _translate("MainWindow", "Butterworth")) - self.iirfilterTypeComboBox.setItemText(2, _translate("MainWindow", "Chebyshev-1")) - self.iirfilterTypeComboBox.setItemText(3, _translate("MainWindow", "Chebyshev-2")) - self.iirfilterTypeComboBox.setItemText(4, _translate("MainWindow", "Bessel")) - self.sampleRateLabel.setText(_translate("MainWindow", "Sample Rate (sps)")) + self.filterTypeComboBox.setItemText( + 0, _translate("MainWindow", "Low Pass")) + self.filterTypeComboBox.setItemText( + 1, _translate("MainWindow", "High Pass")) + self.filterTypeComboBox.setItemText( + 2, _translate("MainWindow", "Band Pass")) + self.filterTypeComboBox.setItemText( + 3, _translate("MainWindow", "Complex Band Pass")) + self.filterTypeComboBox.setItemText( + 4, _translate("MainWindow", "Band Notch")) + self.filterTypeComboBox.setItemText( + 5, _translate("MainWindow", "Root Raised Cosine")) + self.filterTypeComboBox.setItemText( + 6, _translate("MainWindow", "Gaussian")) + self.filterTypeComboBox.setItemText( + 7, _translate("MainWindow", "Half Band")) + self.iirfilterBandComboBox.setItemText( + 0, _translate("MainWindow", "Low Pass")) + self.iirfilterBandComboBox.setItemText( + 1, _translate("MainWindow", "Band Pass")) + self.iirfilterBandComboBox.setItemText( + 2, _translate("MainWindow", "Band Stop")) + self.iirfilterBandComboBox.setItemText( + 3, _translate("MainWindow", "High Pass")) + self.adComboBox.setItemText(0, _translate( + "MainWindow", "Digital (normalized 0-1)")) + self.adComboBox.setItemText(1, _translate( + "MainWindow", "Analog (rad/second)")) + self.filterDesignTypeComboBox.setItemText( + 0, _translate("MainWindow", "Hamming Window")) + self.filterDesignTypeComboBox.setItemText( + 1, _translate("MainWindow", "Hann Window")) + self.filterDesignTypeComboBox.setItemText( + 2, _translate("MainWindow", "Blackman Window")) + self.filterDesignTypeComboBox.setItemText( + 3, _translate("MainWindow", "Rectangular Window")) + self.filterDesignTypeComboBox.setItemText( + 4, _translate("MainWindow", "Kaiser Window")) + self.filterDesignTypeComboBox.setItemText( + 5, _translate("MainWindow", "Blackman-harris Window")) + self.filterDesignTypeComboBox.setItemText( + 6, _translate("MainWindow", "Equiripple")) + self.iirfilterTypeComboBox.setItemText( + 0, _translate("MainWindow", "Elliptic")) + self.iirfilterTypeComboBox.setItemText( + 1, _translate("MainWindow", "Butterworth")) + self.iirfilterTypeComboBox.setItemText( + 2, _translate("MainWindow", "Chebyshev-1")) + self.iirfilterTypeComboBox.setItemText( + 3, _translate("MainWindow", "Chebyshev-2")) + self.iirfilterTypeComboBox.setItemText( + 4, _translate("MainWindow", "Bessel")) + self.sampleRateLabel.setText( + _translate("MainWindow", "Sample Rate (sps)")) self.sampleRateEdit.setText(_translate("MainWindow", "320000")) self.filterGainLabel.setText(_translate("MainWindow", "Filter Gain")) self.filterGainEdit.setText(_translate("MainWindow", "2")) - self.endofLpfPassBandLabel.setText(_translate("MainWindow", "End of Pass Band (Hz)")) + self.endofLpfPassBandLabel.setText( + _translate("MainWindow", "End of Pass Band (Hz)")) self.endofLpfPassBandEdit.setText(_translate("MainWindow", "50000")) - self.startofLpfStopBandLabel.setText(_translate("MainWindow", "Start of Stop Band (Hz)")) + self.startofLpfStopBandLabel.setText( + _translate("MainWindow", "Start of Stop Band (Hz)")) self.startofLpfStopBandEdit.setText(_translate("MainWindow", "60000")) - self.lpfStopBandAttenLabel.setText(_translate("MainWindow", "Stop Band Attenuation (dB)")) + self.lpfStopBandAttenLabel.setText(_translate( + "MainWindow", "Stop Band Attenuation (dB)")) self.lpfStopBandAttenEdit.setText(_translate("MainWindow", "40")) - self.lpfPassBandRippleLabel.setText(_translate("MainWindow", "Pass Band Ripple (dB)")) + self.lpfPassBandRippleLabel.setText( + _translate("MainWindow", "Pass Band Ripple (dB)")) self.lpfPassBandRippleEdit.setText(_translate("MainWindow", "1")) - self.startofBpfPassBandLabel.setText(_translate("MainWindow", "Start of Pass Band (Hz)")) + self.startofBpfPassBandLabel.setText( + _translate("MainWindow", "Start of Pass Band (Hz)")) self.startofBpfPassBandEdit.setText(_translate("MainWindow", "50000")) - self.endofBpfPassBandLabel.setText(_translate("MainWindow", "End of Pass Band (Hz)")) + self.endofBpfPassBandLabel.setText( + _translate("MainWindow", "End of Pass Band (Hz)")) self.endofBpfPassBandEdit.setText(_translate("MainWindow", "80000")) self.bpfStopBandAttenEdit.setText(_translate("MainWindow", "40")) - self.bpfStopBandAttenLabel.setText(_translate("MainWindow", "Stop Band Attenuation (dB)")) - self.bpfTransitionLabel.setText(_translate("MainWindow", "Transition Width (Hz)")) + self.bpfStopBandAttenLabel.setText(_translate( + "MainWindow", "Stop Band Attenuation (dB)")) + self.bpfTransitionLabel.setText(_translate( + "MainWindow", "Transition Width (Hz)")) self.bpfTransitionEdit.setText(_translate("MainWindow", "10000")) self.bpfPassBandRippleEdit.setText(_translate("MainWindow", "1")) - self.bpfPassBandRippleLabel.setText(_translate("MainWindow", "Pass Band Ripple (dB)")) - self.startofBnfStopBandLabel.setText(_translate("MainWindow", "Start of Stop Band (Hz)")) + self.bpfPassBandRippleLabel.setText( + _translate("MainWindow", "Pass Band Ripple (dB)")) + self.startofBnfStopBandLabel.setText( + _translate("MainWindow", "Start of Stop Band (Hz)")) self.startofBnfStopBandEdit.setText(_translate("MainWindow", "50000")) - self.endofBnfStopBandLabel.setText(_translate("MainWindow", "End of Stop Band (Hz)")) + self.endofBnfStopBandLabel.setText( + _translate("MainWindow", "End of Stop Band (Hz)")) self.endofBnfStopBandEdit.setText(_translate("MainWindow", "80000")) - self.bnfTransitionLabel.setText(_translate("MainWindow", "Transition Width (Hz)")) + self.bnfTransitionLabel.setText(_translate( + "MainWindow", "Transition Width (Hz)")) self.bnfTransitionEdit.setText(_translate("MainWindow", "10000")) - self.bnfStopBandAttenLabel.setText(_translate("MainWindow", "Stop Band Attenuation (dB)")) + self.bnfStopBandAttenLabel.setText(_translate( + "MainWindow", "Stop Band Attenuation (dB)")) self.bnfStopBandAttenEdit.setText(_translate("MainWindow", "48")) - self.bnfPassBandRippleLabel.setText(_translate("MainWindow", "Pass Band Ripple (dB)")) + self.bnfPassBandRippleLabel.setText( + _translate("MainWindow", "Pass Band Ripple (dB)")) self.bnfPassBandRippleEdit.setText(_translate("MainWindow", "1")) - self.endofHpfStopBandLabel.setText(_translate("MainWindow", "End of Stop Band (Hz)")) + self.endofHpfStopBandLabel.setText( + _translate("MainWindow", "End of Stop Band (Hz)")) self.endofHpfStopBandEdit.setText(_translate("MainWindow", "50000")) - self.startofHpfPassBandLabel.setText(_translate("MainWindow", "Start of Pass Band (Hz)")) + self.startofHpfPassBandLabel.setText( + _translate("MainWindow", "Start of Pass Band (Hz)")) self.startofHpfPassBandEdit.setText(_translate("MainWindow", "55000")) - self.hpfStopBandAttenLabel.setText(_translate("MainWindow", "Stop Band Attenuation (dB)")) + self.hpfStopBandAttenLabel.setText(_translate( + "MainWindow", "Stop Band Attenuation (dB)")) self.hpfStopBandAttenEdit.setText(_translate("MainWindow", "48")) - self.hpfPassBandRippleLabel.setText(_translate("MainWindow", "Pass Band Ripple (dB)")) + self.hpfPassBandRippleLabel.setText( + _translate("MainWindow", "Pass Band Ripple (dB)")) self.hpfPassBandRippleEdit.setText(_translate("MainWindow", "1")) - self.rrcSymbolRateLabel.setText(_translate("MainWindow", "Symbol Rate (sps)")) + self.rrcSymbolRateLabel.setText( + _translate("MainWindow", "Symbol Rate (sps)")) self.rrcAlphaLabel.setText(_translate("MainWindow", "Roll-off Factor")) - self.rrcNumTapsLabel.setText(_translate("MainWindow", "Number of Taps")) + self.rrcNumTapsLabel.setText( + _translate("MainWindow", "Number of Taps")) self.rrcSymbolRateEdit.setText(_translate("MainWindow", "3200")) self.rrcAlphaEdit.setText(_translate("MainWindow", "15")) self.rrcNumTapsEdit.setText(_translate("MainWindow", "50")) - self.gausSymbolRateLabel.setText(_translate("MainWindow", "Symbol Rate (sps)")) + self.gausSymbolRateLabel.setText( + _translate("MainWindow", "Symbol Rate (sps)")) self.gausSymbolRateEdit.setText(_translate("MainWindow", "5000")) self.gausBTLabel.setText(_translate("MainWindow", "Roll-off Factor")) self.gausBTEdit.setText(_translate("MainWindow", "0.5")) - self.gausNumTapsLabel.setText(_translate("MainWindow", "Number of Taps")) + self.gausNumTapsLabel.setText( + _translate("MainWindow", "Number of Taps")) self.gausNumTapsEdit.setText(_translate("MainWindow", "30")) - self.iirendofLpfPassBandLabel.setText(_translate("MainWindow", "End of Pass Band")) + self.iirendofLpfPassBandLabel.setText( + _translate("MainWindow", "End of Pass Band")) self.iirendofLpfPassBandEdit.setText(_translate("MainWindow", "0.3")) - self.iirstartofLpfStopBandLabel.setText(_translate("MainWindow", "Start of Stop Band ")) + self.iirstartofLpfStopBandLabel.setText( + _translate("MainWindow", "Start of Stop Band ")) self.iirstartofLpfStopBandEdit.setText(_translate("MainWindow", "0.5")) - self.iirLpfPassBandAttenLabel.setText(_translate("MainWindow", "Max loss in Pass Band (dB)")) + self.iirLpfPassBandAttenLabel.setText( + _translate("MainWindow", "Max loss in Pass Band (dB)")) self.iirLpfPassBandAttenEdit.setText(_translate("MainWindow", "1")) - self.iirLpfStopBandRippleLabel.setText(_translate("MainWindow", "Min atten in Stop Band (dB)")) + self.iirLpfStopBandRippleLabel.setText( + _translate("MainWindow", "Min atten in Stop Band (dB)")) self.iirLpfStopBandRippleEdit.setText(_translate("MainWindow", "60")) - self.iirendofHpfStopBandLabel.setText(_translate("MainWindow", "End of Stop Band")) + self.iirendofHpfStopBandLabel.setText( + _translate("MainWindow", "End of Stop Band")) self.iirendofHpfStopBandEdit.setText(_translate("MainWindow", "0.3")) - self.iirstartofHpfPassBandLabel.setText(_translate("MainWindow", "Start of Pass Band ")) + self.iirstartofHpfPassBandLabel.setText( + _translate("MainWindow", "Start of Pass Band ")) self.iirstartofHpfPassBandEdit.setText(_translate("MainWindow", "0.5")) - self.iirHpfPassBandAttenLabel.setText(_translate("MainWindow", "Max loss in Pass Band (dB)")) + self.iirHpfPassBandAttenLabel.setText( + _translate("MainWindow", "Max loss in Pass Band (dB)")) self.iirHpfPassBandAttenEdit.setText(_translate("MainWindow", "1")) - self.iirHpfStopBandRippleLabel.setText(_translate("MainWindow", "Min atten in Stop Band (dB)")) + self.iirHpfStopBandRippleLabel.setText( + _translate("MainWindow", "Min atten in Stop Band (dB)")) self.iirHpfStopBandRippleEdit.setText(_translate("MainWindow", "60")) - self.iirendofBpfStopBandLabel1.setText(_translate("MainWindow", "End of Stop Band-1")) + self.iirendofBpfStopBandLabel1.setText( + _translate("MainWindow", "End of Stop Band-1")) self.iirendofBpfStopBandEdit1.setText(_translate("MainWindow", "0.2")) - self.iirstartofBpfPassBandLabel.setText(_translate("MainWindow", "Start of Pass Band ")) + self.iirstartofBpfPassBandLabel.setText( + _translate("MainWindow", "Start of Pass Band ")) self.iirstartofBpfPassBandEdit.setText(_translate("MainWindow", "0.3")) - self.iirendofBpfPassBandLabel.setText(_translate("MainWindow", "End of Pass Band ")) + self.iirendofBpfPassBandLabel.setText( + _translate("MainWindow", "End of Pass Band ")) self.iirendofBpfPassBandEdit.setText(_translate("MainWindow", "0.5")) - self.iirstartofBpfStopBandLabel2.setText(_translate("MainWindow", "Start of Stop Band-2")) - self.iirstartofBpfStopBandEdit2.setText(_translate("MainWindow", "0.6")) - self.iirBpfPassBandAttenLabel.setText(_translate("MainWindow", "Max loss in Pass Band (dB)")) + self.iirstartofBpfStopBandLabel2.setText( + _translate("MainWindow", "Start of Stop Band-2")) + self.iirstartofBpfStopBandEdit2.setText( + _translate("MainWindow", "0.6")) + self.iirBpfPassBandAttenLabel.setText( + _translate("MainWindow", "Max loss in Pass Band (dB)")) self.iirBpfPassBandAttenEdit.setText(_translate("MainWindow", "1")) - self.iirBpfStopBandRippleLabel.setText(_translate("MainWindow", "Min atten in Stop Band (dB)")) + self.iirBpfStopBandRippleLabel.setText( + _translate("MainWindow", "Min atten in Stop Band (dB)")) self.iirBpfStopBandRippleEdit.setText(_translate("MainWindow", "60")) - self.iirendofBsfPassBandLabel1.setText(_translate("MainWindow", "End of Pass Band-1")) + self.iirendofBsfPassBandLabel1.setText( + _translate("MainWindow", "End of Pass Band-1")) self.iirendofBsfPassBandEdit1.setText(_translate("MainWindow", "0.2")) - self.iirstartofBsfStopBandLabel.setText(_translate("MainWindow", "Start of Stop Band ")) + self.iirstartofBsfStopBandLabel.setText( + _translate("MainWindow", "Start of Stop Band ")) self.iirstartofBsfStopBandEdit.setText(_translate("MainWindow", "0.3")) - self.iirendofBsfStopBandLabel.setText(_translate("MainWindow", "End of Stop Band ")) + self.iirendofBsfStopBandLabel.setText( + _translate("MainWindow", "End of Stop Band ")) self.iirendofBsfStopBandEdit.setText(_translate("MainWindow", "0.6")) - self.iirstartofBsfPassBandLabel2.setText(_translate("MainWindow", "Start of Pass Band-2")) - self.iirstartofBsfPassBandEdit2.setText(_translate("MainWindow", "0.7")) - self.iirBsfPassBandAttenLabel.setText(_translate("MainWindow", "Max loss in Pass Band (dB)")) + self.iirstartofBsfPassBandLabel2.setText( + _translate("MainWindow", "Start of Pass Band-2")) + self.iirstartofBsfPassBandEdit2.setText( + _translate("MainWindow", "0.7")) + self.iirBsfPassBandAttenLabel.setText( + _translate("MainWindow", "Max loss in Pass Band (dB)")) self.iirBsfPassBandAttenEdit.setText(_translate("MainWindow", "1")) - self.iirBsfStopBandRippleLabel.setText(_translate("MainWindow", "Min atten in Stop Band (dB)")) + self.iirBsfStopBandRippleLabel.setText( + _translate("MainWindow", "Min atten in Stop Band (dB)")) self.iirBsfStopBandRippleEdit.setText(_translate("MainWindow", "60")) self.besselordLabel.setText(_translate("MainWindow", "Filter Order")) self.besselordEdit.setText(_translate("MainWindow", "10")) - self.iirbesselcritLabel1.setText(_translate("MainWindow", "Critical point-1")) + self.iirbesselcritLabel1.setText( + _translate("MainWindow", "Critical point-1")) self.iirbesselcritEdit1.setText(_translate("MainWindow", "0.2")) self.iirbesselcritEdit2.setText(_translate("MainWindow", "0.5")) - self.iirbesselcritLabel2.setText(_translate("MainWindow", "Critical point-2")) + self.iirbesselcritLabel2.setText( + _translate("MainWindow", "Critical point-2")) self.firhbordLabel.setText(_translate("MainWindow", "Filter Order")) self.firhbordEdit.setText(_translate("MainWindow", "34")) self.firhbtrEditLabel2.setText(_translate("MainWindow", "Transition width\n" -" (from fs/4)")) + " (from fs/4)")) self.firhbtrEdit.setText(_translate("MainWindow", "10000")) - self.filterPropsBox.setTitle(_translate("MainWindow", "Filter Properties")) + self.filterPropsBox.setTitle( + _translate("MainWindow", "Filter Properties")) self.nTapsLabel.setText(_translate("MainWindow", "Number of Taps:")) self.designButton.setText(_translate("MainWindow", "Design")) self.menu_File.setTitle(_translate("MainWindow", "&File")) @@ -1370,42 +1666,60 @@ class Ui_MainWindow(object): self.action_save.setShortcut(_translate("MainWindow", "Ctrl+S")) self.action_open.setText(_translate("MainWindow", "&Open")) self.action_open.setShortcut(_translate("MainWindow", "Ctrl+O")) - self.actionMagnitude_Response.setText(_translate("MainWindow", "&Magnitude Response")) - self.actionPhase_Respone.setText(_translate("MainWindow", "&Phase Respone")) - self.actionGroup_Delay.setText(_translate("MainWindow", "&Group Delay")) - self.actionPhase_Delay.setText(_translate("MainWindow", "P&hase Delay")) - self.actionImpulse_Response.setText(_translate("MainWindow", "&Impulse Response")) - self.actionStep_Response.setText(_translate("MainWindow", "&Step Response")) - self.actionPole_Zero_Plot.setText(_translate("MainWindow", "Pole-Zero Plot")) + self.actionMagnitude_Response.setText( + _translate("MainWindow", "&Magnitude Response")) + self.actionPhase_Respone.setText( + _translate("MainWindow", "&Phase Respone")) + self.actionGroup_Delay.setText( + _translate("MainWindow", "&Group Delay")) + self.actionPhase_Delay.setText( + _translate("MainWindow", "P&hase Delay")) + self.actionImpulse_Response.setText( + _translate("MainWindow", "&Impulse Response")) + self.actionStep_Response.setText( + _translate("MainWindow", "&Step Response")) + self.actionPole_Zero_Plot.setText( + _translate("MainWindow", "Pole-Zero Plot")) self.actionGrid.setText(_translate("MainWindow", "Grid")) - self.actionPole_Zero_Plot_2.setText(_translate("MainWindow", "Pole &Zero Plot")) + self.actionPole_Zero_Plot_2.setText( + _translate("MainWindow", "Pole &Zero Plot")) self.actionIdeal_Band.setText(_translate("MainWindow", "Id&eal Band")) self.actionGrid_2.setText(_translate("MainWindow", "Grid")) self.actionGrid_3.setText(_translate("MainWindow", "Grid")) self.actionTabbed.setText(_translate("MainWindow", "Tabbed")) self.actionOverlay.setText(_translate("MainWindow", "Overlay")) - self.actionResponse_widget.setText(_translate("MainWindow", "Response widget")) + self.actionResponse_widget.setText( + _translate("MainWindow", "Response widget")) self.actionSpec_widget.setText(_translate("MainWindow", "Spec widget")) - self.actionQuick_access.setText(_translate("MainWindow", "Quick access")) - self.actionFilter_Coefficients.setText(_translate("MainWindow", "&Filter Coefficients")) - self.actionDesign_widget.setText(_translate("MainWindow", "Design widget")) + self.actionQuick_access.setText( + _translate("MainWindow", "Quick access")) + self.actionFilter_Coefficients.setText( + _translate("MainWindow", "&Filter Coefficients")) + self.actionDesign_widget.setText( + _translate("MainWindow", "Design widget")) self.actionOverlay_2.setText(_translate("MainWindow", "Overlay")) self.actionGridview.setText(_translate("MainWindow", "&Gridview")) - self.actionDesign_widget_2.setText(_translate("MainWindow", "Design widget")) - self.actionQuick_access_2.setText(_translate("MainWindow", "Quick access")) - self.actionSpec_widget_2.setText(_translate("MainWindow", "Spec widget")) - self.actionResponse_widget_2.setText(_translate("MainWindow", "Response widget")) - self.actionDesign_Widget.setText(_translate("MainWindow", "&Design Widget")) - self.actionQuick_Access.setText(_translate("MainWindow", "&Quick Access")) - self.actionSpec_Widget.setText(_translate("MainWindow", "Spec &Widget")) - self.actionResponse_Widget.setText(_translate("MainWindow", "&Response Widget")) + self.actionDesign_widget_2.setText( + _translate("MainWindow", "Design widget")) + self.actionQuick_access_2.setText( + _translate("MainWindow", "Quick access")) + self.actionSpec_widget_2.setText( + _translate("MainWindow", "Spec widget")) + self.actionResponse_widget_2.setText( + _translate("MainWindow", "Response widget")) + self.actionDesign_Widget.setText( + _translate("MainWindow", "&Design Widget")) + self.actionQuick_Access.setText( + _translate("MainWindow", "&Quick Access")) + self.actionSpec_Widget.setText( + _translate("MainWindow", "Spec &Widget")) + self.actionResponse_Widget.setText( + _translate("MainWindow", "&Response Widget")) self.actionTabview_2.setText(_translate("MainWindow", "Tabview")) - self.actionPlot_select.setText(_translate("MainWindow", "&Plot select")) - self.actionBand_Diagram.setText(_translate("MainWindow", "&Band Diagram")) + self.actionPlot_select.setText( + _translate("MainWindow", "&Plot select")) + self.actionBand_Diagram.setText( + _translate("MainWindow", "&Band Diagram")) self.actionCheck.setText(_translate("MainWindow", "check")) - self.actionPlot_FFT_points.setText(_translate("MainWindow", "Plot FFT points")) - -from .GrFilterPlotWidget import GrFilterPlotWidget -from .bandgraphicsview import BandGraphicsView -from .polezero_plot import PzPlot -from . import icons_rc + self.actionPlot_FFT_points.setText( + _translate("MainWindow", "Plot FFT points")) diff --git a/gr-filter/python/filter/optfir.py b/gr-filter/python/filter/optfir.py index 1e6ac5b544..21fa53bc48 100644 --- a/gr-filter/python/filter/optfir.py +++ b/gr-filter/python/filter/optfir.py @@ -16,14 +16,15 @@ and Barrie W. Jervis, Adison-Wesley, 1993. ISBN 0-201-54413-X. ''' - -import math, cmath +import math +import cmath from . import filter_python as filter # ---------------------------------------------------------------- -def low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, - nextra_taps=2): + +def low_pass(gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, + nextra_taps=2): """ Builds a low pass filter. @@ -36,18 +37,19 @@ def low_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) nextra_taps: Extra taps to use in the filter (default=2) """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) + passband_dev = passband_ripple_to_dev(passband_ripple_db) + stopband_dev = stopband_atten_to_dev(stopband_atten_db) desired_ampls = (gain, 0) - (n, fo, ao, w) = remezord ([freq1, freq2], desired_ampls, - [passband_dev, stopband_dev], Fs) + (n, fo, ao, w) = remezord([freq1, freq2], desired_ampls, + [passband_dev, stopband_dev], Fs) # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = filter.pm_remez (n + nextra_taps, fo, ao, w, "bandpass") + taps = filter.pm_remez(n + nextra_taps, fo, ao, w, "bandpass") return taps -def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): + +def band_pass(gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, + passband_ripple_db, stopband_atten_db, + nextra_taps=2): """ Builds a band pass filter. @@ -62,20 +64,21 @@ def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) nextra_taps: Extra taps to use in the filter (default=2) """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) + passband_dev = passband_ripple_to_dev(passband_ripple_db) + stopband_dev = stopband_atten_to_dev(stopband_atten_db) desired_ampls = (0, gain, 0) desired_freqs = [freq_sb1, freq_pb1, freq_pb2, freq_sb2] desired_ripple = [stopband_dev, passband_dev, stopband_dev] - (n, fo, ao, w) = remezord (desired_freqs, desired_ampls, - desired_ripple, Fs) + (n, fo, ao, w) = remezord(desired_freqs, desired_ampls, + desired_ripple, Fs) # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = filter.pm_remez (n + nextra_taps, fo, ao, w, "bandpass") + taps = filter.pm_remez(n + nextra_taps, fo, ao, w, "bandpass") return taps -def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): + +def complex_band_pass(gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, + passband_ripple_db, stopband_atten_db, + nextra_taps=2): """ Builds a band pass filter with complex taps by making an LPF and spinning it up to the right center frequency @@ -96,13 +99,15 @@ def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2, lp_sb = freq_sb2 - center_freq lptaps = low_pass(gain, Fs, lp_pb, lp_sb, passband_ripple_db, stopband_atten_db, nextra_taps) - spinner = [cmath.exp(2j*cmath.pi*center_freq/Fs*i) for i in range(len(lptaps))] - taps = [s*t for s,t in zip(spinner, lptaps)] + spinner = [cmath.exp(2j * cmath.pi * center_freq / Fs * i) + for i in range(len(lptaps))] + taps = [s * t for s, t in zip(spinner, lptaps)] return taps -def complex_band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): + +def complex_band_reject(gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, + passband_ripple_db, stopband_atten_db, + nextra_taps=2): """ Builds a band reject filter with complex taps by making an HPF and spinning it up to the right center frequency @@ -122,14 +127,16 @@ def complex_band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, hp_pb = (freq_pb2 - center_freq) / 1.0 hp_sb = freq_sb2 - center_freq hptaps = high_pass(gain, Fs, hp_sb, hp_pb, passband_ripple_db, - stopband_atten_db, nextra_taps) - spinner = [cmath.exp(2j*cmath.pi*center_freq/Fs*i) for i in range(len(hptaps))] - taps = [s*t for s,t in zip(spinner, hptaps)] + stopband_atten_db, nextra_taps) + spinner = [cmath.exp(2j * cmath.pi * center_freq / Fs * i) + for i in range(len(hptaps))] + taps = [s * t for s, t in zip(spinner, hptaps)] return taps -def band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, - passband_ripple_db, stopband_atten_db, - nextra_taps=2): + +def band_reject(gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, + passband_ripple_db, stopband_atten_db, + nextra_taps=2): """ Builds a band reject filter spinning it up to the right center frequency @@ -145,23 +152,23 @@ def band_reject (gain, Fs, freq_pb1, freq_sb1, freq_sb2, freq_pb2, stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) nextra_taps: Extra taps to use in the filter (default=2) """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) + passband_dev = passband_ripple_to_dev(passband_ripple_db) + stopband_dev = stopband_atten_to_dev(stopband_atten_db) desired_ampls = (gain, 0, gain) desired_freqs = [freq_pb1, freq_sb1, freq_sb2, freq_pb2] desired_ripple = [passband_dev, stopband_dev, passband_dev] - (n, fo, ao, w) = remezord (desired_freqs, desired_ampls, - desired_ripple, Fs) + (n, fo, ao, w) = remezord(desired_freqs, desired_ampls, + desired_ripple, Fs) # Make sure we use an odd number of taps - if((n+nextra_taps)%2 == 1): + if((n + nextra_taps) % 2 == 1): n += 1 # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = filter.pm_remez (n + nextra_taps, fo, ao, w, "bandpass") + taps = filter.pm_remez(n + nextra_taps, fo, ao, w, "bandpass") return taps -def high_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, - nextra_taps=2): +def high_pass(gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, + nextra_taps=2): """ Builds a high pass filter. @@ -174,33 +181,36 @@ def high_pass (gain, Fs, freq1, freq2, passband_ripple_db, stopband_atten_db, stopband_atten_db: Stop band attenuation in dB (should be large, >= 60) nextra_taps: Extra taps to use in the filter (default=2) """ - passband_dev = passband_ripple_to_dev (passband_ripple_db) - stopband_dev = stopband_atten_to_dev (stopband_atten_db) + passband_dev = passband_ripple_to_dev(passband_ripple_db) + stopband_dev = stopband_atten_to_dev(stopband_atten_db) desired_ampls = (0, 1) - (n, fo, ao, w) = remezord ([freq1, freq2], desired_ampls, - [stopband_dev, passband_dev], Fs) + (n, fo, ao, w) = remezord([freq1, freq2], desired_ampls, + [stopband_dev, passband_dev], Fs) # For a HPF, we need to use an odd number of taps # In filter.remez, ntaps = n+1, so n must be even - if((n+nextra_taps)%2 == 1): + if((n + nextra_taps) % 2 == 1): n += 1 # The remezord typically under-estimates the filter order, so add 2 taps by default - taps = filter.pm_remez (n + nextra_taps, fo, ao, w, "bandpass") + taps = filter.pm_remez(n + nextra_taps, fo, ao, w, "bandpass") return taps # ---------------------------------------------------------------- -def stopband_atten_to_dev (atten_db): + +def stopband_atten_to_dev(atten_db): """Convert a stopband attenuation in dB to an absolute value""" return 10**(-atten_db / 20) -def passband_ripple_to_dev (ripple_db): + +def passband_ripple_to_dev(ripple_db): """Convert passband ripple spec expressed in dB to an absolute value""" - return (10**(ripple_db / 20)-1)/(10**(ripple_db / 20)+1) + return (10**(ripple_db / 20) - 1) / (10**(ripple_db / 20) + 1) # ---------------------------------------------------------------- -def remezord (fcuts, mags, devs, fsamp = 2): + +def remezord(fcuts, mags, devs, fsamp=2): ''' FIR order estimator (lowpass, highpass, bandpass, mulitiband). @@ -244,12 +254,12 @@ def remezord (fcuts, mags, devs, fsamp = 2): mags = mags[:] devs = devs[:] - for i in range (len (fcuts)): - fcuts[i] = float (fcuts[i]) / fsamp + for i in range(len(fcuts)): + fcuts[i] = float(fcuts[i]) / fsamp - nf = len (fcuts) - nm = len (mags) - nd = len (devs) + nf = len(fcuts) + nm = len(mags) + nd = len(devs) nbands = nm if nm != nd: @@ -258,7 +268,7 @@ def remezord (fcuts, mags, devs, fsamp = 2): if nf != 2 * (nbands - 1): raise ValueError("Length of f must be 2 * len (mags) - 2") - for i in range (len (mags)): + for i in range(len(mags)): if mags[i] != 0: # if not stopband, get relative deviation devs[i] = devs[i] / mags[i] @@ -268,45 +278,46 @@ def remezord (fcuts, mags, devs, fsamp = 2): n = 0 min_delta = 2 - for i in range (len (f1)): + for i in range(len(f1)): if f2[i] - f1[i] < min_delta: n = i min_delta = f2[i] - f1[i] if nbands == 2: # lowpass or highpass case (use formula) - l = lporder (f1[n], f2[n], devs[0], devs[1]) + l = lporder(f1[n], f2[n], devs[0], devs[1]) else: # bandpass or multipass case # try different lowpasses and take the worst one that # goes through the BP specs l = 0 - for i in range (1, nbands-1): - l1 = lporder (f1[i-1], f2[i-1], devs[i], devs[i-1]) - l2 = lporder (f1[i], f2[i], devs[i], devs[i+1]) - l = max (l, l1, l2) + for i in range(1, nbands - 1): + l1 = lporder(f1[i - 1], f2[i - 1], devs[i], devs[i - 1]) + l2 = lporder(f1[i], f2[i], devs[i], devs[i + 1]) + l = max(l, l1, l2) - n = int (math.ceil (l)) - 1 # need order, not length for remez + n = int(math.ceil(l)) - 1 # need order, not length for remez # cook up remez compatible result ff = [0] + fcuts + [1] - for i in range (1, len (ff) - 1): + for i in range(1, len(ff) - 1): ff[i] *= 2 aa = [] for a in mags: aa = aa + [a, a] - max_dev = max (devs) + max_dev = max(devs) wts = [1] * len(devs) - for i in range (len (wts)): + for i in range(len(wts)): wts[i] = max_dev / devs[i] return (n, ff, aa, wts) # ---------------------------------------------------------------- -def lporder (freq1, freq2, delta_p, delta_s): + +def lporder(freq1, freq2, delta_p, delta_s): ''' FIR lowpass filter length estimator. freq1 and freq2 are normalized to the sampling frequency. delta_p is the passband @@ -318,9 +329,9 @@ def lporder (freq1, freq2, delta_p, delta_s): From Herrmann et al (1973), Practical design rules for optimum finite impulse response filters. Bell System Technical J., 52, 769-99 ''' - df = abs (freq2 - freq1) - ddp = math.log10 (delta_p) - dds = math.log10 (delta_s) + df = abs(freq2 - freq1) + ddp = math.log10(delta_p) + dds = math.log10(delta_s) a1 = 5.309e-3 a2 = 7.114e-2 @@ -337,13 +348,13 @@ def lporder (freq1, freq2, delta_p, delta_s): t3 = a4 * ddp * ddp t4 = a5 * ddp - dinf=((t1 + t2 + a3) * dds) + (t3 + t4 + a6) + dinf = ((t1 + t2 + a3) * dds) + (t3 + t4 + a6) ff = b1 + b2 * (ddp - dds) n = dinf / df - ff * df + 1 return n -def bporder (freq1, freq2, delta_p, delta_s): +def bporder(freq1, freq2, delta_p, delta_s): ''' FIR bandpass filter length estimator. freq1 and freq2 are normalized to the sampling frequency. delta_p is the passband @@ -351,9 +362,9 @@ def bporder (freq1, freq2, delta_p, delta_s): From Mintzer and Liu (1979) ''' - df = abs (freq2 - freq1) - ddp = math.log10 (delta_p) - dds = math.log10 (delta_s) + df = abs(freq2 - freq1) + ddp = math.log10(delta_p) + dds = math.log10(delta_s) a1 = 0.01201 a2 = 0.09664 @@ -368,6 +379,6 @@ def bporder (freq1, freq2, delta_p, delta_s): t4 = a5 * ddp cinf = dds * (t1 + t2 + a3) + t3 + t4 + a6 - ginf = -14.6 * math.log10 (delta_p / delta_s) - 16.9 + ginf = -14.6 * math.log10(delta_p / delta_s) - 16.9 n = cinf / df + ginf * df + 1 return n diff --git a/gr-filter/python/filter/pfb.py b/gr-filter/python/filter/pfb.py index ce8c3afae0..838883e016 100644 --- a/gr-filter/python/filter/pfb.py +++ b/gr-filter/python/filter/pfb.py @@ -24,6 +24,7 @@ class channelizer_ccf(gr.hier_block2): This simplifies the interface by allowing a single input stream to connect to this block. It will then output a stream for each channel. ''' + def __init__(self, numchans, taps=None, oversample_rate=1, atten=100): gr.hier_block2.__init__(self, "pfb_channelizer_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), @@ -37,14 +38,15 @@ class channelizer_ccf(gr.hier_block2): else: self._taps = self.create_taps(self._nchans, atten) - self.s2ss = blocks.stream_to_streams(gr.sizeof_gr_complex, self._nchans) + self.s2ss = blocks.stream_to_streams( + gr.sizeof_gr_complex, self._nchans) self.pfb = filter.pfb_channelizer_ccf(self._nchans, self._taps, self._oversample_rate) self.connect(self, self.s2ss) for i in range(self._nchans): - self.connect((self.s2ss,i), (self.pfb,i)) - self.connect((self.pfb,i), (self,i)) + self.connect((self.s2ss, i), (self.pfb, i)) + self.connect((self.pfb, i), (self, i)) def set_channel_map(self, newmap): self.pfb.set_channel_map(newmap) @@ -57,7 +59,7 @@ class channelizer_ccf(gr.hier_block2): def declare_sample_delay(self, delay): self.pfb.declare_sample_delay(delay) - + @staticmethod def create_taps(numchans, atten=100): # Create a filter that covers the full bandwidth of the input signal @@ -66,7 +68,7 @@ class channelizer_ccf(gr.hier_block2): ripple = 0.1 while True: try: - taps = optfir.low_pass(1, numchans, bw, bw+tb, ripple, atten) + taps = optfir.low_pass(1, numchans, bw, bw + tb, ripple, atten) return taps except RuntimeError: ripple += 0.01 @@ -74,7 +76,8 @@ class channelizer_ccf(gr.hier_block2): # Build in an exit strategy; if we've come this far, it ain't working. if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") + raise RuntimeError( + "optfir could not generate an appropriate filter.") class interpolator_ccf(gr.hier_block2): @@ -86,6 +89,7 @@ class interpolator_ccf(gr.hier_block2): streams. This block is provided to be consistent with the interface to the other PFB block. ''' + def __init__(self, interp, taps=None, atten=100): gr.hier_block2.__init__(self, "pfb_interpolator_ccf", gr.io_signature(1, 1, gr.sizeof_gr_complex), @@ -118,7 +122,8 @@ class interpolator_ccf(gr.hier_block2): ripple = 0.99 while True: try: - taps = optfir.low_pass(interp, interp, bw, bw+tb, ripple, atten) + taps = optfir.low_pass( + interp, interp, bw, bw + tb, ripple, atten) return taps except RuntimeError: ripple += 0.01 @@ -126,8 +131,8 @@ class interpolator_ccf(gr.hier_block2): # Build in an exit strategy; if we've come this far, it ain't working. if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - + raise RuntimeError( + "optfir could not generate an appropriate filter.") class decimator_ccf(gr.hier_block2): @@ -137,6 +142,7 @@ class decimator_ccf(gr.hier_block2): This simplifies the interface by allowing a single input stream to connect to this block. It will then output a stream that is the decimated output stream. ''' + def __init__(self, decim, taps=None, channel=0, atten=100, use_fft_rotators=True, use_fft_filters=True): gr.hier_block2.__init__(self, "pfb_decimator_ccf", @@ -158,7 +164,7 @@ class decimator_ccf(gr.hier_block2): self.connect(self, self.s2ss) for i in range(self._decim): - self.connect((self.s2ss,i), (self.pfb,i)) + self.connect((self.s2ss, i), (self.pfb, i)) self.connect(self.pfb, self) @@ -170,7 +176,7 @@ class decimator_ccf(gr.hier_block2): def declare_sample_delay(self, delay): self.pfb.declare_sample_delay(delay) - + @staticmethod def create_taps(decim, atten=100): # Create a filter that covers the full bandwidth of the input signal @@ -179,7 +185,7 @@ class decimator_ccf(gr.hier_block2): ripple = 0.1 while True: try: - taps = optfir.low_pass(1, decim, bw, bw+tb, ripple, atten) + taps = optfir.low_pass(1, decim, bw, bw + tb, ripple, atten) return taps except RuntimeError: ripple += 0.01 @@ -187,7 +193,8 @@ class decimator_ccf(gr.hier_block2): # Build in an exit strategy; if we've come this far, it ain't working. if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") + raise RuntimeError( + "optfir could not generate an appropriate filter.") class arb_resampler_ccf(gr.hier_block2): @@ -199,10 +206,12 @@ class arb_resampler_ccf(gr.hier_block2): streams. This block is provided to be consistent with the interface to the other PFB block. ''' + def __init__(self, rate, taps=None, flt_size=32, atten=100): gr.hier_block2.__init__(self, "pfb_arb_resampler_ccf", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._rate = rate self._size = flt_size @@ -210,9 +219,10 @@ class arb_resampler_ccf(gr.hier_block2): if (taps is not None) and (len(taps) > 0): self._taps = taps else: - self._taps = self.create_taps(self._rate, self._size, atten); + self._taps = self.create_taps(self._rate, self._size, atten) - self.pfb = filter.pfb_arb_resampler_ccf(self._rate, self._taps, self._size) + self.pfb = filter.pfb_arb_resampler_ccf( + self._rate, self._taps, self._size) #print("PFB has %d taps\n" % (len(self._taps),)) self.connect(self, self.pfb) @@ -239,34 +249,37 @@ class arb_resampler_ccf(gr.hier_block2): # the half-band here is 0.5*rate. percent = 0.80 if(rate < 1): - halfband = 0.5*rate - bw = percent*halfband - tb = (percent / 2.0)*halfband + halfband = 0.5 * rate + bw = percent * halfband + tb = (percent / 2.0) * halfband ripple = 0.1 # As we drop the bw factor, the optfir filter has a harder time converging; # using the firdes method here for better results. return filter.firdes.low_pass_2(flt_size, flt_size, bw, tb, atten, - fft.window.WIN_BLACKMAN_HARRIS) + fft.window.WIN_BLACKMAN_HARRIS) else: halfband = 0.5 - bw = percent*halfband - tb = (percent / 2.0)*halfband + bw = percent * halfband + tb = (percent / 2.0) * halfband ripple = 0.1 taps = None while True: try: - taps = optfir.low_pass(flt_size, flt_size, bw, bw+tb, ripple, atten) + taps = optfir.low_pass( + flt_size, flt_size, bw, bw + tb, ripple, atten) return taps except RuntimeError: ripple += 0.01 - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + print( + "Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) # Build in an exit strategy; if we've come this far, it ain't working. if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") - + raise RuntimeError( + "optfir could not generate an appropriate filter.") + class arb_resampler_fff(gr.hier_block2): ''' @@ -277,10 +290,12 @@ class arb_resampler_fff(gr.hier_block2): streams. This block is provided to be consistent with the interface to the other PFB block. ''' + def __init__(self, rate, taps=None, flt_size=32, atten=100): gr.hier_block2.__init__(self, "pfb_arb_resampler_fff", - gr.io_signature(1, 1, gr.sizeof_float), # Input signature - gr.io_signature(1, 1, gr.sizeof_float)) # Output signature + # Input signature + gr.io_signature(1, 1, gr.sizeof_float), + gr.io_signature(1, 1, gr.sizeof_float)) # Output signature self._rate = rate self._size = flt_size @@ -290,8 +305,9 @@ class arb_resampler_fff(gr.hier_block2): else: self._taps = self.create_taps(self._rate, self._size, atten) - self.pfb = filter.pfb_arb_resampler_fff(self._rate, self._taps, self._size) - #print "PFB has %d taps\n" % (len(self._taps),) + self.pfb = filter.pfb_arb_resampler_fff( + self._rate, self._taps, self._size) + # print "PFB has %d taps\n" % (len(self._taps),) self.connect(self, self.pfb) self.connect(self.pfb, self) @@ -317,32 +333,36 @@ class arb_resampler_fff(gr.hier_block2): # the half-band here is 0.5*rate. percent = 0.80 if(rate < 1): - halfband = 0.5*rate - bw = percent*halfband - tb = (percent / 2.0)*halfband + halfband = 0.5 * rate + bw = percent * halfband + tb = (percent / 2.0) * halfband ripple = 0.1 # As we drop the bw factor, the optfir filter has a harder time converging; # using the firdes method here for better results. return filter.firdes.low_pass_2(flt_size, flt_size, bw, tb, atten, - fft.window.WIN_BLACKMAN_HARRIS) + fft.window.WIN_BLACKMAN_HARRIS) else: halfband = 0.5 - bw = percent*halfband - tb = (percent / 2.0)*halfband + bw = percent * halfband + tb = (percent / 2.0) * halfband ripple = 0.1 while True: try: - taps = optfir.low_pass(flt_size, flt_size, bw, bw+tb, ripple, atten) + taps = optfir.low_pass( + flt_size, flt_size, bw, bw + tb, ripple, atten) return taps except RuntimeError: ripple += 0.01 - print("Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) + print( + "Warning: set ripple to %.4f dB. If this is a problem, adjust the attenuation or create your own filter taps." % (ripple)) # Build in an exit strategy; if we've come this far, it ain't working. if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") + raise RuntimeError( + "optfir could not generate an appropriate filter.") + class arb_resampler_ccc(gr.hier_block2): ''' @@ -353,10 +373,12 @@ class arb_resampler_ccc(gr.hier_block2): streams. This block is provided to be consistent with the interface to the other PFB block. ''' + def __init__(self, rate, taps=None, flt_size=32, atten=100): gr.hier_block2.__init__(self, "pfb_arb_resampler_ccc", - gr.io_signature(1, 1, gr.sizeof_gr_complex), # Input signature - gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature + # Input signature + gr.io_signature(1, 1, gr.sizeof_gr_complex), + gr.io_signature(1, 1, gr.sizeof_gr_complex)) # Output signature self._rate = rate self._size = flt_size @@ -366,8 +388,9 @@ class arb_resampler_ccc(gr.hier_block2): else: self._taps = self.create_taps(self._rate, self._size, atten) - self.pfb = filter.pfb_arb_resampler_ccc(self._rate, self._taps, self._size) - #print "PFB has %d taps\n" % (len(self._taps),) + self.pfb = filter.pfb_arb_resampler_ccc( + self._rate, self._taps, self._size) + # print "PFB has %d taps\n" % (len(self._taps),) self.connect(self, self.pfb) self.connect(self.pfb, self) @@ -390,7 +413,8 @@ class arb_resampler_ccc(gr.hier_block2): ripple = 0.1 while True: try: - taps = optfir.low_pass(flt_size, flt_size, bw, bw+tb, ripple, atten) + taps = optfir.low_pass( + flt_size, flt_size, bw, bw + tb, ripple, atten) return taps except RuntimeError: ripple += 0.01 @@ -398,7 +422,9 @@ class arb_resampler_ccc(gr.hier_block2): # Build in an exit strategy; if we've come this far, it ain't working. if(ripple >= 1.0): - raise RuntimeError("optfir could not generate an appropriate filter.") + raise RuntimeError( + "optfir could not generate an appropriate filter.") + class channelizer_hier_ccf(gr.hier_block2): """ @@ -426,29 +452,34 @@ class channelizer_hier_ccf(gr.hier_block2): gr.io_signature(1, 1, gr.sizeof_gr_complex), gr.io_signature(len(outchans), len(outchans), gr.sizeof_gr_complex)) if taps is None: - taps = self.create_taps(n_chans, atten=100, bw=1.0, tb=0.2, ripple=0.1) + taps = self.create_taps( + n_chans, atten=100, bw=1.0, tb=0.2, ripple=0.1) taps = list(taps) - extra_taps = int(math.ceil(1.0*len(taps)/n_chans)*n_chans - len(taps)) + extra_taps = int(math.ceil(1.0 * len(taps) / n_chans) * + n_chans - len(taps)) taps = taps + [0] * extra_taps # Make taps for each channel - chantaps = [list(reversed(taps[i: len(taps): n_chans])) for i in range(0, n_chans)] + chantaps = [list(reversed(taps[i: len(taps): n_chans])) + for i in range(0, n_chans)] # Convert the input stream into a stream of vectors. self.s2v = blocks.stream_to_vector(gr.sizeof_gr_complex, n_chans) # Create a mapping to separate out each filterbank (a group of channels to be processed together) # And a list of sets of taps for each filterbank. low_cpp = int(n_chans / n_filterbanks) - extra = n_chans - low_cpp*n_filterbanks - cpps = [low_cpp+1]*extra + [low_cpp]*(n_filterbanks-extra) + extra = n_chans - low_cpp * n_filterbanks + cpps = [low_cpp + 1] * extra + [low_cpp] * (n_filterbanks - extra) splitter_mapping = [] filterbanktaps = [] total = 0 for cpp in cpps: - splitter_mapping.append([(0, i) for i in range(total, total+cpp)]) - filterbanktaps.append(chantaps[total: total+cpp]) + splitter_mapping.append([(0, i) + for i in range(total, total + cpp)]) + filterbanktaps.append(chantaps[total: total + cpp]) total += cpp assert(total == n_chans) # Split the stream of vectors in n_filterbanks streams of vectors. - self.splitter = blocks.vector_map(gr.sizeof_gr_complex, [n_chans], splitter_mapping) + self.splitter = blocks.vector_map( + gr.sizeof_gr_complex, [n_chans], splitter_mapping) # Create the filterbanks self.fbs = [filter.filterbank_vcvcf(taps) for taps in filterbanktaps] # Combine the streams of vectors back into a single stream of vectors. @@ -456,15 +487,18 @@ class channelizer_hier_ccf(gr.hier_block2): for i, cpp in enumerate(cpps): for j in range(cpp): combiner_mapping[0].append((i, j)) - self.combiner = blocks.vector_map(gr.sizeof_gr_complex, cpps, combiner_mapping) + self.combiner = blocks.vector_map( + gr.sizeof_gr_complex, cpps, combiner_mapping) # Add the final FFT to the channelizer. - self.fft = fft.fft_vcc(n_chans, forward=True, window=[1.0]*n_chans) + self.fft = fft.fft_vcc(n_chans, forward=True, window=[1.0] * n_chans) # Select the desired channels if outchans != list(range(n_chans)): selector_mapping = [[(0, i) for i in outchans]] - self.selector = blocks.vector_map(gr.sizeof_gr_complex, [n_chans], selector_mapping) + self.selector = blocks.vector_map( + gr.sizeof_gr_complex, [n_chans], selector_mapping) # Convert stream of vectors to a normal stream. - self.v2ss = blocks.vector_to_streams(gr.sizeof_gr_complex, len(outchans)) + self.v2ss = blocks.vector_to_streams( + gr.sizeof_gr_complex, len(outchans)) self.connect(self, self.s2v, self.splitter) for i in range(0, n_filterbanks): self.connect((self.splitter, i), self.fbs[i], (self.combiner, i)) @@ -478,5 +512,4 @@ class channelizer_hier_ccf(gr.hier_block2): @staticmethod def create_taps(n_chans, atten=100, bw=1.0, tb=0.2, ripple=0.1): - return optfir.low_pass(1, n_chans, bw, bw+tb, ripple, atten) - + return optfir.low_pass(1, n_chans, bw, bw + tb, ripple, atten) diff --git a/gr-filter/python/filter/qa_freq_xlating_fir_filter.py b/gr-filter/python/filter/qa_freq_xlating_fir_filter.py index 0ca435795c..615e5e60a1 100644 --- a/gr-filter/python/filter/qa_freq_xlating_fir_filter.py +++ b/gr-filter/python/filter/qa_freq_xlating_fir_filter.py @@ -115,7 +115,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 1 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -134,7 +134,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 4 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -152,7 +152,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 1 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -170,7 +170,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 4 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -188,7 +188,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 1 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -206,7 +206,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 4 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -224,7 +224,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 1 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) @@ -242,7 +242,7 @@ class test_freq_xlating_filter(gr_unittest.TestCase): decim = 4 lo = sig_source_c(self.fs, -self.fc, 1, len(self.src_data)) - phase = -cmath.pi * self.fc / self.fs * (len(self.taps)-1) + phase = -cmath.pi * self.fc / self.fs * (len(self.taps) - 1) despun = mix(lo, self.src_data, phase=phase) expected_data = fir_filter(despun, self.taps, decim) diff --git a/gr-filter/python/filter/qa_rational_resampler.py b/gr-filter/python/filter/qa_rational_resampler.py index 4c67dc793b..55ed431709 100644 --- a/gr-filter/python/filter/qa_rational_resampler.py +++ b/gr-filter/python/filter/qa_rational_resampler.py @@ -18,7 +18,7 @@ import sys def random_floats(n): r = [] for x in range(n): - # r.append(float(random.randint(-32768, 32768))) + # r.append(float(random.randint(-32768, 32768))) r.append(float(random.random())) return tuple(r) |