Did you ever check out maximum_position
from scipy.ndimage
?
The examples straight from their docs
>>> from scipy import ndimage
>>> import numpy as np
>>> a = np.array([[1, 2, 0, 0],
... [5, 3, 0, 4],
... [0, 0, 0, 7],
... [9, 3, 0, 0]])
>>> ndimage.maximum_position(a)
(3, 0)
Features to process can be specified using `labels` and `index`:
>>> lbl = np.array([[0, 1, 2, 3],
... [0, 1, 2, 3],
... [0, 1, 2, 3],
... [0, 1, 2, 3]])
>>> ndimage.maximum_position(a, lbl, 1)
(1, 1)
If no index is given, non-zero `labels` are processed:
>>> ndimage.maximum_position(a, lbl)
(2, 3)
If there are no maxima, the position of the first element is returned:
>>> ndimage.maximum_position(a, lbl, 2)
(0, 2)