Q:

index masked element Array

I have a array
z = np.random.random((10,10))  --> two dimensions

with a mask
y,x=np.mgrid[slice(0,61, 1),slice(0,106, 1)] 

sorted = np.sort(z,axis=None)
mask = ma.masked_inside(z,sorted[10],sorted[-10])

mask is Array masked inside only the 10 min element and 10 max inside with a mask TRUE. I need the index position to put x,y in the annotate, but only like create element that is masked
I will like return mask elements masked and the index position in the axis of all the elements to create a automatic annotates objects
 ax.annotate(str(j)+" Altura",xy=(i,j))

A:

To return the "index position", use np.where on the mask. For example:
import numpy as np
A = np.array([[2,7,9],[9,1,4],[8,7,2]])
idx = A<3 # The mask

print np.where(idx)
print zip(*np.where(idx))

Gives:
(array([0, 1, 2]), array([0, 1, 2]))
[(0, 0), (1, 1), (2, 2)]

that is, the locations where A<3. I find zipping over the elements and packaging them as a list of tuples useful, but use the first representation to index them back from the original array.

