0

Suppose I have an array in numpy which reads:

arr = np.array([[1,2,7,6],[2,3,2,1],[10,8,1,3],[9,7,4,2], [np.nan, np.nan, np.nan, np.nan]])

I would like to extract all entries where surrounding entries are superior. A sort of 'local minima' such that I obtain the following indices:

indices = [(0,0), [(2,2), (2,3)]]

Note that the second item in the list is a list of tuples. I would like for such an algorithm to be able to identify local minimum areas as well as local minimum points. NAN values should simply be ignored and treated like a "border".

I have tried playing around with np.gradient because I thought that it should allow me to extract parts where the derivative is 0. But I couldn't really get it to a point where it would work.

Do any libraries or out-of-the-box functionalities exist to achieve this?

halfer
  • 19,471
  • 17
  • 87
  • 173
user32882
  • 4,174
  • 4
  • 28
  • 56

0 Answers0