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,824
  • 17
  • 99
  • 186
user32882
  • 5,094
  • 5
  • 43
  • 82

0 Answers0