[Numpy-discussion] find location of maximum values

Aronne Merrelli aronne.merrelli at gmail.com
Mon Jan 9 23:28:52 EST 2012

On Mon, Jan 9, 2012 at 7:59 PM, questions anon <questions.anon at gmail.com>wrote:

> thank you, I seem to have made some progress (with lots of help)!!
> I still seem to be having trouble with the time. Because it is hourly data
> for a whole month I assume that is where my problem lies.
> When I run the following code I alwayes receive the first timestamp of the
> file. Not sure how to get around this:
>             tmax=TSFC.max(axis=0)
>             maxindex=tmax.argmax()

You are computing max(axis=0) first. So, tmax is an array containing the
maximum temperature at each lat/lon grid point, over the set of 721 months.
It will be a [106, 193] array.

So the argmax of tmax is an element in a shape [106,193] array (the number
of latitude/number of longitude) not the original three dimension [721,
106, 193] array. Thus when you unravel it you can only get the first time

I re-read your original post but I don't understand what number you need.
Are you trying to get the single max value over the entire array? Or max
value for each month? (a 721 element vector)? or something else?

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20120109/3d31eaaf/attachment.html>

More information about the NumPy-Discussion mailing list