Changeset 612 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Apr 4, 2012, 1:59:05 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r610 r612 64 64 xlab=None,\ 65 65 ylab=None,\ 66 lbls=None): 66 lbls=None,\ 67 lstyle=None,\ 68 cross=None): 67 69 68 70 #################################################################################################################### … … 75 77 fmtvar,definecolorvec,defcolorb,getprefix,putpoints,calculate_bounds,errormess,definesubplot,\ 76 78 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 77 getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,windamplitude 79 getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,\ 80 windamplitude,slopeamplitude,deltat0t1 78 81 from mymath import deg,max,min,mean,get_tsat,writeascii,fig2data,fig2img 79 82 import matplotlib as mpl … … 148 151 ### we get the names of variables to be read. in case only one available, we choose this one. 149 152 varname=var[vvv] 150 if ((varname not in nc.variables) and not ((typefile in ['meso']) and (varname in ['UV','uv','uvmet' ]))):153 if ((varname not in nc.variables) and not ((typefile in ['meso']) and (varname in ['UV','uv','uvmet','slopexy','SLOPEXY','deltat','DELTAT']))): 151 154 if len(varinfile) == 1: varname = varinfile[0] 152 155 else: varname = False … … 205 208 ###### principle: calculate correct indices then repopulate slon and slat 206 209 if slon is not None or slat is not None: 207 if firstfile and save == 'png' and typefile == 'meso' and "HGT" in varinfile : iwantawhereplot = nc #show a topo map with a cross on the chosen point210 if firstfile and save == 'png' and typefile == 'meso' and "HGT" in varinfile and display: iwantawhereplot = nc #show a topo map with a cross on the chosen point 208 211 else: iwantawhereplot = None #do not show anything, just select indices 209 212 numlon = 1 ; numlat = 1 … … 278 281 all_namefile[k] = namefile 279 282 all_time[k] = time 280 if var2: all_var2[k] = getfield(nc,var2) 283 if var2: 284 if ((var2 in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (var2 not in nc.variables)): all_var2[k] = slopeamplitude(nc) 285 else: all_var2[k] = getfield(nc,var2) 281 286 if winds: all_windu[k] = getfield(nc,uchar) ; all_windv[k] = getfield(nc,vchar) 282 287 ##################### … … 293 298 elif ((varname in ['UV','uv','uvmet']) and (typefile in ['meso']) and (varname not in nc.variables)): 294 299 all_var[k]=windamplitude(nc) 300 elif ((varname in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (varname not in nc.variables)): 301 all_var[k]=slopeamplitude(nc) 302 elif ((varname in ['DELTAT','deltat']) and (typefile in ['meso']) and (varname not in nc.variables)): 303 all_var[k]=deltat0t1(nc) 295 304 else: 296 305 ##### GENERAL STUFF HERE … … 310 319 if ((all_varname[k-1] in ['UV','uv','uvmet']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)): 311 320 all_var[k] = windamplitude(ncref) 321 elif ((all_varname[k-1] in ['slopexy','SLOPEXY']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)): 322 all_var[k] = slopeamplitude(ncref) 323 elif ((all_varname[k-1] in ['DELTAT','deltat']) and (typefile in ['meso']) and (all_varname[k-1] not in ncref.variables)): 324 all_var[k]=deltat0t1(ncref) 312 325 else: 313 326 all_var[k] = getfield(ncref,all_varname[k-1]) 314 327 all_varname[k] = all_varname[k-1] ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] ; all_var2[k] = all_var2[k-1] 328 if winds: all_windu[k] = getfield(ncref,uchar) ; all_windv[k] = getfield(ncref,vchar) 315 329 else: errormess("fileref is missing!") 316 330 if ope == "-": all_var[k+1]= all_var[k-1] - all_var[k] … … 321 335 all_var[k+1]= 100.*(all_var[k-1] - masked)/masked 322 336 all_varname[k+1] = all_varname[k] ; all_time[k+1] = all_time[k] ; all_namefile[k+1] = all_namefile[k] ; all_var2[k+1] = all_var2[k] ; numplot = numplot+2 337 if winds: all_windu[k+1] = all_windu[k-1]-all_windu[k] ; all_windv[k+1] = all_windv[k-1] - all_windv[k] 323 338 elif ope in ["cat"]: 324 339 tabtime = all_time[0];tab = all_var[0];k = 1 … … 349 364 ### Time loop for plotting device 350 365 nplot = 1 ; error = False 351 linecycler = cycle(["-","--","-.",":"]) 366 if lstyle is not None: linecycler = cycle(lstyle) 367 else: linecycler = cycle(["-","--","-.",":"]) 352 368 print "********************************************" 353 369 while error is False: … … 492 508 493 509 if which == "unidim": 494 lbl = "" 495 if indexlat is not None: lbl = lbl + " ix" + str(indexlat[0]) 496 if indexlon is not None: lbl = lbl + " iy" + str(indexlon[0]) 497 if indexvert is not None: lbl = lbl + " iz" + str(indexvert[0]) 498 if indextime is not None: lbl = lbl + " it" + str(indextime[0]) 499 if lbl == "": lbl = namefiles[index_f] 500 if lbls is not None: lbl=lbls[nplot-1] 510 if lbls is not None: lbl=lbls[index_f] 511 else: 512 lbl = "" 513 if indexlat is not None: lbl = lbl + " ix" + str(indexlat[0]) 514 if indexlon is not None: lbl = lbl + " iy" + str(indexlon[0]) 515 if indexvert is not None: lbl = lbl + " iz" + str(indexvert[0]) 516 if indextime is not None: lbl = lbl + " it" + str(indextime[0]) 517 if lbl == "": lbl = namefiles[index_f] 501 518 502 519 if mrate is not None: x = y ## because swapaxes... … … 523 540 if mapmode == 1: m.contourf( x, y, what_I_plot_frame, zelevels, cmap = palette, alpha=trans) 524 541 elif mapmode == 0: contourf( x, y, what_I_plot_frame, zelevels, cmap = palette, alpha=trans) 542 if cross is not None and mapmode == 1: 543 idx,idy=m(cross[0][0],cross[0][1]) 544 mpl.pyplot.plot([idx],[idy],'+k',mew=0.5,ms=18) 525 545 else: 526 546 if mapmode == 1: m.pcolor( x, y, what_I_plot_frame, cmap = palette, vmin=zevmin, vmax=zevmax, alpha=trans) … … 553 573 zevminc, zevmaxc = calculate_bounds(what_I_plot_frame, vmin=min(what_I_plot_frame), vmax=max(what_I_plot_frame)) 554 574 zelevels = np.linspace(zevminc,zevmaxc,ticks/2) #20) 555 if var2 == 'HGT': zelevels = np.arange(-10000.,30000., 2000.)575 if var2 == 'HGT': zelevels = np.arange(-10000.,30000.,1000.) 556 576 if mapmode == 0: 557 577 what_I_plot_frame, x, y = define_axis( lon,lat,vert,time,indexlon,indexlat,indexvert,\ 558 578 itime,what_I_plot_frame, len(all_var2[index_f].shape),vertmode ) 559 cs = contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)#, linestyles='solid')560 elif mapmode == 1: cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 1 ) #0.33 colors='w' )# , alpha=0.5)#, linestyles='solid')579 cs = contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33, alpha=0.5, linestyles='solid') 580 elif mapmode == 1: cs = m.contour( x,y,what_I_plot_frame, zelevels, colors='k', linewidths = 0.33, alpha=0.5, linestyles='solid') 561 581 if which in ["regular","unidim"]: 562 582 … … 645 665 if zetitle[0] != "fill": zecb.ax.set_xlabel(zetitle[index_f]) ; zetitle[index_f]="" 646 666 647 667 648 668 ########################################################################## 649 669 ### Save the figure in a file in the data folder or an user-defined folder
Note: See TracChangeset
for help on using the changeset viewer.