Changeset 424 for trunk/UTIL
- Timestamp:
- Nov 25, 2011, 1:42:00 AM (13 years ago)
- Location:
- trunk/UTIL/PYTHON
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/README.PP
r394 r424 62 62 63 63 Goal: I want to plot results from two simulation files next to one another 64 pp.py -f diagfired.nc,diagfired.nc -x -v tsurf 64 pp.py -f diagfired.nc,diagfired.nc -v tsurf 65 66 Goal: I want to plot results for two different times in the file next to one another 67 pp.py -f diagfi.nc -v tsurf --time 4 -- time 7 68 69 Goal: I want to plot averaged results in the file from one time to another time 70 pp.py -f diagfi.nc -v tsurf --time 4,7 71 72 --- mesoscale stuff 73 Goal: I want to plot results for two different LOCAL times in the file next to one another 74 pp.py -f wrfout**** -v TSURF --time -4 -- time -7 65 75 66 76 *********************************************************************************** -
trunk/UTIL/PYTHON/myscript.py
r422 r424 36 36 parser.add_option('-s', '--stride', action='store',dest='ste', type="int", default=3, help='stride vectors [3]') 37 37 parser.add_option('-W', '--winds', action='store_true',dest='winds', default=False, help='wind vectors [False]') 38 parser.add_option('-n', '--num', action='store',dest='num', type="int", default=None, help='plot number (<0: plot LT -*numplot*) [1]')39 38 parser.add_option('-z', '--zoom', action='store',dest='zoom', type="float", default=None, help='zoom factor in %') 40 parser.add_option('-e', '--itstep', action='store',dest='it', type="int", default=None, help='stride time [4]')41 parser.add_option('-F', '--first', action='store',dest='frt', type="int", default=1, help='first subscript to plot [1]')42 39 parser.add_option('--blat', action='store',dest='blat', type="int", default=None, help='bounding latitude for stereographic plots [computed]') 43 40 … … 47 44 parser.add_option('--vert', action='append',dest='svert', type="string", default=None, help='slices along vert. 2 comma-separated values: averaging') 48 45 parser.add_option('--column', action='store_true',dest='column', default=False,help='changes --vert z1,z2 from MEAN to INTEGRATE along z') 49 parser.add_option('--time', action='append',dest='stime', type="string", default=None, help='slices along time. 2 comma-separated values: averaging ')46 parser.add_option('--time', action='append',dest='stime', type="string", default=None, help='slices along time. 2 comma-separated values: averaging. negative: local time [meso].') 50 47 parser.add_option('--xmax', action='store',dest='xmax', type="float", default=None, help='max value for x-axis in contour-plots [max(xaxis)]') 51 48 parser.add_option('--ymax', action='store',dest='ymax', type="float", default=None, help='max value for y-axis in contour-plots [max(yaxis)]') -
trunk/UTIL/PYTHON/planetoplot.py
r423 r424 15 15 target=None, 16 16 stride=3,\ 17 numplot=None,\18 17 var=None,\ 19 18 colorb="def",\ … … 26 25 zoom=None,\ 27 26 display=True,\ 28 itstep=None,\29 27 hole=False,\ 30 28 save="gui",\ … … 32 30 var2=None,\ 33 31 ndiv=10,\ 34 first=1,\35 32 mult=1.,\ 36 33 zetitle="fill",\ … … 93 90 if svert is None: svert = readslices(str(level)) ; nvert=1 94 91 zelen = len(namefiles)*len(var) 95 if numplot is None:numplot = zelen*nslices92 numplot = zelen*nslices 96 93 print "********** FILES, SLICES, VARS, TOTAL PLOTS: ", len(namefiles), nslices, len(var), numplot 97 94 print "********** MAPMODE: ", mapmode … … 230 227 ################################# 231 228 ### Time loop for plotting device 232 found_lct = False;nplot = 1;itime = first;error = False 233 if itstep is None and numplot > 0: itstep = int(24./numplot) 234 elif numplot <= 0: itstep = 1 229 nplot = 1;error = False 235 230 print "********************************************" 236 231 while error is False: 237 print "********** nplot", nplot, " itime",itime,"error",error232 print "********** nplot", nplot, "error",error 238 233 239 ### Which local time ?240 ltst = localtime ( interv[0]+itime*interv[1], 0.5*(wlon[0]+wlon[1]) )241 242 234 ### General plot settings 243 #print itime, int(ltst), numplot, nplot 244 if numplot >= 1: 245 if nplot > numplot: break 246 if numplot > 1: 247 if typefile not in ['geo']: subplot(subv,subh,nplot) 248 found_lct = True 249 ### If only one local time is requested (numplot < 0) 250 elif numplot <= 0: 251 if int(ltst) + numplot != 0: 252 itime += 1 253 if found_lct is True: break ## because it means LT was found at previous iteration 254 else: continue ## continue to iterate to find the correct LT 255 else: 256 found_lct = True 235 if nplot > numplot: break 236 if numplot > 1: subplot(subv,subh,nplot) 257 237 258 238 ### Map projection … … 260 240 m = define_proj(proj,wlon,wlat,back=back,blat=blat) 261 241 x, y = m(lon2d, lat2d) 262 #################################################################### 242 243 #################################################################### 263 244 ## get all indexes to be taken into account for this subplot and then reduce field 264 245 ## We plot 1) all lon slices 2) all lat slices 3) all vert slices 4) all time slices and then go to the next slice … … 272 253 else: yeah = len(namefiles)*len(var) ; index_f = ((nplot-1)//(nlon*nlat*nvert*ntime))%yeah 273 254 time = all_time[index_f] 274 275 if mapmode == 1 and stime is None: 276 indextime = itime 277 if len(var) != 1 or len(namefiles) != 1: indextime = first 278 else: 279 indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 280 if typefile in ['mesoapi','meso'] and indextime is not None: ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 281 #################################################################### 255 if stime is not None: 256 if stime[0][0] < 0: 257 if typefile in ['mesoapi','meso']: 258 for i in range(len(time)): time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) ) 259 stime = -stime ; print "OK... WORKING WITH LOCAL TIMES" 260 else: errormess("local times not supported for GCM files. not too hard to modify the code though.") 261 if mapmode == 1 and stime is None: indextime = 1 262 else: indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 263 if typefile in ['mesoapi','meso'] and indextime is not None: ltst = localtime ( interv[0]+indextime*interv[1], 0.5*(wlon[0]+wlon[1]) ) 264 #################################################################### 282 265 283 266 ticks = ndiv + 1 … … 418 401 # if indextime is not None: plottitle = plottitle + " time: " + str(min(time[indextime])) +" "+ str(max(time[indextime])) 419 402 title( plottitle ) 420 itime += itstep421 403 if nplot >= numplot: error = True 422 404 nplot += 1 … … 446 428 zeplot=outputname 447 429 448 if found_lct: 449 pad_inches_value = 0.35 450 print "********** SAVE ", save 451 if save == 'png': 452 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 453 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 454 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 455 elif save == 'gui': show() 456 elif save == 'txt': print "Saved results in txt file." 457 else: 458 print "INFO: save mode not supported. using gui instead." 459 show() 460 else: print "!!! Local time not found" 430 pad_inches_value = 0.35 431 print "********** SAVE ", save 432 if save == 'png': 433 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 434 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 435 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 436 elif save == 'gui': show() 437 elif save == 'txt': print "Saved results in txt file." 438 else: 439 print "INFO: save mode not supported. using gui instead." 440 show() 461 441 462 442 ############### -
trunk/UTIL/PYTHON/pp.py
r419 r424 125 125 name = planetoplot (zefiles,level=int(zelevel),vertmode=opt.itp,\ 126 126 proj=opt.proj,back=opt.back,target=opt.tgt,stride=opt.ste,var=zevars,\ 127 numplot=opt.num,colorb=opt.clb,winds=opt.winds,\127 colorb=opt.clb,winds=opt.winds,\ 128 128 addchar=lschar,interv=[zehour,zehourin],vmin=zevmin,vmax=zevmax,\ 129 129 tile=opt.tile,zoom=opt.zoom,display=opt.display,\ 130 itstep=opt.it,hole=opt.hole,save=opt.save,\131 anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv, first=opt.frt,\130 hole=opt.hole,save=opt.save,\ 131 anomaly=opt.anomaly,var2=opt.var2,ndiv=opt.ndiv,\ 132 132 mult=opt.mult,zetitle=opt.zetitle,\ 133 133 slon=zeslon,slat=zeslat,svert=zesvert,stime=zestime,\ … … 143 143 command = "" 144 144 for arg in sys.argv: command = command + arg + ' ' 145 if typefile not in ["meso","mesoapi"]: name = 'pycommand' 145 #if typefile not in ["meso","mesoapi"]: name = 'pycommand' 146 if opt.save is "gui": name = 'pycommand' 146 147 f = open(name+'.sh', 'w') 147 148 f.write(command)
Note: See TracChangeset
for help on using the changeset viewer.