From: John H. <jdh...@ac...> - 2005-05-17 15:30:57
|
>>>>> "Perry" == Perry Greenfield <pe...@st...> writes: Perry> It's simpler in numarray: Perry> i,j = where(z<0.5) Perry> For numeric it's more work: Perry> ind = where(z.flat < 0.5) i = ind//z.shape[1] j = ind % Perry> z.shape[1] Perry> One could turn this into a function for Numeric (to handle Perry> all dimensionalities, etc) I think you meant to use "nonzero" rather than "where" for Numeric... from matplotlib.numerix import where, nonzero from matplotlib.numerix.mlab import rand z = rand(4,5) # It's simpler in numarray: i,j = where(z<0.5) print i,j # For numeric it's more work: ind = nonzero(z.flat < 0.5) i = ind//z.shape[1] j = ind % z.shape[1] print i,j I also think wrapping this functionality into the find function in mpl is a good idea... I frequently miss it. JDH |