[Python] Python: Find maxima and discontinuities in a numpy array

Discussão em 'Python' iniciado por Stack, Junho 6, 2025.

  1. Stack

    Stack Membro Participativo

    I have a question related to finding maxima or more preciseley discontinuities in a numpy array? My exemplary data looks for example like this

    a = np.array([3,4,5,8,7,6,5,4,1])


    In general, I am interested in every maximum/jump in the data. For array a, I want to detect the 8 since it is a maximum (growing numbers on the left side and decreasing numbers on the right) and the value of 4, since the data drops after this value. Until now, I have used scipy.signal.argrelextrema with np.greater to detect maxima, but I am not able to detect these jumps/discontinuities. For the data I am looking at, only a jump towards smaller values can occur not the opposite. Is there an easy pythonic way to detect these jumps?

    Continue reading...

Compartilhe esta Página