title: From which index array values are inside a specific error band?
body: <p>Is there any built-in <code>numpy</code> function to check from which index a signal (array) does not leave a specific error band?</p>
  
  <hr>
  
  <p>Working with digital filters, I need to determine the length of an impulse response to use in <a href="http://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.filtfilt.html" rel="nofollow noreferrer"><code>scipy.signal.filtfilt</code></a>. Fairly easy with <em>Finite Impulse Response (FIR)</em> filters, but kind of impossible with <em>Infinite Impulse Response (IIR)</em> filters.<br>
  However, it would do calculating the point, from which the impulse response does not leave a certain error band:</p>
  
  <p><img src="https://i.stack.imgur.com/bMyY3.png" alt="impulse response of a Chebyshev-2 IIR filter"></p>
  
  <p>For now I'm using a quick-and-dirty workaround, checking the reversed array manually for the first value outside the error band:</p>
  
  <pre><code>def ringing_time(sig, th):
      return len(sig) - np.argmax(np.abs(sig[::-1]) &gt; th)
  </code></pre>
  
  <p>Is there any fast built-in <code>numpy</code> approach for this?</p>