I'm sorry I don't have time to look closely at your code and this may not be helpful, but just in case... I find it suspicious that you *seem* (by quickly glancing at the code) to be taking TIME[max(temperature)] instead of TIME[argmax(temperature)].<br>
<br>-=- Olivier<br><br><div class="gmail_quote">2011/12/20 questions anon <span dir="ltr"><<a href="mailto:questions.anon@gmail.com">questions.anon@gmail.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have a netcdf file that contains hourly temperature data for a whole month. I would like to find the maximum temperature within that file and also the corresponding Latitude and Longitude and Time and then plot this. Below is the code I have so far. I think everything is working except for identifying the corresponding latitude and longitude. The latitude and longitude always seems to be in the same area (from file to file) and they are not where the maximum values are occurring. <br>

Any feedback will be greatly appreciated.<br><br>from netCDF4 import Dataset<br>import matplotlib.pyplot as plt<br>import numpy as N<br>from mpl_toolkits.basemap import Basemap<br>from netcdftime import utime<br>from datetime import datetime<br>

from numpy import ma as MA<br>import os<br><br>TSFCall=[]<br><br>for (path, dirs, files) in os.walk(MainFolder):<br>    for dir in dirs:<br>        print dir<br>    path=path+'/'<br>    for ncfile in files:<br>        if ncfile[-3:]=='.nc':<br>

            print "dealing with ncfiles:", path+ncfile<br>            ncfile=os.path.join(path,ncfile)<br>            ncfile=Dataset(ncfile, 'r+', 'NETCDF4')<br>            TSFC=ncfile.variables['T_SFC'][:]<br>

            TIME=ncfile.variables['time'][:]<br>            LAT=ncfile.variables['latitude'][:]<br>            LON=ncfile.variables['longitude'][:] <br>            ncfile.close()<br><br>            TSFCall.append(TSFC)<br>

            <br>big_array=N.ma.concatenate(TSFCall)<br>tmax=MA.max(TSFC)<br>print tmax<br>t=TIME[tmax]<br>indexTIME=N.where(TIME==t)<br>TSFCmax=TSFC[tmax]<br>print t, indexTIME<br>print LAT[tmax], LON[tmax], TSFCmax<br><br>

cdftime=utime('seconds since 1970-01-01 00:00:00')<br>ncfiletime=cdftime.num2date(t)<br>print ncfiletime<br>timestr=str(ncfiletime)<br>d = datetime.strptime(timestr, '%Y-%m-%d %H:%M:%S')<br>date_string = d.strftime('%Y%m%d_%H%M')<br>

<br>map = Basemap(projection='merc',llcrnrlat=-40,urcrnrlat=-33,llcrnrlon=139.0,urcrnrlon=151.0,lat_ts=0,resolution='i')<br>x,y=map(*N.meshgrid(LON,LAT))<br>map.tissot(LON[tmax], LAT[tmax], 0.15, 100, facecolor='none', edgecolor='black', linewidth=2)<br>

map.readshapefile(shapefile1, 'DSE_REGIONS')<br>map.drawcoastlines(linewidth=0.5)<br>map.drawstates()<br>plt.title('test'+' %s'%date_string)<br>ticks=[-5,0,5,10,15,20,25,30,35,40,45,50]<br>CS = map.contourf(x,y,TSFCmax, 15, cmap=plt.cm.jet)<br>

l,b,w,h =0.1,0.1,0.8,0.8<br>cax = plt.axes([l+w+0.025, b, 0.025, h], )<br>cbar=plt.colorbar(CS, cax=cax, drawedges=True)<br>                 <br>plt.show()<br>plt.close() <br><br>
<br><br>
<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>