Thank you, thank you, thank you! I needed to find the max value (and corresponding TIME and LAT, LON) for the entire month but I shouldn't have been using the tmax, instead I needed to use the entire array. Below code works for those needing to do something similar. Thanks for all your help everyone!
tmax=TSFC.max(axis=0) maxindex=TSFC.argmax() maxtemp=TSFC.ravel()[maxindex] #or maxtemp=TSFC.max() print maxindex, maxtemp val=N.unravel_index(maxindex, TSFC.shape) listval=list(val) print listval timelocation=TIME[listval[0]] latlocation=LAT[listval[1]] lonlocation=LON[listval[2]] print latlocation, lonlocation cdftime=utime('seconds since 1970-01-01 00:00:00') ncfiletime=cdftime.num2date(timelocation) print ncfiletime On Tue, Jan 10, 2012 at 3:28 PM, Aronne Merrelli <aronne.merre...@gmail.com>wrote: > > > On Mon, Jan 9, 2012 at 7:59 PM, questions anon > <questions.a...@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 > value. > > 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? > > > Cheers, > Aronne > > _______________________________________________ > NumPy-Discussion mailing list > NumPy-Discussion@scipy.org > http://mail.scipy.org/mailman/listinfo/numpy-discussion > >
_______________________________________________ NumPy-Discussion mailing list NumPy-Discussion@scipy.org http://mail.scipy.org/mailman/listinfo/numpy-discussion