Changeset 489 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Dec 21, 2011, 3:22:19 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r485 r489 74 74 from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img 75 75 import matplotlib as mpl 76 from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel 76 from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor, show, plot, clabel, title, close, legend, xlabel, axis 77 77 from matplotlib.cm import get_cmap 78 78 import numpy as np … … 147 147 if ((proj == None) and (typefile not in ['mesoideal'])): proj = getproj(nc) 148 148 149 ########################################################## 149 if firstfile: 150 ########################## 151 ### Define plot boundaries 152 ### todo: possible areas in latinterv in argument (ex: "Far_South_Pole") 153 if proj in ["npstere","spstere"]: [wlon,wlat] = polarinterv(lon2d,lat2d) 154 elif proj in ["lcc","laea"]: [wlon,wlat] = wrfinterv(lon2d,lat2d) 155 else: [wlon,wlat] = simplinterv(lon2d,lat2d) 156 if zoom: [wlon,wlat] = zoomset(wlon,wlat,zoom) 157 elif zarea is not None: [wlon,wlat] = latinterv(area=zarea) 158 159 ########################################################## LOAD 4D DIMENSIONS : x, y, z, t 150 160 if typefile == "gcm": 151 161 lat = nc.variables["latitude"][:] ; lon = nc.variables["longitude"][:] … … 158 168 ### the following lines are kind of dirty... not possible to ask for several lats and lons 159 169 if vlon is not None or vlat is not None: 160 indices = bidimfind(lon2d,lat2d,vlon,vlat) #,file=nc) #placer un point sur carte 170 if firstfile: iwantawhereplot = nc 171 else: iwantawhereplot = None 172 indices = bidimfind(lon2d,lat2d,vlon,vlat,file=iwantawhereplot) #placer un point sur carte 161 173 lonp,latp = ( lon2d[indices[0],indices[1]] , lat2d[indices[0],indices[1]] ) 162 174 if typefile in ['mesoapi','meso'] and mapmode == 1: lon2d = dumpbdy(lon2d,6) ; lat2d = dumpbdy(lat2d,6) ### important to do that now and not before … … 183 195 elif "Time" in nc.variables: time = count + np.arange(0,len(nc.variables["Time"]),1) 184 196 else: time = count + np.arange(0,1,1) 185 count = time[-1] + 1 ## so that a cat is possible with simple subscripts 197 if nnn > 0: count = time[-1] + 1 ## so that a cat is possible with simple subscripts 198 else: count = 0 199 if axtime in ["lt"]: 200 for i in range(len(time)): time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) ) 201 print "LOCAL TIMES.... ", time 186 202 ### 187 203 if typefile in ['geo']: vert = [0.] ; stime = readslices(str(0)) … … 198 214 ## Faire d'autre checks sur les compatibilites entre fichiers!! 199 215 ########################################################## 200 201 if firstfile:202 ##########################203 ### Define plot boundaries204 ### todo: possible areas in latinterv in argument (ex: "Far_South_Pole")205 if proj in ["npstere","spstere"]: [wlon,wlat] = polarinterv(lon2d,lat2d)206 elif proj in ["lcc","laea"]: [wlon,wlat] = wrfinterv(lon2d,lat2d)207 else: [wlon,wlat] = simplinterv(lon2d,lat2d)208 if zoom: [wlon,wlat] = zoomset(wlon,wlat,zoom)209 elif zarea is not None: [wlon,wlat] = latinterv(area=zarea)210 216 211 217 all_varname[k] = varname … … 246 252 if var2: tab2 = np.append(tab2,all_var2[k],axis=0) 247 253 tabtime = np.append(tabtime,all_time[k]) ; tab = np.append(tab,all_var[k],axis=0) ; k += 1 248 #all_time[0] = np.arange(0,len(tab),1) ### AS: time reference is too simplistic, should be better249 254 all_time[0] = np.array(tabtime) ; all_var[0] = np.array(tab) ; numplot = 1 250 255 if var2: all_var2[0] = np.array(tab2) … … 287 292 else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah 288 293 time = all_time[index_f] 289 if stime is not None:290 if stime[0][0] < 0:291 if typefile in ['mesoapi','meso']:292 for i in range(len(time)): time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) )293 print "OK... WORKING WITH LOCAL TIMES"294 else: errormess("local times not supported. not too hard to modify the code though.")295 294 if mrate is not None: indextime = None 296 295 else: indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) … … 298 297 if typefile in ['mesoapi','meso'] and indextime is not None: ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 299 298 print "********** INDEX LON:",indexlon," LAT:",indexlat," VERT:",indexvert," TIME:",indextime 299 #var = nc.variables["phisinit"][:,:] 300 #contourf(np.transpose(var),30,cmap = get_cmap(name="Greys_r") ) ; axis('off') ; plot(indexlat,indexlon,'mx',mew=4.0,ms=20.0) 301 #show() 302 #exit() 300 303 #################################################################### 301 304 ########## REDUCE FIELDS … … 337 340 if colorb in ["def","nobar"]: palette = get_cmap(name=defcolorb(fvar.upper())) 338 341 else: palette = get_cmap(name=colorb) 339 ##### 1. ELIMINATE >3D CASES 340 if len(what_I_plot.shape) >= 4: 342 ##### 1. ELIMINATE 0D or >3D CASES 343 if len(what_I_plot.shape) == 0: 344 print "VALUE VALUE VALUE VALUE ::: ",what_I_plot 345 save = 'donothing' 346 elif len(what_I_plot.shape) >= 4: 341 347 print "WARNING!!! ",len(what_I_plot.shape),"-D PLOT NOT SUPPORTED !!! dimensions: ",what_I_plot.shape 342 348 errormess("Are you sure you did not forget to prescribe a dimension ?") … … 542 548 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 543 549 elif save == 'gui': show() 550 elif save == 'donothing': pass 544 551 elif save == 'txt': print "Saved results in txt file." 545 552 else:
Note: See TracChangeset
for help on using the changeset viewer.