thank you, I seem to have made some progress (with lots of help)!!<br>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. <br>When I run the following code I alwayes receive the first timestamp of the file. Not sure how to get around this:<br>
<br>            tmax=TSFC.max(axis=0)<br>            maxindex=tmax.argmax()<br>            maxtemp=tmax.ravel()[maxindex] #or maxtemp=TSFC.max()<br>            print maxindex, maxtemp<br>            val=N.unravel_index(maxindex, TSFC.shape)<br>
            listval=list(val)<br>            print listval<br>            timelocation=TIME[listval[0]]<br>            latlocation=LAT[listval[1]]<br>            lonlocation=LON[listval[2]]<br>            print latlocation, lonlocation<br>
            cdftime=utime('seconds since 1970-01-01 00:00:00')<br>            ncfiletime=cdftime.num2date(timelocation)<br>            print ncfiletime<br><br><br><div class="gmail_quote">On Tue, Jan 10, 2012 at 10:22 AM, Benjamin Root <span dir="ltr"><<a href="mailto:ben.root@ou.edu">ben.root@ou.edu</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="im"><br><br>On Monday, January 9, 2012, questions anon <<a href="mailto:questions.anon@gmail.com" target="_blank">questions.anon@gmail.com</a>> wrote:<br>
> thanks for the responses.<br>> Unfortunately they are not matching shapes<br>
>>>> print TSFC.shape, TIME.shape, LAT.shape, LON.shape<br>> (721, 106, 193) (721,) (106,) (193,)<br>><br>> So I still receive index out of bounds error:<br>>>>>tmax=TSFC.max(axis=0)<br>> numpy array of max values for the month<br>

>>>>maxindex=tmax.argmax()<br>> 2928<br>>>>>maxtemp=tmax.ravel()[maxindex] #or maxtemp=TSFC.max()<br>> 35.5 (degrees celcius)<br>><br>>>>>latloc=LAT[tmax.argmax()]<br>> IndexError: index out of bounds<br>

><br>> lonloc=LON[tmax.argmax()]<br>> timeloc=TIME[tmax.argmax()]<br>><br>><br>> Any other ideas for this type of situation?<br>> thanks<br><br></div>Right, we realize they are not the same shape.  When you use argmax on the temperature data, take that index number and use unravel_index(index, TSFC.shape) to get a three-element tuple, each being the index in the TIME, LAT, LON arrays, respectively.<br>

<br>Cheers,<br>Ben Root<div class="HOEnZb"><div class="h5"><br><br>><br>> On Wed, Jan 4, 2012 at 10:29 PM, Derek Homeier <<a href="mailto:derek@astro.physik.uni-goettingen.de" target="_blank">derek@astro.physik.uni-goettingen.de</a>> wrote:<br>
>><br>>> On 04.01.2012, at 5:10AM, questions anon wrote:<br>
>><br>>> > Thanks for your responses but I am still having difficuties with this problem. Using argmax gives me one very large value and I am not sure what it is.<br>>> > There shouldn't be any issues with the shape. The latitude and longitude are the same shape always (covering a state) and the temperature (TSFC) data are hourly for a whole month.<br>

>><br>>> There will be an issue if not TSFC.shape == TIME.shape == LAT.shape == LON.shape<br>>><br>>> One needs more information on the structure of these data to say anything definite,<br>>> but if e.g. your TSFC data have a time and a location dimension, argmax will<br>

>> per default return the index for the flattened array (see the argmax documentation<br>>> for details, and how to use the axis keyword to get a different output).<br>>> This might be the very large value you mention, and if your location data have fewer<br>

>> dimensions, the index will easily be out of range. As Ben wrote, you'd need extra work to<br>>> find the maximum location, depending on what maximum you are actually looking for.<br>>><br>>> As a speculative example, let's assume you have the temperature data in an<br>

>> array(ntime, nloc) and the position data in array(nloc). Then<br>>><br>>> TSFC.argmax(axis=1)<br>>><br>>> would give you the index for the hottest place for each hour of the month<br>>> (i.e. actually an array of ntime indices, and pointer to so many different locations).<br>

>><br>>> To locate the maximum temperature for the entire month, your best way would probably<br>>> be to first extract the array of (monthly) maximum temperatures in each location as<br>>><br>>> tmax = TSFC.max(axis=0)<br>

>><br>>> which would have (in this example) the shape (nloc,), so you could directly use it to index<br>>><br>>> LAT[tmax.argmax()]   etc.<br>>><br>>> Cheers,<br>>>                                                Derek<br>

>><br>>> _______________________________________________<br>>> NumPy-Discussion mailing list<br>>> <a href="mailto:NumPy-Discussion@scipy.org" target="_blank">NumPy-Discussion@scipy.org</a><br>>> <a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>

><br>>
</div></div><br>_______________________________________________<br>
NumPy-Discussion mailing list<br>
<a href="mailto:NumPy-Discussion@scipy.org">NumPy-Discussion@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/numpy-discussion" target="_blank">http://mail.scipy.org/mailman/listinfo/numpy-discussion</a><br>
<br></blockquote></div><br>