Changeset 760
- Timestamp:
- Aug 10, 2012, 2:03:29 AM (12 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/mcd/proto/index.html
r723 r760 72 72 <li>Presets 73 73 <!--<input type="button" value="Now!" onClick="DefaultDateValues();DefaultTimeValues();Convert2Ls();">--> 74 <input type="button" value="Curiosity" onClick="DateAndTimeValues(2012,8,6,0 0,00,00);Convert2Ls();PlaceValues(137.2,-4.6)">74 <input type="button" value="Curiosity" onClick="DateAndTimeValues(2012,8,6,05,30,00);Convert2Ls();PlaceValues(137.4,-4.6)"> 75 75 <input type="button" value="Phoenix" onClick="DateAndTimeValues(2008,5,25,23,38,23);Convert2Ls();PlaceValues(234.25,68.22)"> 76 76 <input type="button" value="Opportunity" onClick="DateAndTimeValues(2004,1,25,4,55,0);Convert2Ls();PlaceValues(354.47,-1.95)"> -
trunk/UTIL/PYTHON/myplot.py
r754 r760 866 866 #zelatmax = 90. - step/3 867 867 if char not in ["moll"]: 868 m.drawmeridians(np.r_[-180.:180.:steplon], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax) 869 m.drawparallels(np.r_[-90.:90.:step], labels=[1,0,0,0], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax) 868 if wlon[1]-wlon[0] < 2.: ## LOCAL MODE 869 m.drawmeridians(np.r_[-1.:1.:0.05], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, fmt='%5.2f') 870 m.drawparallels(np.r_[-1.:1.:0.05], labels=[1,0,0,0], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, fmt='%5.2f') 871 else: ## GLOBAL OR REGIONAL MODE 872 m.drawmeridians(np.r_[-180.:180.:steplon], labels=[0,0,0,1], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax) 873 m.drawparallels(np.r_[-90.:90.:step], labels=[1,0,0,0], color=zecolor, linewidth=zelinewidth, fontsize=fontsizemer, latmax=zelatmax) 870 874 if back: m.warpimage(marsmap(back),scale=0.75) 871 875 #if not back: … … 989 993 "def": "%.1e",\ 990 994 "PTOT": "%.0f",\ 995 "PSFC": "%.1f",\ 991 996 "HGT": "%.1e",\ 992 997 "USTM": "%.2f",\ … … 1423 1428 ## Author : AC 1424 1429 ## Handles calls to specific computations (e.g. wind norm, enrichment factor...) 1425 def select_ case(zvarname=None,znc=None,ztypefile=None,mode=None,ztsat=None,ylon=None,ylat=None,yalt=None,ytime=None):1430 def select_getfield(zvarname=None,znc=None,ztypefile=None,mode=None,ztsat=None,ylon=None,ylat=None,yalt=None,ytime=None): 1426 1431 from mymath import get_tsat 1427 1432 -
trunk/UTIL/PYTHON/myscript.py
r748 r760 29 29 30 30 ### GENERIC GRAPHICS SETTINGS 31 parser.add_option('-c', '--color', action='store',dest='clb', type="string", default="def", help='change colormap (also: nobar,onebar)') 31 parser.add_option('-c', '--color', action='store',dest='clb', type="string", default=None, help='change colormapS (also: nobar,onebar,def)') 32 parser.add_option('--trycol', action='store_true',dest='trycol', default=False, help='try 9 typical color palette') 32 33 parser.add_option('--div', action='store',dest='ndiv', type="int", default=10, help='number of divisions in colorbar [10]') 33 34 parser.add_option('--title', action='store',dest='zetitle', type="string", default="fill",help='customize the whole title') -
trunk/UTIL/PYTHON/planetoplot.py
r754 r760 23 23 stride=3,\ 24 24 var=None,\ 25 c olorb="def",\25 clb=None,\ 26 26 winds=False,\ 27 27 addchar=None,\ … … 72 72 cross=None,\ 73 73 facwind=1.,\ 74 trycol=False,\ 74 75 streamflag=False): 75 76 … … 84 85 zoomset,getcoorddef,getwinddef,whatkindfile,reducefield,bounds,getstralt,getfield,smooth,nolow,\ 85 86 getname,localtime,check_localtime,polarinterv,getsindex,define_axis,determineplot,readslices,bidimfind,getlschar,hole_bounds,\ 86 getdimfromvar,select_ case87 getdimfromvar,select_getfield 87 88 from mymath import deg,max,min,mean,writeascii,fig2data,fig2img 88 89 import matplotlib as mpl … … 113 114 ### we initialize a few variables 114 115 initime=-1 ; sslon = None ; sslat = None 116 k = 0 ; firstfile = True ; count = 0 117 ### we perform sanity checks and correct for insufficient information 115 118 if slon is not None: sslon = np.zeros([1,2]) 116 119 if slat is not None: sslat = np.zeros([1,2]) 117 k = 0 ; firstfile = True ; count = 0 120 if clb is None: clb = ["def"]*len(var) 121 elif len(clb) < len(var): clb = [clb[0]]*len(var) ; print "WARNING: less color than vars! setting all to 1st value." 122 ### we set option trycol i.e. the user wants to try a set of colorbars 123 if trycol: clb = ["Greys","Blues","YlOrRd","jet","spectral","hot","RdBu","RdYlBu","Paired"] ; zetitle = clb ; var = [var[0]]*9 118 124 ### we avoid specific cases not yet implemented 119 125 if mrate is not None and len(var) > 1: errormess("multivar not allowed in movies. should be fixed soon!") 120 ### we prepare number of plot fields [zelen] and plot instances [numplot] according to user choices126 ### we prepare number of plot fields [zelen] and number of plot instances [numplot] according to user choices 121 127 ### --> we support multifile and multivar plots : files + vars separated by commas are on the same figure 122 128 nlon, nlat, nvert, ntime, mapmode, nslices = determineplot(slon, slat, svert, stime) … … 131 137 ### we define the arrays for plot fields -- which will be placed within multiplot loops 132 138 all_var = [[]]*zelen ; all_var2 = [[]]*zelen 133 all_title = [[]]*zelen ; all_varname = [[]]*zelen ; all_namefile = [[]]*zelen ; all_time = [[]]*zelen 139 all_title = [[]]*zelen ; all_varname = [[]]*zelen ; all_namefile = [[]]*zelen ; all_time = [[]]*zelen ; all_colorb = [[]]*zelen 134 140 all_windu = [[]]*zelen ; all_windv = [[]]*zelen 135 141 136 142 ############################# 137 143 ### LOOP OVER PLOT FIELDS ### … … 163 169 ### we get the names of variables to be read. in case only one available, we choose this one. 164 170 ### (we take out of the test specific names e.g. UV is not in the file but used to ask a wind speed computation) 165 varname = select_ case(zvarname=var[vvv],znc=nc,ztypefile=typefile,mode='check')171 varname = select_getfield(zvarname=var[vvv],znc=nc,ztypefile=typefile,mode='check') 166 172 ### we get the names of wind variables to be read (if any) 167 173 if winds: … … 302 308 #################################################################### 303 309 304 ### we fill the arrays of varname, namefile, time at the current step considered (NB: why use both k and nnn ?)310 ### we fill the arrays of varname, namefile, time, colorbar at the current step considered (NB: why use both k and nnn ?) 305 311 all_varname[k] = varname 306 312 all_namefile[k] = namefile 307 313 all_time[k] = time 308 if var2: all_var2[k] = select_case(zvarname=var2,znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k]) 314 all_colorb[k] = clb[vvv] 315 if var2: all_var2[k] = select_getfield(zvarname=var2,znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k]) 309 316 if winds: all_windu[k] = getfield(nc,uchar) ; all_windv[k] = getfield(nc,vchar) 310 317 ### we fill the arrays of fields to be plotted at the current step considered 311 all_var[k] = select_ case(zvarname=all_varname[k],znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k])318 all_var[k] = select_getfield(zvarname=all_varname[k],znc=nc,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k]) 312 319 ### we inform the user about the loop then increment the loop. this is the last line of "for namefile in namefiles" 313 320 print "**** GOT SUBDATA:",k," NAMEFILE:",namefile," VAR:",varname, var2 ; k += 1 ; firstfile = False … … 324 331 if fileref is not None: 325 332 ncref = Dataset(fileref) 326 all_var[k] = select_ case(zvarname=all_varname[k-1],znc=ncref,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k],zvert=vert)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] 333 all_var[k] = select_getfield(zvarname=all_varname[k-1],znc=ncref,ztypefile=typefile,mode='getvar',ztsat=tsat,ylon=lon,ylat=lat,yalt=vert,ytime=all_time[k]) 334 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] ; all_colorb[k] = all_colorb[k-1] 328 335 if winds: all_windu[k] = getfield(ncref,uchar) ; all_windv[k] = getfield(ncref,vchar) 329 336 else: errormess("fileref is missing!") … … 334 341 masked.set_fill_value([np.NaN]) 335 342 all_var[k+1]= 100.*(all_var[k-1] - masked)/masked 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 343 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 344 if len(clb) >= zelen: all_colorb[k+1] = clb[-1] # last additional user-defined color is for operation plot 345 else: all_colorb[k+1] = "RdBu_r" # if no additional user-defined color... set a good default one 337 346 if winds: all_windu[k+1] = all_windu[k-1]-all_windu[k] ; all_windv[k+1] = all_windv[k-1] - all_windv[k] 338 347 elif ope in ["cat"]: … … 355 364 numplot = numplot + 1 ; all_time[k] = all_time[k-1] ; all_namefile[k] = all_namefile[k-1] 356 365 all_varname[k] = all_varname[k-2] + insert + all_varname[k-1] 357 ### only the operation plot 366 if len(clb) >= zelen: all_colorb[k] = clb[-1] # last additional user-defined color is for operation plot 367 else: all_colorb[k] = all_colorb[k-1] # if no additional user-defined color... set same as var 368 ### only the operation plot. do not mention colorb so that it is user-defined? 358 369 if "only" in ope: 359 370 numplot = 1 ; all_var[0] = all_var[k] … … 413 424 if mult != 2718.: what_I_plot = what_I_plot*mult 414 425 else: what_I_plot = np.log10(what_I_plot) ; print "log plot" 415 426 416 427 if var2: ### what is contoured. 417 428 what_I_plot_contour, error = reducefield( all_var2[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert, \ 418 yint=yintegral, alt=vert )429 yint=yintegral, alt=vert ) 419 430 if winds: ### what is plot as vectors. 420 431 vecx, error = reducefield( all_windu[index_f], d4=indextime, d3=indexvert, yint=yintegral, alt=vert) … … 443 454 changesubplot = (numplot > 1) and (len(what_I_plot.shape) != 1) ## default for 1D plots: superimposed. to be reworked for better flexibility. 444 455 if changesubplot: subplot(subv,subh,nplot) #; subplots_adjust(wspace=0,hspace=0) 456 colorb = all_colorb[index_f] 445 457 #################################################################### 446 458 if error: … … 466 478 if (fileref is not None) and (index_f == numplot-1): zevmin, zevmax = calculate_bounds(what_I_plot,vmin=minop,vmax=maxop) 467 479 else: zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax) 468 if (fileref is not None) and (index_f == numplot-1): colorb = "RdBu_r"480 #if (fileref is not None) and (index_f == numplot-1): colorb = "RdBu_r" 469 481 if colorb in ["def","nobar","onebar"]: palette = get_cmap(name=defcolorb(fvar.upper())) 470 482 else: palette = get_cmap(name=colorb) … … 750 762 if mrate is None: 751 763 pad_inches_value = 0.35 764 if wlon[1]-wlon[0] < 2.: pad_inches_value = 0.5 # LOCAL MODE (small values) 752 765 print "********** SAVE ", save 753 766 if save == 'png': -
trunk/UTIL/PYTHON/pp.py
r721 r760 55 55 if typefile in ["meso"]: 56 56 [lschar,zehour,zehourin] = getlschar ( zefiles[0] ) 57 if opt.var is None: opt.var = ["HGT"] ; opt.clb = "nobar"57 if opt.var is None: opt.var = ["HGT"] #; opt.clb = "nobar" # otherwise breaks the automatic one-var file capability 58 58 elif typefile in ["geo"]: 59 59 [lschar,zehour,zehourin] = ["",0,0] … … 162 162 name = planetoplot (zefiles,level=int(zelevel),vertmode=opt.itp,\ 163 163 proj=opt.proj,back=opt.back,target=opt.tgt,stride=opt.ste,var=zevars,\ 164 c olorb=opt.clb,winds=opt.winds,\164 clb=separatenames(opt.clb),winds=opt.winds,\ 165 165 addchar=lschar,interv=[zehour,zehourin],vmin=zevmin,vmax=zevmax,\ 166 166 tile=opt.tile,zoom=opt.zoom,display=opt.display,\ … … 175 175 mrate=opt.rate,mquality=opt.quality,trans=opt.trans,zarea=opt.area,axtime=opt.axtime,\ 176 176 redope=opt.redope,seevar=opt.seevar,xlab=opt.xlab,ylab=opt.ylab,lbls=separatenames(opt.labels),\ 177 lstyle=separatenames(opt.linestyle),cross=readslices(opt.mark),facwind=opt.facwind,streamflag=opt.stream) 177 lstyle=separatenames(opt.linestyle),cross=readslices(opt.mark),facwind=opt.facwind,\ 178 trycol=opt.trycol,streamflag=opt.stream) 178 179 print 'DONE: '+name 179 180 system("rm -f to_be_erased")
Note: See TracChangeset
for help on using the changeset viewer.