diff options
author | Tom Rondeau <trondeau@molly.home> | 2009-08-24 17:44:43 -0400 |
---|---|---|
committer | Tom Rondeau <trondeau@molly.home> | 2009-08-24 17:44:43 -0400 |
commit | ef44b1afa410d77dbf84ba79119c16bb4fd02606 (patch) | |
tree | 670a74662ca9acf4e760c634c596e21d7ecb0610 /gnuradio-core/src/python/gnuradio/optfir.py | |
parent | 2d4405ea55f3d9e4369fa903ce4d0d2a5addd7b4 (diff) |
Added routine for optfir equiripple filter design code to create complex bandpass filters. Also adds this ability to the filter designer.
Diffstat (limited to 'gnuradio-core/src/python/gnuradio/optfir.py')
-rw-r--r-- | gnuradio-core/src/python/gnuradio/optfir.py | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/gnuradio-core/src/python/gnuradio/optfir.py b/gnuradio-core/src/python/gnuradio/optfir.py index 06a0eea614..ad5743287e 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) |