What are the values ​​of the index array within a certain range of errors?

Is there a built-in function numpyto check from which index a signal (array) does not leave a certain range of errors?


When working with digital filters, I need to determine the impulse response length to use in scipy.signal.filtfilt. Quite easy with FIR filters, but seemingly impossible with Infinite Impulse Response (IIR) filters.
However, it will calculate the point from which the impulse response does not leave a certain range of errors:

impulse response of a Chebyshev-2 IIR filter

I am currently using a quick and dirty workaround, manually checking the inverse array for the first value outside the error range:

def ringing_time(sig, th):
    return len(sig) - np.argmax(np.abs(sig[::-1]) > th)

Is there any quick built-in approach numpyfor this?

+4
source share
1 answer

In general, no. You use some signal-specific knowledge that is not universal (the fact that the envelope decays over time). Your decision is good, I think if you want to do it numerically.

You can do something like accept the impulse response equation, symbolically differentiate it with sympy and apply the newton method, but you have to deal with getting started in the right place so that it does not fall into one of the local minima. All in all, I think you are in a good place.

0
source

All Articles