[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Commit-gnuradio] [gnuradio] 10/20: python3: update gr-filter for python
From: |
git |
Subject: |
[Commit-gnuradio] [gnuradio] 10/20: python3: update gr-filter for python3 support |
Date: |
Sun, 25 Dec 2016 03:59:59 +0000 (UTC) |
This is an automated email from the git hooks/post-receive script.
jcorgan pushed a commit to branch python3
in repository gnuradio.
commit 789706013cc9d8932e087e7d8de44096562b93fb
Author: Douglas Anderson <address@hidden>
Date: Thu Dec 22 12:53:24 2016 -0700
python3: update gr-filter for python3 support
---
gr-filter/python/filter/design/filter_design.py | 523 ++++++++++++------------
gr-filter/python/filter/design/fir_design.py | 26 +-
gr-filter/python/filter/filterbank.py | 6 +-
gr-filter/python/filter/gui/banditems.py | 6 +-
gr-filter/python/filter/gui/idealbanditems.py | 39 +-
gr-filter/python/filter/optfir.py | 6 +-
gr-filter/python/filter/pfb.py | 10 +-
gr-filter/python/filter/rational_resampler.py | 18 +-
8 files changed, 328 insertions(+), 306 deletions(-)
diff --git a/gr-filter/python/filter/design/filter_design.py
b/gr-filter/python/filter/design/filter_design.py
index f94b6b8..5f72df7 100644
--- a/gr-filter/python/filter/design/filter_design.py
+++ b/gr-filter/python/filter/design/filter_design.py
@@ -18,6 +18,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import sys, os, re, csv, copy
import warnings
from optparse import OptionParser
@@ -27,56 +29,56 @@ try:
import scipy
from scipy import fftpack, poly1d, signal
except ImportError:
- print "Please install SciPy to run this script (http://www.scipy.org/)"
- raise SystemExit, 1
+ print("Please install SciPy to run this script (http://www.scipy.org/)")
+ raise SystemExit(1)
try:
from PyQt4 import Qt, QtCore, QtGui
except ImportError:
- print "Please install PyQt4 to run this script
(http://www.riverbankcomputing.co.uk/software/pyqt/download)"
- raise SystemExit, 1
+ print("Please install PyQt4 to run this script
(http://www.riverbankcomputing.co.uk/software/pyqt/download)")
+ raise SystemExit(1)
try:
import PyQt4.Qwt5 as Qwt
except ImportError:
- print "Please install PyQwt5 to run this script
(http://pyqwt.sourceforge.net/)"
- raise SystemExit, 1
+ print("Please install PyQwt5 to run this script
(http://pyqwt.sourceforge.net/)")
+ raise SystemExit(1)
try:
from gnuradio.filter.pyqt_filter_stacked import Ui_MainWindow
except ImportError:
- print "Could not import from pyqt_filter_stacked. Please build with
\"pyuic4 pyqt_filter_stacked.ui -o pyqt_filter_stacked.py\""
- raise SystemExit, 1
+ print("Could not import from pyqt_filter_stacked. Please build with
\"pyuic4 pyqt_filter_stacked.ui -o pyqt_filter_stacked.py\"")
+ raise SystemExit(1)
try:
from gnuradio.filter.banditems import *
except ImportError:
- print "Could not import from banditems. Please check whether banditems.py
is in the library path"
- raise SystemExit, 1
+ print("Could not import from banditems. Please check whether banditems.py
is in the library path")
+ raise SystemExit(1)
try:
from gnuradio.filter.polezero_plot import *
except ImportError:
- print "Could not import from polezero_plot. Please check whether
polezero_plot.py is in the library path"
- raise SystemExit, 1
+ print("Could not import from polezero_plot. Please check whether
polezero_plot.py is in the library path")
+ raise SystemExit(1)
try:
from gnuradio.filter.idealbanditems import *
except ImportError:
- print "Could not import from idealbanditems. Please check whether
idealbanditems.py is in the library path"
- raise SystemExit, 1
+ print("Could not import from idealbanditems. Please check whether
idealbanditems.py is in the library path")
+ raise SystemExit(1)
try:
from gnuradio.filter.api_object import *
except ImportError:
- print "Could not import from api_object. Please check whether
api_object.py is in the library path"
- raise SystemExit, 1
+ print("Could not import from api_object. Please check whether
api_object.py is in the library path")
+ raise SystemExit(1)
try:
from gnuradio.filter.fir_design import *
except ImportError:
- print "Could not import from fir_design. Please check whether
fir_design.py is in the library path"
- raise SystemExit, 1
+ print("Could not import from fir_design. Please check whether
fir_design.py is in the library path")
+ raise SystemExit(1)
try:
_fromUtf8 = QtCore.QString.fromUtf8
@@ -140,72 +142,72 @@ class gr_plot_filter(QtGui.QMainWindow):
self.nfft_edit_changed)
self.connect(self.gui.actionQuick_Access,
- Qt.SIGNAL("activated()"),
- self.action_quick_access)
+ Qt.SIGNAL("activated()"),
+ self.action_quick_access)
self.connect(self.gui.actionSpec_Widget,
- Qt.SIGNAL("activated()"),
- self.action_spec_widget)
+ Qt.SIGNAL("activated()"),
+ self.action_spec_widget)
self.connect(self.gui.actionResponse_Widget,
- Qt.SIGNAL("activated()"),
- self.action_response_widget)
+ Qt.SIGNAL("activated()"),
+ self.action_response_widget)
self.connect(self.gui.actionDesign_Widget,
- Qt.SIGNAL("activated()"),
- self.action_design_widget)
+ Qt.SIGNAL("activated()"),
+ self.action_design_widget)
self.connect(self.gui.actionMagnitude_Response,
- Qt.SIGNAL("activated()"),
- self.set_actmagresponse)
+ Qt.SIGNAL("activated()"),
+ self.set_actmagresponse)
self.connect(self.gui.actionGrid_2,
- Qt.SIGNAL("activated()"),
- self.set_actgrid)
+ Qt.SIGNAL("activated()"),
+ self.set_actgrid)
self.connect(self.gui.actionPhase_Respone,
- Qt.SIGNAL("activated()"),
- self.set_actphase)
+ Qt.SIGNAL("activated()"),
+ self.set_actphase)
self.connect(self.gui.actionGroup_Delay,
- Qt.SIGNAL("activated()"),
- self.set_actgdelay)
+ Qt.SIGNAL("activated()"),
+ self.set_actgdelay)
self.connect(self.gui.actionFilter_Coefficients,
- Qt.SIGNAL("activated()"),
- self.set_actfcoeff)
+ Qt.SIGNAL("activated()"),
+ self.set_actfcoeff)
self.connect(self.gui.actionBand_Diagram,
- Qt.SIGNAL("activated()"),
- self.set_actband)
+ Qt.SIGNAL("activated()"),
+ self.set_actband)
self.connect(self.gui.actionIdeal_Band,
- Qt.SIGNAL("activated()"),
- self.set_drawideal)
+ Qt.SIGNAL("activated()"),
+ self.set_drawideal)
self.connect(self.gui.actionPole_Zero_Plot_2,
- Qt.SIGNAL("activated()"),
- self.set_actpzplot)
+ Qt.SIGNAL("activated()"),
+ self.set_actpzplot)
self.connect(self.gui.actionGridview,
- Qt.SIGNAL("activated()"),
- self.set_switchview)
+ Qt.SIGNAL("activated()"),
+ self.set_switchview)
self.connect(self.gui.actionPlot_select,
- Qt.SIGNAL("activated()"),
- self.set_plotselect)
+ Qt.SIGNAL("activated()"),
+ self.set_plotselect)
self.connect(self.gui.actionPhase_Delay,
- Qt.SIGNAL("activated()"),
- self.set_actpdelay)
+ Qt.SIGNAL("activated()"),
+ self.set_actpdelay)
self.connect(self.gui.actionImpulse_Response,
- Qt.SIGNAL("activated()"),
- self.set_actimpres)
+ Qt.SIGNAL("activated()"),
+ self.set_actimpres)
self.connect(self.gui.actionStep_Response,
- Qt.SIGNAL("activated()"),
- self.set_actstepres)
+ Qt.SIGNAL("activated()"),
+ self.set_actstepres)
self.connect(self.gui.mfmagPush,
Qt.SIGNAL("released()"),
@@ -272,48 +274,48 @@ class gr_plot_filter(QtGui.QMainWindow):
self.set_mtimpulse)
self.connect(self.gui.checkKeepcur,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_bufferplots)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_bufferplots)
self.connect(self.gui.checkGrid,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_grid)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_grid)
self.connect(self.gui.checkMagres,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_magresponse)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_magresponse)
self.connect(self.gui.checkGdelay,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_gdelay)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_gdelay)
self.connect(self.gui.checkPhase,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_phase)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_phase)
self.connect(self.gui.checkFcoeff,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_fcoeff)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_fcoeff)
self.connect(self.gui.checkBand,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_band)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_band)
self.connect(self.gui.checkPzplot,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_pzplot)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_pzplot)
self.connect(self.gui.checkPdelay,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_pdelay)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_pdelay)
self.connect(self.gui.checkImpulse,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_impres)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_impres)
self.connect(self.gui.checkStep,
- Qt.SIGNAL("stateChanged(int)"),
- self.set_stepres)
+ Qt.SIGNAL("stateChanged(int)"),
+ self.set_stepres)
self.gridenable = False
self.mfoverlay = False
@@ -387,28 +389,28 @@ class gr_plot_filter(QtGui.QMainWindow):
impxtitle = Qwt.QwtText("n (Samples)")
impxtitle.setFont(Qt.QFont("Helvetica", 11, Qt.QFont.Bold))
self.gui.impresPlot.setAxisTitle(self.gui.freqPlot.xBottom,
- impxtitle)
+ impxtitle)
self.gui.impresPlot.setAxisTitle(self.gui.freqPlot.yLeft,
- impytitle)
+ impytitle)
self.gui.stepresPlot.setAxisTitle(self.gui.freqPlot.xBottom,
- impxtitle)
+ impxtitle)
self.gui.stepresPlot.setAxisTitle(self.gui.freqPlot.yLeft,
- impytitle)
+ impytitle)
mtytitle = Qwt.QwtText("Amplitude")
mtytitle.setFont(Qt.QFont("Helvetica", 9, Qt.QFont.Bold))
mtxtitle = Qwt.QwtText("n (Samples/taps)")
mtxtitle.setFont(Qt.QFont("Helvetica", 9, Qt.QFont.Bold))
self.gui.mtimePlot.setAxisTitle(self.gui.freqPlot.xBottom,
- mtxtitle)
+ mtxtitle)
self.gui.mtimePlot.setAxisTitle(self.gui.freqPlot.yLeft,
- mtytitle)
+ mtytitle)
phytitle = Qwt.QwtText("Phase Delay")
phytitle.setFont(Qt.QFont("Helvetica", 11, Qt.QFont.Bold))
self.gui.pdelayPlot.setAxisTitle(self.gui.groupPlot.xBottom,
- fxtitle)
+ fxtitle)
self.gui.pdelayPlot.setAxisTitle(self.gui.groupPlot.yLeft,
- phytitle)
+ phytitle)
# Set up plot curves
self.rcurve = Qwt.QwtPlotCurve("Real")
@@ -480,16 +482,16 @@ class gr_plot_filter(QtGui.QMainWindow):
self.gui.timePlot.canvas())
self.mtimeZoomer = Qwt.QwtPlotZoomer(self.gui.mtimePlot.xBottom,
- self.gui.mtimePlot.yLeft,
- Qwt.QwtPicker.PointSelection,
- Qwt.QwtPicker.AlwaysOn,
- self.gui.mtimePlot.canvas())
+ self.gui.mtimePlot.yLeft,
+ Qwt.QwtPicker.PointSelection,
+ Qwt.QwtPicker.AlwaysOn,
+ self.gui.mtimePlot.canvas())
self.mtimeZoomer2 = Qwt.QwtPlotZoomer(self.gui.mtimePlot.xBottom,
- self.gui.mtimePlot.yRight,
- Qwt.QwtPicker.PointSelection,
- Qwt.QwtPicker.AlwaysOff,
- self.gui.mtimePlot.canvas())
+ self.gui.mtimePlot.yRight,
+ Qwt.QwtPicker.PointSelection,
+ Qwt.QwtPicker.AlwaysOff,
+ self.gui.mtimePlot.canvas())
self.freqZoomer = Qwt.QwtPlotZoomer(self.gui.freqPlot.xBottom,
self.gui.freqPlot.yLeft,
@@ -523,25 +525,25 @@ class gr_plot_filter(QtGui.QMainWindow):
self.gui.groupPlot.canvas())
self.impresZoomer = Qwt.QwtPlotZoomer(self.gui.groupPlot.xBottom,
- self.gui.groupPlot.yLeft,
- Qwt.QwtPicker.PointSelection,
- Qwt.QwtPicker.AlwaysOn,
- self.gui.impresPlot.canvas())
+ self.gui.groupPlot.yLeft,
+ Qwt.QwtPicker.PointSelection,
+ Qwt.QwtPicker.AlwaysOn,
+ self.gui.impresPlot.canvas())
self.stepresZoomer = Qwt.QwtPlotZoomer(self.gui.groupPlot.xBottom,
- self.gui.groupPlot.yLeft,
- Qwt.QwtPicker.PointSelection,
- Qwt.QwtPicker.AlwaysOn,
- self.gui.stepresPlot.canvas())
+ self.gui.groupPlot.yLeft,
+ Qwt.QwtPicker.PointSelection,
+ Qwt.QwtPicker.AlwaysOn,
+ self.gui.stepresPlot.canvas())
self.pdelayZoomer = Qwt.QwtPlotZoomer(self.gui.groupPlot.xBottom,
- self.gui.groupPlot.yLeft,
- Qwt.QwtPicker.PointSelection,
- Qwt.QwtPicker.AlwaysOn,
- self.gui.pdelayPlot.canvas())
+ self.gui.groupPlot.yLeft,
+ Qwt.QwtPicker.PointSelection,
+ Qwt.QwtPicker.AlwaysOn,
+ self.gui.pdelayPlot.canvas())
- #Assigning items
+ #Assigning items
self.lpfitems = lpfItems
self.hpfitems = hpfItems
self.bpfitems = bpfItems
@@ -580,7 +582,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.lpfstartproxy.setWidget(self.lpfpassEdit)
self.lpfstartproxy.setPos(400,30)
- self.lpfstopEdit=QtGui.QLineEdit()
+ self.lpfstopEdit=QtGui.QLineEdit()
self.lpfstopEdit.setMaximumSize(QtCore.QSize(75,20))
self.lpfstopEdit.setText(Qt.QString("Not set"))
self.lpfstopproxy=QtGui.QGraphicsProxyWidget()
@@ -642,39 +644,39 @@ class gr_plot_filter(QtGui.QMainWindow):
self.freqcurve.setPen(Qt.QPen(blueBrush, 1))
self.rcurve.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
self.rcurve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
- Qt.QBrush(Qt.Qt.gray),
- Qt.QPen(Qt.Qt.blue),
- Qt.QSize(8, 8)))
+ Qt.QBrush(Qt.Qt.gray),
+ Qt.QPen(Qt.Qt.blue),
+ Qt.QSize(8, 8)))
self.icurve.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
self.icurve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
- Qt.QBrush(Qt.Qt.gray),
- Qt.QPen(Qt.Qt.red),
- Qt.QSize(8, 8)))
+ Qt.QBrush(Qt.Qt.gray),
+ Qt.QPen(Qt.Qt.red),
+ Qt.QSize(8, 8)))
self.imprescurve.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
self.imprescurve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
- Qt.QBrush(Qt.Qt.gray),
- Qt.QPen(Qt.Qt.blue),
- Qt.QSize(8, 8)))
+ Qt.QBrush(Qt.Qt.gray),
+ Qt.QPen(Qt.Qt.blue),
+ Qt.QSize(8, 8)))
self.imprescurve_i.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
self.imprescurve_i.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
- Qt.QBrush(Qt.Qt.gray),
- Qt.QPen(Qt.Qt.red),
- Qt.QSize(8, 8)))
+ Qt.QBrush(Qt.Qt.gray),
+ Qt.QPen(Qt.Qt.red),
+ Qt.QSize(8, 8)))
self.steprescurve.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
self.steprescurve.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
- Qt.QBrush(Qt.Qt.gray),
- Qt.QPen(Qt.Qt.blue),
- Qt.QSize(8, 8)))
+ Qt.QBrush(Qt.Qt.gray),
+ Qt.QPen(Qt.Qt.blue),
+ Qt.QSize(8, 8)))
self.steprescurve_i.setPen(Qt.QPen(Qt.Qt.white, 0, Qt.Qt.NoPen))
self.steprescurve_i.setSymbol(Qwt.QwtSymbol(Qwt.QwtSymbol.Ellipse,
- Qt.QBrush(Qt.Qt.gray),
- Qt.QPen(Qt.Qt.red),
- Qt.QSize(8, 8)))
+ Qt.QBrush(Qt.Qt.gray),
+ Qt.QPen(Qt.Qt.red),
+ Qt.QSize(8, 8)))
self.phasecurve.setPen(Qt.QPen(blueBrush, 1))
self.groupcurve.setPen(Qt.QPen(blueBrush, 1))
@@ -802,7 +804,7 @@ class gr_plot_filter(QtGui.QMainWindow):
# filters this window type can handle
currenttype = self.gui.filterTypeComboBox.currentText()
items = self.gui.filterTypeComboBox.count()
- for i in xrange(items):
+ for i in range(items):
self.gui.filterTypeComboBox.removeItem(0)
self.gui.filterTypeComboBox.addItems(self.optFilters)
@@ -837,7 +839,7 @@ class gr_plot_filter(QtGui.QMainWindow):
items = self.gui.filterTypeComboBox.count()
for i in xrange(items):
self.gui.filterTypeComboBox.removeItem(0)
- self.gui.filterTypeComboBox.addItems(self.firFilters)
+ self.gui.filterTypeComboBox.addItems(self.firFilters)
# If the last filter type was valid for this window type,
# go back to it; otherwise, reset
@@ -872,7 +874,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.design_iir()
if len(w):
reply = QtGui.QMessageBox.information(self,
"BadCoefficients",
-
str(w[-1].message),"&Ok")
+
str(w[-1].message),"&Ok")
# Do FIR design
def design_fir(self, ftype, fs, gain, winstr):
@@ -908,15 +910,15 @@ class gr_plot_filter(QtGui.QMainWindow):
self.gui.nTapsEdit.setText(Qt.QString("%1").arg(self.taps.size))
else:
self.draw_plots(taps,params)
- zeros=self.get_zeros()
- poles=self.get_poles()
- self.gui.pzPlot.insertZeros(zeros)
- self.gui.pzPlot.insertPoles(poles)
- self.gui.mpzPlot.insertZeros(zeros)
- self.gui.mpzPlot.insertPoles(poles)
- self.update_fcoeff()
- self.set_drawideal()
- #return taps if callback is enabled
+ zeros=self.get_zeros()
+ poles=self.get_poles()
+ self.gui.pzPlot.insertZeros(zeros)
+ self.gui.pzPlot.insertPoles(poles)
+ self.gui.mpzPlot.insertZeros(zeros)
+ self.gui.mpzPlot.insertPoles(poles)
+ self.update_fcoeff()
+ self.set_drawideal()
+ #return taps if callback is enabled
if self.callback:
retobj = ApiObject()
retobj.update_all("fir", self.params, self.taps, 1)
@@ -935,22 +937,22 @@ class gr_plot_filter(QtGui.QMainWindow):
self.cpicker.set_iir(True)
self.cpicker2.set_iir(True)
- iirft = {"Elliptic" : 'ellip',
+ 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" }
iirabbr = {
- "Low Pass" : "lpf",
- "High Pass" : "hpf",
- "Band Pass" : "bpf",
- "Band Stop" : "bnf" }
+ "Low Pass" : "lpf",
+ "High Pass" : "hpf",
+ "Band Pass" : "bpf",
+ "Band Stop" : "bnf" }
iirboxes = {"Low Pass" :
[self.gui.iirendofLpfPassBandEdit.text().toDouble(),
self.gui.iirstartofLpfStopBandEdit.text().toDouble(),
@@ -1004,33 +1006,33 @@ class gr_plot_filter(QtGui.QMainWindow):
try:
(self.b,self.a) = signal.iirfilter(order, besselparams,
btype=iirbtype.replace(' ','').lower(),
analog=sanalog[atype],
ftype=iirft[iirftype], output='ba')
- except StandardError, e:
- reply = QtGui.QMessageBox.information(self,
"IIR design error",
-
e.args[0], "&Ok")
- (self.z,self.p,self.k) = signal.tf2zpk(self.b,self.a)
- iirparams = { "filttype": iirft[iirftype],"bandtype":
iirabbr[iirbtype], "filtord": order, "paramtype":paramtype[sanalog[atype]],
- "critfreq": besselparams}
+ except Exception as e:
+ reply = QtGui.QMessageBox.information(self, "IIR design
error",
+ e.args[0], "&Ok")
+ (self.z,self.p,self.k) = signal.tf2zpk(self.b,self.a)
+ iirparams = { "filttype": iirft[iirftype],"bandtype":
iirabbr[iirbtype], "filtord": order, "paramtype":paramtype[sanalog[atype]],
+ "critfreq": besselparams}
else:
try:
(self.b,self.a) = signal.iirdesign(params[0], params[1],
params[2],
- params[3], analog=sanalog[atype],
ftype=iirft[iirftype], output='ba')
- except StandardError, e:
- reply = QtGui.QMessageBox.information(self,
"IIR design error",
-
e.args[0], "&Ok")
- (self.z,self.p,self.k) = signal.tf2zpk(self.b,self.a)
- #Create params
+ params[3],
analog=sanalog[atype], ftype=iirft[iirftype], output='ba')
+ except Exception as e:
+ reply = QtGui.QMessageBox.information(self, "IIR design
error",
+ e.args[0], "&Ok")
+ (self.z,self.p,self.k) = signal.tf2zpk(self.b,self.a)
+ #Create params
iirparams = { "filttype": iirft[iirftype], "bandtype":
iirabbr[iirbtype],"paramtype":paramtype[sanalog[atype]],
"pbedge": params[0], "sbedge":
params[1],"gpass": params[2],
"gstop": params[3]}
- 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.update_fcoeff()
- self.gui.nTapsEdit.setText("-")
- self.params = iirparams
- #return api_object if callback is enabled
+ 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.update_fcoeff()
+ self.gui.nTapsEdit.setText("-")
+ self.params = iirparams
+ #return api_object if callback is enabled
if self.callback:
retobj = ApiObject()
retobj.update_all("iir", self.params, (self.b, self.a), 1)
@@ -1046,15 +1048,15 @@ class gr_plot_filter(QtGui.QMainWindow):
self.groupDelay = -scipy.diff(self.fftDeg)
self.phaseDelay = -self.fftDeg[1:]/self.freq[1:]
if self.gridview:
- self.set_mfmagresponse()
- self.set_mtimpulse()
+ self.set_mfmagresponse()
+ self.set_mtimpulse()
else:
- self.update_freq_curves()
- self.update_phase_curves()
- self.update_group_curves()
- self.update_pdelay_curves()
- self.update_step_curves()
- self.update_imp_curves()
+ self.update_freq_curves()
+ self.update_phase_curves()
+ self.update_group_curves()
+ self.update_pdelay_curves()
+ self.update_step_curves()
+ self.update_imp_curves()
def nfft_edit_changed(self, nfft):
@@ -1119,7 +1121,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.gui.mtimePlot.enableAxis(Qwt.QwtPlot.yRight,False)
self.gui.mtimePlot.setAxisScale(self.gui.mtimePlot.yLeft,
ymin, ymax)
- # Set the zoomer base to unzoom to the new axis
+ # Set the zoomer base to unzoom to the new axis
self.timeZoomer.setZoomBase()
self.mtimeZoomer.setZoomBase()
@@ -1148,9 +1150,9 @@ class gr_plot_filter(QtGui.QMainWindow):
# Reset the x-axis to the new time scale
self.gui.stepresPlot.setAxisScale(self.gui.stepresPlot.xBottom,
- 0, ntaps)
+ 0, ntaps)
self.gui.stepresPlot.setAxisScale(self.gui.stepresPlot.yLeft,
- symin, symax)
+ symin, symax)
if self.mtoverlay:
self.gui.mtimePlot.setAxisScale(self.steprescurve.yAxis(),
symin, symax)
@@ -1191,9 +1193,9 @@ class gr_plot_filter(QtGui.QMainWindow):
# Reset the x-axis to the new time scale
self.gui.impresPlot.setAxisScale(self.gui.impresPlot.xBottom,
- 0, ntaps)
+ 0, ntaps)
self.gui.impresPlot.setAxisScale(self.gui.impresPlot.yLeft,
- iymin, iymax)
+ iymin, iymax)
if self.mtoverlay:
self.gui.mtimePlot.setAxisScale(self.imprescurve.yAxis(),
@@ -1228,16 +1230,16 @@ class gr_plot_filter(QtGui.QMainWindow):
ymax = self.fftdB.max()
if(ymax < 0):
ymax = 0.8 * self.fftdB.max()
- ymin = 1.1 * self.fftdB.min()
+ ymin = 1.1 * self.fftdB.min()
else:
xmax = self.freq[npts/2]
ymax = 1.5 * max(self.fftdB[0:npts/2])
ymin = 1.1 * min(self.fftdB[0:npts/2])
- xmin = self.freq[0]
- self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom,
- xmin, xmax)
- self.gui.freqPlot.setAxisScale(self.gui.freqPlot.yLeft,
- ymin, ymax)
+ xmin = self.freq[0]
+ self.gui.freqPlot.setAxisScale(self.gui.freqPlot.xBottom,
+ xmin, xmax)
+ self.gui.freqPlot.setAxisScale(self.gui.freqPlot.yLeft,
+ ymin, ymax)
if self.mfoverlay:
self.gui.mfreqPlot.setAxisScale(self.gui.mfreqPlot.xBottom,
@@ -1253,11 +1255,11 @@ class gr_plot_filter(QtGui.QMainWindow):
xmin, xmax)
self.gui.mfreqPlot.setAxisScale(self.gui.mfreqPlot.yLeft,
ymin, ymax)
- #Set Axis title
+ #Set Axis title
self.gui.mfreqPlot.setAxisTitle(self.freqcurve.yAxis(),
- fytitle)
+ fytitle)
self.gui.mfreqPlot.setAxisTitle(self.freqcurve.xAxis(),
- fxtitle)
+ fxtitle)
# Set the zoomer base to unzoom to the new axis
self.freqZoomer.setZoomBase()
self.mfreqZoomer.setZoomBase()
@@ -1279,16 +1281,16 @@ class gr_plot_filter(QtGui.QMainWindow):
ymax = self.fftDeg.max()
if(ymax < 0):
ymax = 0.8 * self.fftDeg.max()
- ymin = 1.1 * self.fftDeg.min()
+ ymin = 1.1 * self.fftDeg.min()
else:
ymax = 1.5 * max(self.fftDeg[0:npts/2])
ymin = 1.1 * min(self.fftDeg[0:npts/2])
xmax = self.freq[npts/2]
- xmin = self.freq[0]
- self.gui.phasePlot.setAxisScale(self.gui.phasePlot.xBottom,
- xmin, xmax)
- self.gui.phasePlot.setAxisScale(self.gui.phasePlot.yLeft,
- ymin, ymax)
+ xmin = self.freq[0]
+ self.gui.phasePlot.setAxisScale(self.gui.phasePlot.xBottom,
+ xmin, xmax)
+ self.gui.phasePlot.setAxisScale(self.gui.phasePlot.yLeft,
+ ymin, ymax)
if self.mfoverlay:
self.gui.mfreqPlot.setAxisScale(self.gui.mfreqPlot.xBottom,
@@ -1307,7 +1309,7 @@ class gr_plot_filter(QtGui.QMainWindow):
#Set Axis title
self.gui.mfreqPlot.setAxisTitle(self.phasecurve.yAxis(),
- pytitle)
+ pytitle)
# Set the zoomer base to unzoom to the new axis
self.phaseZoomer.setZoomBase()
@@ -1330,16 +1332,16 @@ class gr_plot_filter(QtGui.QMainWindow):
ymax = self.groupDelay.max()
if(ymax < 0):
ymax = 0.8 * self.groupDelay.max()
- ymin = 1.1 * self.groupDelay.min()
+ ymin = 1.1 * self.groupDelay.min()
else:
ymax = 1.5 * max(self.groupDelay[0:npts/2])
ymin = 1.1 * min(self.groupDelay[0:npts/2])
xmax = self.freq[npts/2]
- xmin = self.freq[0]
- self.gui.groupPlot.setAxisScale(self.gui.groupPlot.xBottom,
- xmin, xmax)
- self.gui.groupPlot.setAxisScale(self.gui.groupPlot.yLeft,
- ymin, ymax)
+ xmin = self.freq[0]
+ self.gui.groupPlot.setAxisScale(self.gui.groupPlot.xBottom,
+ xmin, xmax)
+ self.gui.groupPlot.setAxisScale(self.gui.groupPlot.yLeft,
+ ymin, ymax)
if self.mfoverlay:
self.gui.mfreqPlot.setAxisScale(self.gui.mfreqPlot.xBottom,
@@ -1358,7 +1360,7 @@ class gr_plot_filter(QtGui.QMainWindow):
#Set Axis title
self.gui.mfreqPlot.setAxisTitle(self.groupcurve.yAxis(),
- gytitle)
+ gytitle)
# Set the zoomer base to unzoom to the new axis
self.groupZoomer.setZoomBase()
self.mfreqZoomer.setZoomBase()
@@ -1379,16 +1381,16 @@ class gr_plot_filter(QtGui.QMainWindow):
ymax = self.phaseDelay.max()
if(ymax < 0):
ymax = 0.8 * self.phaseDelay.max()
- ymin = 1.1 * self.phaseDelay.min()
+ ymin = 1.1 * self.phaseDelay.min()
else:
ymax = 1.3 * max(self.phaseDelay[0:npts])
ymin = 0.8 * min(self.phaseDelay[0:npts])
xmax = self.freq[npts/2]
- xmin = self.freq[0]
- self.gui.pdelayPlot.setAxisScale(self.gui.pdelayPlot.xBottom,
- xmin, xmax)
- self.gui.pdelayPlot.setAxisScale(self.gui.pdelayPlot.yLeft,
- ymin, ymax)
+ xmin = self.freq[0]
+ self.gui.pdelayPlot.setAxisScale(self.gui.pdelayPlot.xBottom,
+ xmin, xmax)
+ self.gui.pdelayPlot.setAxisScale(self.gui.pdelayPlot.yLeft,
+ ymin, ymax)
if self.mfoverlay:
self.gui.mfreqPlot.setAxisScale(self.gui.mfreqPlot.xBottom,
@@ -1404,9 +1406,9 @@ class gr_plot_filter(QtGui.QMainWindow):
xmin, xmax)
self.gui.mfreqPlot.setAxisScale(self.gui.mfreqPlot.yLeft,
ymin, ymax)
- #Set Axis title
+ #Set Axis title
self.gui.mfreqPlot.setAxisTitle(self.pdelaycurve.yAxis(),
-
phytitle)
+ phytitle)
# Set the zoomer base to unzoom to the new axis
self.pdelayZoomer.setZoomBase()
@@ -1448,8 +1450,8 @@ class gr_plot_filter(QtGui.QMainWindow):
#Detach and delete all plots if unchecked
for c in self.bufferplots:
c.detach()
- self.replot_all()
- self.bufferplots = []
+ self.replot_all()
+ self.bufferplots = []
else:
self.bufferplots = []
#Iterate through tabgroup children and copy curves
@@ -1472,7 +1474,7 @@ class gr_plot_filter(QtGui.QMainWindow):
dup.setSymbol(dsym)
dup.setRenderHint(Qwt.QwtPlotItem.RenderAntialiased)
dup.setData([c.x(i) for i in
range(c.dataSize())],
-
[c.y(i) for i in range(c.dataSize())])
+ [c.y(i) for i in
range(c.dataSize())])
self.bufferplots.append(dup)
self.bufferplots[-1].attach(item)
@@ -1565,7 +1567,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.icurve.attach(self.gui.mtimePlot)
self.update_freq_curves()
self.update_time_curves()
- self.set_drawideal()
+ self.set_drawideal()
def set_plotselect(self):
if (self.gui.actionPlot_select.isChecked() == 0 ):
@@ -1605,8 +1607,8 @@ class gr_plot_filter(QtGui.QMainWindow):
self.detach_allgrid()
self.freqcurve.attach(self.gui.mfreqPlot)
self.detach_firstattached(self.gui.mfreqPlot)
- self.update_freq_curves()
- self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
+ self.update_freq_curves()
+ self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
else:
self.gui.mfreqPlot.detachItems(Qwt.QwtPlotItem.Rtti_PlotItem,
False)
self.set_actgrid()
@@ -1623,7 +1625,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.phasecurve.attach(self.gui.mfreqPlot)
self.detach_firstattached(self.gui.mfreqPlot)
self.update_phase_curves()
- self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
+ self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
else:
self.gui.mfreqPlot.detachItems(Qwt.QwtPlotItem.Rtti_PlotItem,
False)
self.set_actgrid()
@@ -1639,7 +1641,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.groupcurve.attach(self.gui.mfreqPlot)
self.detach_firstattached(self.gui.mfreqPlot)
self.update_group_curves()
- self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
+ self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
else:
self.gui.mfreqPlot.detachItems(Qwt.QwtPlotItem.Rtti_PlotItem,
False)
self.set_actgrid()
@@ -1655,7 +1657,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.pdelaycurve.attach(self.gui.mfreqPlot)
self.detach_firstattached(self.gui.mfreqPlot)
self.update_pdelay_curves()
- self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
+ self.idbanditems.detach_allidealcurves(self.gui.mfreqPlot)
else:
self.gui.mfreqPlot.detachItems(Qwt.QwtPlotItem.Rtti_PlotItem,
False)
self.set_actgrid()
@@ -1688,7 +1690,7 @@ class gr_plot_filter(QtGui.QMainWindow):
items[1].setYAxis(Qwt.QwtPlot.yRight)
if plot is self.gui.mfreqPlot:
items[1].setPen(QtGui.QPen(QtCore.Qt.red, 1,
QtCore.Qt.SolidLine))
- self.set_actgrid()
+ self.set_actgrid()
def update_fft(self, taps, params):
@@ -1918,9 +1920,10 @@ class gr_plot_filter(QtGui.QMainWindow):
if ftype == "Complex Band Pass":
boxatten,r = self.gui.bpfStopBandAttenEdit.text().toDouble()
self.gui.bpfStopBandAttenEdit.setText(Qt.QString(str(atten+boxatten)))
-#self.design()
+ #self.design()
- def set_curvetaps(self,(zr,pl)):
+ def set_curvetaps(self, zeros_poles):
+ zr, pl = zeros_poles
if self.iir:
self.z=zr
self.p=pl
@@ -1934,7 +1937,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.callback(retobj)
else:
hz = poly1d(zr,r=1)
- #print hz.c
+ #print(hz.c)
self.taps=hz.c*self.taps[0]
self.draw_plots(self.taps,self.params)
self.update_fcoeff()
@@ -1949,7 +1952,8 @@ class gr_plot_filter(QtGui.QMainWindow):
retobj.update_all("fir", self.params, self.taps, 1)
self.callback(retobj)
- def set_mcurvetaps(self,(zr,pl)):
+ def set_mcurvetaps(self, zeros_poles):
+ zr, pl = zeros_poles
if self.iir:
self.z=zr
self.p=pl
@@ -1963,7 +1967,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.callback(retobj)
else:
hz = poly1d(zr,r=1)
- #print hz.c
+ #print(hz.c)
self.taps=hz.c*self.taps[0]
if self.gridview:
self.update_fft(self.taps, self.params)
@@ -1971,8 +1975,8 @@ class gr_plot_filter(QtGui.QMainWindow):
self.set_mttaps()
else:
self.draw_plots(self.taps,self.params)
- self.update_fcoeff()
- #update the pzplot in other view
+ self.update_fcoeff()
+ #update the pzplot in other view
zeros=self.get_zeros()
poles=self.get_poles()
self.gui.pzPlot.insertZeros(zeros)
@@ -1983,17 +1987,19 @@ class gr_plot_filter(QtGui.QMainWindow):
retobj.update_all("fir", self.params, self.taps, 1)
self.callback(retobj)
- def set_statusbar(self,(x,y)):
+ def set_statusbar(self, point):
+ x, y = point
if x == None:
- self.gui.pzstatusBar.showMessage("")
+ 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,(x,y)):
+ def set_mstatusbar(self, point):
+ x, y = point
if x == None:
- self.gui.mpzstatusBar.showMessage("")
+ 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)
@@ -2103,7 +2109,9 @@ class gr_plot_filter(QtGui.QMainWindow):
params[row[0]] = float(row[1])
except ValueError:
params[row[0]] = row[1]
+
handle.close()
+
if restype == "fir":
self.iir = False
self.gui.fselectComboBox.setCurrentIndex(0)
@@ -2195,7 +2203,7 @@ class gr_plot_filter(QtGui.QMainWindow):
self.params = params
#Set GUI for IIR type
- iirft = { "ellip" : 0,
+ iirft = { "ellip" : 0,
"butter" : 1,
"cheby1" : 2,
"cheby2" : 3,
@@ -2204,34 +2212,34 @@ class gr_plot_filter(QtGui.QMainWindow):
paramtype = { "analog" : 1,
"digital" : 0 }
bandpos = {
- "lpf" : 0,
- "bpf" : 1,
- "bnf" : 2,
- "hpf" : 3}
+ "lpf" : 0,
+ "bpf" : 1,
+ "bnf" : 2,
+ "hpf" : 3}
iirboxes = {"lpf" : [self.gui.iirendofLpfPassBandEdit,
- self.gui.iirstartofLpfStopBandEdit,
- self.gui.iirLpfPassBandAttenEdit,
- self.gui.iirLpfStopBandRippleEdit],
+ self.gui.iirstartofLpfStopBandEdit,
+ self.gui.iirLpfPassBandAttenEdit,
+ self.gui.iirLpfStopBandRippleEdit],
"hpf" : [self.gui.iirstartofHpfPassBandEdit,
- self.gui.iirendofHpfStopBandEdit,
- self.gui.iirHpfPassBandAttenEdit,
- self.gui.iirHpfStopBandRippleEdit],
+ 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],
+ 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.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"]])
@@ -2260,13 +2268,13 @@ class gr_plot_filter(QtGui.QMainWindow):
self.taps = scipy.array(taps)
if self.params:
self.get_fft(self.params["fs"], self.taps, self.nfftpts)
- self.update_time_curves()
- self.update_freq_curves()
- self.update_phase_curves()
- self.update_group_curves()
- self.update_pdelay_curves()
- self.update_step_curves()
- self.update_imp_curves()
+ self.update_time_curves()
+ self.update_freq_curves()
+ self.update_phase_curves()
+ self.update_group_curves()
+ self.update_pdelay_curves()
+ self.update_step_curves()
+ self.update_imp_curves()
self.gui.nTapsEdit.setText(Qt.QString("%1").arg(self.taps.size))
@@ -2309,4 +2317,3 @@ def main(args):
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 e27b065..68382d6 100644
--- a/gr-filter/python/filter/design/fir_design.py
+++ b/gr-filter/python/filter/design/fir_design.py
@@ -38,7 +38,7 @@ def design_win_lpf(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.low_pass_2(gain, fs, pb, tb,
atten, wintype)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
return ([], [], ret)
@@ -65,7 +65,7 @@ def design_win_bpf(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.band_pass_2(gain, fs, pb1, pb2, tb,
atten, wintype)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
return ([], [], ret)
@@ -92,7 +92,7 @@ def design_win_cbpf(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.complex_band_pass_2(gain, fs, pb1, pb2, tb,
atten, wintype)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
return ([], [], ret)
@@ -119,7 +119,7 @@ def design_win_bnf(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.band_reject_2(gain, fs, pb1, pb2, tb,
atten, wintype)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
return ([], [], ret)
@@ -145,7 +145,7 @@ def design_win_hpf(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.high_pass_2(gain, fs, pb, tb,
atten, wintype)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
else:
@@ -195,7 +195,7 @@ def design_win_rrc(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.root_raised_cosine(gain, fs, sr,
alpha, ntaps)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
else:
@@ -220,7 +220,7 @@ def design_win_gaus(fs, gain, wintype, mainwin):
try:
taps = filter.firdes.gaussian(gain, spb, bt, ntaps)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Runtime Error",
e.args[0], "&Ok")
else:
@@ -247,7 +247,7 @@ def design_opt_lpf(fs, gain, mainwin):
try:
taps = filter.optfir.low_pass(gain, fs, pb, sb,
ripple, atten)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Filter did not
converge",
e.args[0], "&Ok")
return ([],[],False)
@@ -278,7 +278,7 @@ def design_opt_bpf(fs, gain, mainwin):
try:
taps = filter.optfir.band_pass(gain, fs, sb1, pb1, pb2, sb2,
ripple, atten)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Filter did not
converge",
e.args[0], "&Ok")
return ([],[],False)
@@ -311,7 +311,7 @@ def design_opt_cbpf(fs, gain, mainwin):
try:
taps = filter.optfir.complex_band_pass(gain, fs, sb1, pb1, pb2,
sb2,
ripple, atten)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Filter did not
converge",
e.args[0], "&Ok")
return ([],[],False)
@@ -343,7 +343,7 @@ def design_opt_bnf(fs, gain, mainwin):
try:
taps = filter.optfir.band_reject(gain, fs, pb1, sb1, sb2, pb2,
ripple, atten)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Filter did not
converge",
e.args[0], "&Ok")
return ([],[],False)
@@ -372,7 +372,7 @@ def design_opt_hb(fs, gain, mainwin):
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, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Filter Design
Error",
e.args[0], "&Ok")
return ([],[],False)
@@ -398,7 +398,7 @@ def design_opt_hpf(fs, gain, mainwin):
try:
taps = filter.optfir.high_pass(gain, fs, sb, pb,
atten, ripple)
- except RuntimeError, e:
+ except RuntimeError as e:
reply = QtGui.QMessageBox.information(mainwin, "Filter did not
converge",
e.args[0], "&Ok")
return ([],[],False)
diff --git a/gr-filter/python/filter/filterbank.py
b/gr-filter/python/filter/filterbank.py
index 4e1456c..9f0bce7 100644
--- a/gr-filter/python/filter/filterbank.py
+++ b/gr-filter/python/filter/filterbank.py
@@ -19,6 +19,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import sys
from gnuradio import gr
from gnuradio import fft
@@ -119,7 +121,7 @@ class synthesis_filterbank(gr.hier_block2):
self.connect((self.v2ss, i), f)
self.connect(f, (self.ss2s, i))
- self.connect(self.ss2s, self)
+ self.connect(self.ss2s, self)
class analysis_filterbank(gr.hier_block2):
"""
@@ -154,7 +156,7 @@ class analysis_filterbank(gr.hier_block2):
# split in mpoints separate set of taps
sub_taps = _split_taps(taps, mpoints)
- # print >> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =",
len(sub_taps)
+ # print(>> sys.stderr, "mpoints =", mpoints, "len(sub_taps) =",
len(sub_taps))
self.s2ss = blocks.stream_to_streams(item_size, mpoints)
# filters here
diff --git a/gr-filter/python/filter/gui/banditems.py
b/gr-filter/python/filter/gui/banditems.py
index 5071fe7..90bc7ac 100644
--- a/gr-filter/python/filter/gui/banditems.py
+++ b/gr-filter/python/filter/gui/banditems.py
@@ -18,11 +18,13 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
try:
from PyQt4 import Qt, QtCore, QtGui
except ImportError:
- print "Please install PyQt4 to run this script
(http://www.riverbankcomputing.co.uk/software/pyqt/download)"
- raise SystemExit, 1
+ print("Please install PyQt4 to run this script
(http://www.riverbankcomputing.co.uk/software/pyqt/download)")
+ raise SystemExit(1)
#Movable solid line for filter ideal-band diagram
#Enable split to cut the line into two (for bpf)
diff --git a/gr-filter/python/filter/gui/idealbanditems.py
b/gr-filter/python/filter/gui/idealbanditems.py
index ce55657..58d94f3 100644
--- a/gr-filter/python/filter/gui/idealbanditems.py
+++ b/gr-filter/python/filter/gui/idealbanditems.py
@@ -18,6 +18,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
from PyQt4 import QtGui, QtCore, Qt
import PyQt4.Qwt5 as Qwt
import scipy
@@ -47,7 +49,7 @@ class IdealBandItems():
x=[self.params["pbend"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[0].setData(x, y)
x=[self.params["sbstart"], self.params["fs"]/2.0]
@@ -56,7 +58,7 @@ class IdealBandItems():
x=[self.params["sbstart"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[1].setData(x, y)
elif ftype == "High Pass":
@@ -67,7 +69,7 @@ class IdealBandItems():
x=[self.params["pbstart"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[0].setData(x, y)
x=[0,self.params["sbend"]]
@@ -76,7 +78,7 @@ class IdealBandItems():
x=[self.params["sbend"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[1].setData(x, y)
elif ftype == "Band Notch":
@@ -86,12 +88,12 @@ class IdealBandItems():
x=[self.params["sbstart"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[0].setData(x, y)
x=[self.params["sbend"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[1].setData(x, y)
x=[0,self.params["sbstart"]-self.params["tb"]]
@@ -100,7 +102,7 @@ class IdealBandItems():
x=[self.params["sbstart"]-self.params["tb"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[2].setData(x, y)
x=[self.params["sbend"]+self.params["tb"],self.params["fs"]/2.0]
@@ -109,7 +111,7 @@ class IdealBandItems():
x=[self.params["sbend"]+self.params["tb"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[3].setData(x, y)
elif ftype == "Band Pass":
@@ -119,12 +121,12 @@ class IdealBandItems():
x=[self.params["pbstart"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[0].setData(x, y)
x=[self.params["pbend"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[1].setData(x, y)
x=[0,self.params["pbstart"]-self.params["tb"]]
@@ -133,7 +135,7 @@ class IdealBandItems():
x=[self.params["pbstart"]-self.params["tb"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[2].setData(x, y)
x=[self.params["pbend"]+self.params["tb"],self.params["fs"]/2.0]
@@ -142,7 +144,7 @@ class IdealBandItems():
x=[self.params["pbend"]+self.params["tb"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[3].setData(x, y)
elif ftype == "Complex Band Pass":
@@ -152,12 +154,12 @@ class IdealBandItems():
x=[self.params["pbstart"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[0].setData(x, y)
x=[self.params["pbend"]]*2
y=[20.0*scipy.log10(self.params["gain"]),
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[1].setData(x, y)
x=[0,self.params["pbstart"]-self.params["tb"]]
@@ -166,7 +168,7 @@ class IdealBandItems():
x=[self.params["pbstart"]-self.params["tb"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[2].setData(x, y)
x=[self.params["pbend"]+self.params["tb"],self.params["fs"]/2.0]
@@ -175,26 +177,29 @@ class IdealBandItems():
x=[self.params["pbend"]+self.params["tb"]]*2
y=[-self.params["atten"],
- plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
+ plot.axisScaleDiv(Qwt.QwtPlot.yLeft).lowerBound()]
self.idealbandvcurves[3].setData(x, y)
else:
self.detach_allidealcurves(plot)
except KeyError:
- print "All parameters not set for ideal band diagram"
+ print("All parameters not set for ideal band diagram")
self.detach_allidealcurves(plot)
def detach_allidealcurves(self, plot):
for c in self.idealbandhcurves:
c.detach()
+
for c in self.idealbandvcurves:
c.detach()
+
plot.replot()
def detach_unwantedcurves(self, plot):
for i in range(2,4):
self.idealbandvcurves[i].detach()
self.idealbandhcurves[i].detach()
+
plot.replot()
def attach_allidealcurves(self, plot):
diff --git a/gr-filter/python/filter/optfir.py
b/gr-filter/python/filter/optfir.py
index 8ef2a06..b3e6d48 100644
--- a/gr-filter/python/filter/optfir.py
+++ b/gr-filter/python/filter/optfir.py
@@ -19,6 +19,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
'''
Routines for designing optimal FIR filters.
@@ -237,10 +239,10 @@ def remezord (fcuts, mags, devs, fsamp = 2):
nbands = nm
if nm != nd:
- raise ValueError, "Length of mags and devs must be equal"
+ raise ValueError("Length of mags and devs must be equal")
if nf != 2 * (nbands - 1):
- raise ValueError, "Length of f must be 2 * len (mags) - 2"
+ raise ValueError("Length of f must be 2 * len (mags) - 2")
for i in range (len (mags)):
if mags[i] != 0: # if not stopband, get
relative deviation
diff --git a/gr-filter/python/filter/pfb.py b/gr-filter/python/filter/pfb.py
index 9f23d10..b903603 100644
--- a/gr-filter/python/filter/pfb.py
+++ b/gr-filter/python/filter/pfb.py
@@ -20,6 +20,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
import optfir, math
from gnuradio import gr, fft
@@ -147,9 +149,9 @@ class decimator_ccf(gr.hier_block2):
'''
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",
- gr.io_signature(1, 1, gr.sizeof_gr_complex),
- gr.io_signature(1, 1, gr.sizeof_gr_complex))
+ gr.hier_block2.__init__(self, "pfb_decimator_ccf",
+ gr.io_signature(1, 1, gr.sizeof_gr_complex),
+ gr.io_signature(1, 1, gr.sizeof_gr_complex))
self._decim = decim
self._channel = channel
@@ -255,7 +257,7 @@ class arb_resampler_ccf(gr.hier_block2):
raise RuntimeError("optfir could not generate an
appropriate filter.")
self.pfb = filter.pfb_arb_resampler_ccf(self._rate, self._taps,
self._size)
- #print "PFB has %d taps\n" % (len(self._taps),)
+ #print("PFB has %d taps\n" % (len(self._taps),))
self.connect(self, self.pfb)
self.connect(self.pfb, self)
diff --git a/gr-filter/python/filter/rational_resampler.py
b/gr-filter/python/filter/rational_resampler.py
index 961ffc6..f89d8bc 100644
--- a/gr-filter/python/filter/rational_resampler.py
+++ b/gr-filter/python/filter/rational_resampler.py
@@ -19,6 +19,8 @@
# Boston, MA 02110-1301, USA.
#
+from __future__ import print_function
+
from gnuradio import gr, gru
import filter_swig as filter
@@ -38,7 +40,7 @@ def design_filter(interpolation, decimation, fractional_bw):
"""
if fractional_bw >= 0.5 or fractional_bw <= 0:
- raise ValueError, "Invalid fractional_bandwidth, must be in (0, 0.5)"
+ raise ValueError("Invalid fractional_bandwidth, must be in (0, 0.5)")
beta = 7.0
halfband = 0.5
@@ -82,10 +84,10 @@ class _rational_resampler_base(gr.hier_block2):
"""
if not isinstance(interpolation, int) or interpolation < 1:
- raise ValueError, "interpolation must be an integer >= 1"
+ raise ValueError("interpolation must be an integer >= 1")
if not isinstance(decimation, int) or decimation < 1:
- raise ValueError, "decimation must be an integer >= 1"
+ raise ValueError("decimation must be an integer >= 1")
if taps is None and fractional_bw is None:
fractional_bw = 0.4
@@ -108,11 +110,11 @@ class _rational_resampler_base(gr.hier_block2):
taps = design_filter(interpolation, decimation, fractional_bw)
self.resampler = resampler_base(interpolation, decimation, taps)
- gr.hier_block2.__init__(self, "rational_resampler",
- gr.io_signature(1, 1,
self.resampler.input_signature().sizeof_stream_item(0)),
- gr.io_signature(1, 1,
self.resampler.output_signature().sizeof_stream_item(0)))
+ gr.hier_block2.__init__(self, "rational_resampler",
+ gr.io_signature(1, 1,
self.resampler.input_signature().sizeof_stream_item(0)),
+ gr.io_signature(1, 1,
self.resampler.output_signature().sizeof_stream_item(0)))
- self.connect(self, self.resampler, self)
+ self.connect(self, self.resampler, self)
def taps(self):
return self.resampler.taps()
@@ -124,7 +126,7 @@ class rational_resampler_fff(_rational_resampler_base):
float input, float output and float taps.
"""
_rational_resampler_base.__init__(self,
filter.rational_resampler_base_fff,
- interpolation, decimation, taps,
fractional_bw)
+ interpolation, decimation, taps,
fractional_bw)
class rational_resampler_ccf(_rational_resampler_base):
def __init__(self, interpolation, decimation, taps=None,
fractional_bw=None):
- [Commit-gnuradio] [gnuradio] 08/20: python3: update gr-dtv for python3 support, (continued)
- [Commit-gnuradio] [gnuradio] 08/20: python3: update gr-dtv for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 02/20: python3: add cmake support for python3 at top level, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 17/20: python3: fix issues detected by futurize, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 16/20: python3: update gr-zeromq for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 11/20: python3: update gr-qtgui for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 13/20: python3: update gr-uhd for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 04/20: python3: update gnuradio-runtime for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 03/20: python3: update doxygen files to build docs with python3, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 09/20: python3: update gr-fec for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 14/20: python3: update gr-utils for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 10/20: python3: update gr-filter for python3 support,
git <=
- [Commit-gnuradio] [gnuradio] 07/20: python3: update gr-digital for python3 support, git, 2016/12/24
- [Commit-gnuradio] [gnuradio] 18/20: python3: futurize --stage1 --write $(find . -iname '*.py'), git, 2016/12/24