summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gnuradio-core/src/python/gnuradio/optfir.py25
-rwxr-xr-xgr-utils/src/python/gr_filter_design.py27
2 files changed, 48 insertions, 4 deletions
diff --git a/gnuradio-core/src/python/gnuradio/optfir.py b/gnuradio-core/src/python/gnuradio/optfir.py
index 06a0eea61..ad5743287 100644
--- a/gnuradio-core/src/python/gnuradio/optfir.py
+++ b/gnuradio-core/src/python/gnuradio/optfir.py
@@ -27,7 +27,7 @@ For a great intro to how all this stuff works, see section 6.6 of
and Barrie W. Jervis, Adison-Wesley, 1993. ISBN 0-201-54413-X.
'''
-import math
+import math, cmath
from gnuradio import gr
remez = gr.remez
@@ -75,6 +75,29 @@ def band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2,
taps = gr.remez (n + nextra_taps, fo, ao, w, "bandpass")
return taps
+
+## Builds a band pass filter with complex taps by making an LPF and
+# spinning it up to the right center frequency
+# @param gain Filter gain in the passband (linear)
+# @param Fs Sampling rate (sps)
+# @param freq1 End of stop band (in Hz)
+# @param freq2 Start of pass band (in Hz)
+# @param passband_ripple_db Pass band ripple in dB (should be small, < 1)
+# @param stopband_atten_db Stop band attenuation in dB (should be large, >= 60)
+# @param nextra_taps Extra taps to use in the filter (default=2)
+def complex_band_pass (gain, Fs, freq_sb1, freq_pb1, freq_pb2, freq_sb2,
+ passband_ripple_db, stopband_atten_db,
+ nextra_taps=2):
+ center_freq = (freq_pb2 + freq_pb1) / 2.0
+ lp_pb = (freq_pb2 - center_freq)/1.0
+ 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 xrange(len(lptaps))]
+ taps = [s*t for s,t in zip(spinner, lptaps)]
+ return taps
+
+
## Builds a high pass filter.
# @param gain Filter gain in the passband (linear)
# @param Fs Sampling rate (sps)
diff --git a/gr-utils/src/python/gr_filter_design.py b/gr-utils/src/python/gr_filter_design.py
index 0579d0fe2..4aa59360f 100755
--- a/gr-utils/src/python/gr_filter_design.py
+++ b/gr-utils/src/python/gr_filter_design.py
@@ -15,8 +15,6 @@ from gnuradio import gr, blks2, eng_notation
from scipy import fftpack
from pyqt_filter import Ui_MainWindow
-from pyqt_filter_firlpf import Ui_firlpfForm
-from pyqt_filter_firhpf import Ui_firhpfForm
class gr_plot_filter(QtGui.QMainWindow):
def __init__(self, qapp, options):
@@ -196,7 +194,8 @@ class gr_plot_filter(QtGui.QMainWindow):
if(winstr == "Equiripple"):
designer = {"Low Pass" : self.design_opt_lpf,
"Band Pass" : self.design_opt_bpf,
- "High Pass" : self.design_opt_hpf}
+ "Complex Band Pass" : self.design_opt_cbpf,
+ "High Pass" : self.design_opt_hpf}
taps,r = designer[ftype](fs, gain)
else:
@@ -381,6 +380,28 @@ class gr_plot_filter(QtGui.QMainWindow):
else:
return ([],r)
+ def design_opt_cbpf(self, fs, gain, wintype=None):
+ ret = True
+ pb1,r = self.gui.startofBpfPassBandEdit.text().toDouble()
+ ret = r and ret
+ pb2,r = self.gui.endofBpfPassBandEdit.text().toDouble()
+ ret = r and ret
+ tb,r = self.gui.bpfTransitionEdit.text().toDouble()
+ ret = r and ret
+ atten,r = self.gui.bpfStopBandAttenEdit.text().toDouble()
+ ret = r and ret
+ ripple,r = self.gui.bpfPassBandRippleEdit.text().toDouble()
+ ret = r and ret
+
+ if(r):
+ sb1 = pb1 - tb
+ sb2 = pb2 + tb
+ taps = blks2.optfir.complex_band_pass(gain, fs, sb1, pb1, pb2, sb2,
+ ripple, atten)
+ return (taps,r)
+ else:
+ return ([],r)
+
def design_opt_hpf(self, fs, gain, wintype=None):
ret = True
sb,r = self.gui.endofHpfStopBandEdit.text().toDouble()