From 09fb1c056189e676d4c905949d7608c866a9247e Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Mon, 24 Aug 2009 19:25:30 -0400 Subject: [PATCH] Adding equiripple band reject filter to filter design app. --- gr-utils/src/python/gr_filter_design.py | 41 ++- gr-utils/src/python/pyqt_filter.py | 15 +- gr-utils/src/python/pyqt_filter.ui | 457 ++++++++++++------------ 3 files changed, 280 insertions(+), 233 deletions(-) diff --git a/gr-utils/src/python/gr_filter_design.py b/gr-utils/src/python/gr_filter_design.py index 4aa59360..238fd63f 100755 --- a/gr-utils/src/python/gr_filter_design.py +++ b/gr-utils/src/python/gr_filter_design.py @@ -41,7 +41,7 @@ class gr_plot_filter(QtGui.QMainWindow): Qt.SIGNAL("textEdited(QString)"), self.nfft_edit_changed) - self.gui.designButton.setShortcut("Return") + self.gui.designButton.setShortcut(QtCore.Qt.Key_Return) self.taps = [] self.fftdB = [] @@ -54,6 +54,8 @@ class gr_plot_filter(QtGui.QMainWindow): self.gui.lpfPassBandRippleEdit.setVisible(False) self.gui.bpfPassBandRippleLabel.setVisible(False) self.gui.bpfPassBandRippleEdit.setVisible(False) + self.gui.bnfPassBandRippleLabel.setVisible(False) + self.gui.bnfPassBandRippleEdit.setVisible(False) self.gui.hpfPassBandRippleLabel.setVisible(False) self.gui.hpfPassBandRippleEdit.setVisible(False) @@ -168,6 +170,8 @@ class gr_plot_filter(QtGui.QMainWindow): self.gui.lpfPassBandRippleEdit.setVisible(True) self.gui.bpfPassBandRippleLabel.setVisible(True) self.gui.bpfPassBandRippleEdit.setVisible(True) + self.gui.bnfPassBandRippleLabel.setVisible(True) + self.gui.bnfPassBandRippleEdit.setVisible(True) self.gui.hpfPassBandRippleLabel.setVisible(True) self.gui.hpfPassBandRippleEdit.setVisible(True) @@ -177,6 +181,8 @@ class gr_plot_filter(QtGui.QMainWindow): self.gui.lpfPassBandRippleEdit.setVisible(False) self.gui.bpfPassBandRippleLabel.setVisible(False) self.gui.bpfPassBandRippleEdit.setVisible(False) + self.gui.bnfPassBandRippleLabel.setVisible(False) + self.gui.bnfPassBandRippleEdit.setVisible(False) self.gui.hpfPassBandRippleLabel.setVisible(False) self.gui.hpfPassBandRippleEdit.setVisible(False) @@ -195,6 +201,7 @@ class gr_plot_filter(QtGui.QMainWindow): designer = {"Low Pass" : self.design_opt_lpf, "Band Pass" : self.design_opt_bpf, "Complex Band Pass" : self.design_opt_cbpf, + "Band Notch" : self.design_opt_bnf, "High Pass" : self.design_opt_hpf} taps,r = designer[ftype](fs, gain) @@ -210,6 +217,8 @@ class gr_plot_filter(QtGui.QMainWindow): taps,r = designer[ftype](fs, gain, wintype) if(r): + print "Number of taps: ", len(taps) + self.taps = scipy.array(taps) self.get_fft(fs, self.taps, self.nfftpts) self.update_time_curves() @@ -340,7 +349,7 @@ class gr_plot_filter(QtGui.QMainWindow): return ([],r) # Design Functions for Equiripple Filters - def design_opt_lpf(self, fs, gain, wintype=None): + def design_opt_lpf(self, fs, gain): ret = True pb,r = self.gui.endofLpfPassBandEdit.text().toDouble() ret = r and ret @@ -358,7 +367,7 @@ class gr_plot_filter(QtGui.QMainWindow): else: return ([], ret) - def design_opt_bpf(self, fs, gain, wintype=None): + def design_opt_bpf(self, fs, gain): ret = True pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() ret = r and ret @@ -380,7 +389,7 @@ class gr_plot_filter(QtGui.QMainWindow): else: return ([],r) - def design_opt_cbpf(self, fs, gain, wintype=None): + def design_opt_cbpf(self, fs, gain): ret = True pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble() ret = r and ret @@ -402,7 +411,29 @@ class gr_plot_filter(QtGui.QMainWindow): else: return ([],r) - def design_opt_hpf(self, fs, gain, wintype=None): + def design_opt_bnf(self, fs, gain): + ret = True + sb1,r = self.gui.startofBnfStopBandEdit.text().toDouble() + ret = r and ret + sb2,r = self.gui.endofBnfStopBandEdit.text().toDouble() + ret = r and ret + tb,r = self.gui.bnfTransitionEdit.text().toDouble() + ret = r and ret + atten,r = self.gui.bnfStopBandAttenEdit.text().toDouble() + ret = r and ret + ripple,r = self.gui.bnfPassBandRippleEdit.text().toDouble() + ret = r and ret + + if(r): + pb1 = sb1 - tb + pb2 = sb2 + tb + taps = blks2.optfir.band_reject(gain, fs, pb1, sb1, sb2, pb2, + ripple, atten) + return (taps,r) + else: + return ([],r) + + def design_opt_hpf(self, fs, gain): ret = True sb,r = self.gui.endofHpfStopBandEdit.text().toDouble() ret = r and ret diff --git a/gr-utils/src/python/pyqt_filter.py b/gr-utils/src/python/pyqt_filter.py index 5591cc1a..c10429cf 100644 --- a/gr-utils/src/python/pyqt_filter.py +++ b/gr-utils/src/python/pyqt_filter.py @@ -2,8 +2,8 @@ # Form implementation generated from reading ui file 'pyqt_filter.ui' # -# Created: Mon Aug 24 00:28:45 2009 -# by: PyQt4 UI code generator 4.4.4 +# Created: Mon Aug 24 17:59:37 2009 +# by: PyQt4 UI code generator 4.4.3 # # WARNING! All changes made in this file will be lost! @@ -157,6 +157,12 @@ class Ui_MainWindow(object): self.bnfStopBandAttenLabel = QtGui.QLabel(self.firbnfPage) self.bnfStopBandAttenLabel.setObjectName("bnfStopBandAttenLabel") self.formLayout_5.setWidget(3, QtGui.QFormLayout.LabelRole, self.bnfStopBandAttenLabel) + self.bnfPassBandRippleEdit = QtGui.QLineEdit(self.firbnfPage) + self.bnfPassBandRippleEdit.setObjectName("bnfPassBandRippleEdit") + self.formLayout_5.setWidget(4, QtGui.QFormLayout.FieldRole, self.bnfPassBandRippleEdit) + self.bnfPassBandRippleLabel = QtGui.QLabel(self.firbnfPage) + self.bnfPassBandRippleLabel.setObjectName("bnfPassBandRippleLabel") + self.formLayout_5.setWidget(4, QtGui.QFormLayout.LabelRole, self.bnfPassBandRippleLabel) self.filterTypeWidget.addWidget(self.firbnfPage) self.firhpfPage = QtGui.QWidget() self.firhpfPage.setObjectName("firhpfPage") @@ -292,7 +298,7 @@ class Ui_MainWindow(object): self.gridLayout.addWidget(self.tabGroup, 1, 1, 1, 1) MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 1124, 25)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 1124, 24)) self.menubar.setObjectName("menubar") self.menu_File = QtGui.QMenu(self.menubar) self.menu_File.setObjectName("menu_File") @@ -308,7 +314,7 @@ class Ui_MainWindow(object): self.menubar.addAction(self.menu_File.menuAction()) self.retranslateUi(MainWindow) - self.filterTypeWidget.setCurrentIndex(5) + self.filterTypeWidget.setCurrentIndex(2) self.tabGroup.setCurrentIndex(0) QtCore.QObject.connect(self.action_exit, QtCore.SIGNAL("activated()"), MainWindow.close) QtCore.QMetaObject.connectSlotsByName(MainWindow) @@ -362,6 +368,7 @@ class Ui_MainWindow(object): self.endofBnfStopBandLabel.setText(QtGui.QApplication.translate("MainWindow", "End of Stop Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.bnfTransitionLabel.setText(QtGui.QApplication.translate("MainWindow", "Transition Width (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.bnfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) + self.bnfPassBandRippleLabel.setText(QtGui.QApplication.translate("MainWindow", "Pass Band Ripple (dB)", None, QtGui.QApplication.UnicodeUTF8)) self.endofHpfStopBandLabel.setText(QtGui.QApplication.translate("MainWindow", "End of Stop Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.startofHpfPassBandLabel.setText(QtGui.QApplication.translate("MainWindow", "Start of Pass Band (Hz)", None, QtGui.QApplication.UnicodeUTF8)) self.hpfStopBandAttenLabel.setText(QtGui.QApplication.translate("MainWindow", "Stop Band Attenuation (dB)", None, QtGui.QApplication.UnicodeUTF8)) diff --git a/gr-utils/src/python/pyqt_filter.ui b/gr-utils/src/python/pyqt_filter.ui index ed203700..d7dccfba 100644 --- a/gr-utils/src/python/pyqt_filter.ui +++ b/gr-utils/src/python/pyqt_filter.ui @@ -1,8 +1,7 @@ - - + MainWindow - - + + 0 0 @@ -10,131 +9,131 @@ 696 - + GNU Radio Filter Design Tool - - - - - + + + + + 300 0 - + 300 16777215 - + QFrame::StyledPanel - + QFrame::Raised - + - + - + Low Pass - + Band Pass - + Complex Band Pass - + Band Notch - + High Pass - + Root Raised Cosine - + Gaussian - + - + Hamming Window - + Hann Window - + Blackman Window - + Rectangular Window - + Kaiser Window - + Blackman-harris Window - + Equiripple - - + + QFormLayout::AllNonFixedFieldsGrow - - - + + + 16777215 30 - + Sample Rate (sps) - - - + + + 16777215 30 @@ -142,294 +141,304 @@ - - - + + + Filter Gain - - + + - - - 5 + + + 2 - - - - - + + + + + End of Pass Band (Hz) - - + + - - - + + + Start of Stop Band (Hz) - - + + - - - + + + Stop Band Attenuation (dB) - - + + - - + + - - - + + + Pass Band Ripple (dB) - - - - - + + + + + Start of Pass Band (Hz) - - + + - - - + + + End of Pass Band (Hz) - - + + - - + + - - - + + + Stop Band Attenuation (dB) - - - + + + Transition Width (Hz) - - + + - - + + - - - + + + Pass Band Ripple (dB) - - - - - + + + + + Start of Stop Band (Hz) - - + + - - + + - - + + - - + + - - - + + + End of Stop Band (Hz) - - - + + + Transition Width (Hz) - - - + + + Stop Band Attenuation (dB) + + + + + + + Pass Band Ripple (dB) + + + - - - + + + QFormLayout::AllNonFixedFieldsGrow - - - + + + End of Stop Band (Hz) - - + + - - - + + + Start of Pass Band (Hz) - - + + - - - + + + Stop Band Attenuation (dB) - - + + - - - + + + Pass Band Ripple (dB) - - + + - - - - - + + + + + Symbol Rate (sps) - - - + + + Roll-off Factor - - - + + + Number of Taps - - + + - - + + - - + + - - - - - + + + + + Symbol Rate (sps) - - + + - - - + + + Roll-off Factor - - + + - - - + + + Number of Taps - - + + - - + + System Parameters - - - + + + - - - + + + Num FFT points @@ -438,26 +447,26 @@ - - + + 0 0 - + 200 16777215 - + Design - + true - + true @@ -465,54 +474,54 @@ - - - + + + 800 0 - + 0 - - + + Frequency Domain - + - + - - + + Time Domain - + - + - - + + Phase - + - + - - + + Group Delay - + - + @@ -520,34 +529,34 @@ - - + + 0 0 1124 - 25 + 24 - - + + &File - + - + - - - + + + &Open - + Ctrl+O - - + + E&xit @@ -588,11 +597,11 @@ MainWindow close() - + -1 -1 - + 399 347 -- 2.30.2