Changeset 436 for trunk/UTIL/PYTHON/planetoplot.py
- Timestamp:
- Dec 1, 2011, 2:19:47 AM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/UTIL/PYTHON/planetoplot.py
r435 r436 89 89 if slon is not None: vlon = slon[0][0] 90 90 if slat is not None: vlat = slat[0][0] 91 if mrate is not None: mapmode = 0 ### THIS IS DIRTY. MAPMPODE=1 SHOULD WORK WITH MOVIES. WILL BE FIXED.92 91 if mapmode == 0: winds=False 93 92 elif mapmode == 1: 94 93 if svert is None: svert = readslices(str(level)) ; nvert=1 94 if stime is None and mrate is None: 95 stime = readslices(str(0)) ; ntime=1 ## this is a default choice 96 print "WELL... nothing about time axis. I took default: first time reference stored in file." 95 97 zelen = len(namefiles)*len(var) 96 98 numplot = zelen*nslices … … 235 237 ################################# 236 238 ### Time loop for plotting device 237 nplot = 1 ;error = False239 nplot = 1 ; error = False 238 240 print "********************************************" 239 241 while error is False: … … 265 267 for i in range(len(time)): time[i] = localtime ( interv[0]+time[i]*interv[1], 0.5*(wlon[0]+wlon[1]) ) 266 268 print "OK... WORKING WITH LOCAL TIMES" 267 else: errormess("local times not supported for GCM files. not too hard to modify the code though.")269 else: errormess("local times not supported. not too hard to modify the code though.") 268 270 if mrate is not None: indextime = None 269 elif mapmode == 1 and stime is None: indextime = 1270 271 else: indextime = getsindex(stime,((nplot-1)//(nlon*nlat*nvert))%ntime,time) 271 272 ltst = None … … 288 289 if mapmode == 0: 289 290 if typefile in ['mesoideal']: what_I_plot = dumpbdy(what_I_plot,0,stag='W') 290 itime=indextime 291 if len(what_I_plot.shape) is 3: itime=[0]291 itime=indextime 292 if len(what_I_plot.shape) is 3: itime=[0] 292 293 what_I_plot, x, y = define_axis(lon,lat,vert,time,indexlon,indexlat,indexvert,\ 293 294 itime,what_I_plot, len(all_var2[index_f].shape),vertmode) … … 306 307 varname = all_varname[index_f] 307 308 if varname: 308 what_I_plot, error = reducefield(all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat , d3=indexvert , yint=yintegral, alt=vert, anomaly=anomaly) 309 what_I_plot, error = reducefield( all_var[index_f], d4=indextime, d1=indexlon, d2=indexlat, d3=indexvert, \ 310 yint=yintegral, alt=vert, anomaly=anomaly ) 309 311 what_I_plot = what_I_plot*mult 310 312 if not error: 311 313 fvar = varname 312 314 if anomaly: fvar = 'anomaly' 313 ##### MAPMODE-SPECIFIC SETTINGS ##### 314 if mapmode == 1: 315 if typefile in ['mesoapi','meso']: what_I_plot = dumpbdy(what_I_plot,6) 316 elif mapmode == 0: 315 if mapmode == 0: 317 316 itime=indextime 318 317 if len(what_I_plot.shape) is 3:itime=[0] … … 328 327 if (fileref is not None) and (index_f is numplot-1): zevmin, zevmax = calculate_bounds(what_I_plot,vmin=minop,vmax=maxop) 329 328 else: zevmin, zevmax = calculate_bounds(what_I_plot,vmin=vmin,vmax=vmax) 330 if colorb in ["def","nobar"]: palette = get_cmap(name=defcolorb(fvar.upper()))331 elif (fileref is not None) and (index_f is numplot-1): palette = get_cmap(name="RdBu_r")332 else: palette = get_cmap(name=colorb)329 if colorb in ["def","nobar"]: palette = get_cmap(name=defcolorb(fvar.upper())) 330 elif (fileref is not None) and (index_f is numplot-1): palette = get_cmap(name="RdBu_r") 331 else: palette = get_cmap(name=colorb) 333 332 ##### simple 2D field and movies of 2D fields 334 333 if len(what_I_plot.shape) >= 2: 335 if (len(what_I_plot.shape) is 3 and mrate is None): 336 errormess("3D field in input but not rate specified for movie (use --rate RATE or specify --time TIME). Exit.") 334 if (len(what_I_plot.shape) is 3 and mrate is None): errormess("3D field. Use --rate RATE for movie or specify --time TIME. Exit.") 337 335 istart=0 338 336 if mrate is not None: iend=len(time)-1 … … 341 339 while imov <= iend: 342 340 what_I_plot_frame = what_I_plot 343 if mrate is not None: what_I_plot_frame = what_I_plot[imov,:,:] ; print "-> frame ",imov+1 344 if hole: what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax) 345 else: what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax) 346 if flagnolow: what_I_plot_frame = nolow(what_I_plot_frame) 341 if mrate is not None: 342 what_I_plot_frame = what_I_plot[imov,:,:] ; print "-> frame ",imov+1 343 if mapmode == 1: 344 m = define_proj(proj,wlon,wlat,back=back,blat=blat) ## this is dirty, defined above but out of imov loop 345 x, y = m(lon2d, lat2d) ## this is dirty, defined above but out of imov loop 346 if typefile in ['mesoapi','meso'] and mapmode == 1: what_I_plot_frame = dumpbdy(what_I_plot_frame,6) 347 if hole: what_I_plot_frame = hole_bounds(what_I_plot_frame,zevmin,zevmax) 348 else: what_I_plot_frame = bounds(what_I_plot_frame,zevmin,zevmax) 349 if flagnolow: what_I_plot_frame = nolow(what_I_plot_frame) 347 350 if not tile: 348 351 #zelevels = np.linspace(zevmin*(1. + 1.e-7),zevmax*(1. - 1.e-7)) #,num=20) … … 460 463 zeplot=outputname 461 464 462 pad_inches_value = 0.35 463 print "********** SAVE ", save 464 if save == 'png': 465 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 466 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 467 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 468 elif save == 'gui': show() 469 elif save == 'txt': print "Saved results in txt file." 470 else: 471 print "INFO: save mode not supported. using gui instead." 472 show() 465 if mrate is None: 466 pad_inches_value = 0.35 467 print "********** SAVE ", save 468 if save == 'png': 469 if display: makeplotres(zeplot,res=100.,pad_inches_value=pad_inches_value) #,erase=True) ## a miniature 470 makeplotres(zeplot,res=resolution,pad_inches_value=pad_inches_value,disp=False) 471 elif save in ['eps','svg','pdf']: makeplotres(zeplot,pad_inches_value=pad_inches_value,disp=False,ext=save) 472 elif save == 'gui': show() 473 elif save == 'txt': print "Saved results in txt file." 474 else: 475 print "INFO: save mode not supported. using gui instead." 476 show() 473 477 474 478 ###############
Note: See TracChangeset
for help on using the changeset viewer.