From 2fa7c997559e173c59227ee14a154e4b462d46bd Mon Sep 17 00:00:00 2001
From: Tom Rondeau <trondeau@vt.edu>
Date: Tue, 28 Dec 2010 13:08:55 -0500
Subject: Under extreme circumstances, optfir might never produce an answer
 (atten>300), so this puts in a check on the ripple; if it gets too large,
 stop trying.

---
 gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py | 4 ++++
 gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py   | 4 ++++
 gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py     | 4 ++++
 gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py  | 6 +++++-
 4 files changed, 17 insertions(+), 1 deletion(-)

(limited to 'gnuradio-core/src/python/gnuradio/blks2impl')

diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py
index c4e496c45a..5e4e068714 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_arb_resampler.py
@@ -57,6 +57,10 @@ class pfb_arb_resampler_ccf(gr.hier_block2):
                     made = False
                     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.")
+
         self.pfb = gr.pfb_arb_resampler_ccf(self._rate, self._taps, self._size)
 
         self.connect(self, self.pfb)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py
index ecbdd20476..3ddc1749a7 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_channelizer.py
@@ -54,6 +54,10 @@ class pfb_channelizer_ccf(gr.hier_block2):
                     made = False
                     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.")
+
         self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._numchans)
         self.pfb = gr.pfb_channelizer_ccf(self._numchans, self._taps,
                                           self._oversample_rate)
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py
index 103980da02..2e36e7bc1d 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_decimator.py
@@ -54,6 +54,10 @@ class pfb_decimator_ccf(gr.hier_block2):
                     made = False
                     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.")
+
         self.s2ss = gr.stream_to_streams(gr.sizeof_gr_complex, self._decim)
         self.pfb = gr.pfb_decimator_ccf(self._decim, self._taps, self._channel)
 
diff --git a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
index a210e3de82..a6094f7f45 100644
--- a/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
+++ b/gnuradio-core/src/python/gnuradio/blks2impl/pfb_interpolator.py
@@ -45,7 +45,7 @@ class pfb_interpolator_ccf(gr.hier_block2):
             # Create a filter that covers the full bandwidth of the input signal
             bw = 0.4
             tb = 0.2
-            ripple = 0.1
+            ripple = 0.99
             made = False
             while not made:
                 try:
@@ -56,6 +56,10 @@ class pfb_interpolator_ccf(gr.hier_block2):
                     made = False
                     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.")
+
         self.pfb = gr.pfb_interpolator_ccf(self._interp, self._taps)
 
         self.connect(self, self.pfb)
-- 
cgit v1.2.3