Changeset 199 for trunk/MESOSCALE/PLOT/PYTHON
- Timestamp:
- Jul 5, 2011, 4:18:57 PM (13 years ago)
- Location:
- trunk/MESOSCALE/PLOT/PYTHON
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py
r197 r199 44 44 from timestuff import sol2ls 45 45 nc = Dataset(namefile) 46 if 'Times' in nc.variables :46 if 'Times' in nc.variables and 'vert' not in nc.variables: 47 47 zetime = nc.variables['Times'][0] 48 48 zetimestart = getattr(nc, 'START_DATE') -
trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py
r197 r199 18 18 colorb=None,\ 19 19 winds=True,\ 20 addchar=None, 21 interv=[0,1]): 20 addchar=None,\ 21 interv=[0,1],\ 22 vmin=None,\ 23 vmax=None): 22 24 23 25 #################################################################################################################### … … 28 30 from netCDF4 import Dataset 29 31 from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy 30 from mymath import deg 31 from matplotlib.pyplot import contourf, subplot, figure, rcParams, savefig, colorbar 32 from mymath import deg,max,min,mean 33 from matplotlib.pyplot import contourf, subplot, figure, rcParams, savefig, colorbar, pcolor 32 34 from matplotlib.cm import get_cmap 33 35 import numpy as np … … 109 111 elif dimension == 3: field = nc.variables[var][:,:,:] 110 112 elif dimension == 4: field = nc.variables[var][:,nvert,:,:] 111 113 dev = np.std(field)*2.5 114 if vmin is None: zevmin = mean(field) - dev 115 else: zevmin = vmin 116 if vmax is None: zevmax = mean(field) + dev 117 else: zevmax = vmax 118 print "bounds ", zevmin, zevmax 119 112 120 ########################### 113 121 ### Get length of time axis … … 208 216 if dimension == 2: what_I_plot = field[:,:] 209 217 elif dimension == 3: what_I_plot = field[i,:,:] 210 contourf( x, y, what_I_plot, 30, cmap = get_cmap(name=colorb) ) 211 if colorb: colorbar(fraction=0.05,pad=0.1) 218 #contourf( x, y, what_I_plot, 30, cmap = get_cmap(name=colorb), vmin=zevmin, vmax=zevmax ) 219 pcolor( x, y, what_I_plot, cmap = get_cmap(name=colorb), vmin=zevmin, vmax=zevmax ) 220 if colorb: colorbar(fraction=0.05,pad=0.1,format='%.1e') 212 221 213 222 ### Vector plot … … 281 290 parser.add_option('-c', action='store', dest='colorb', type="string", default=None, help='change colormap (and draw a colorbar)') 282 291 parser.add_option('-x', action='store_false', dest='winds', default=True, help='flag: no wind vectors') 292 parser.add_option('-m', action='store', dest='vmin', type="float", default=None, help='bounding minimum value for color plot') 293 parser.add_option('-M', action='store', dest='vmax', type="float", default=None, help='bounding maximum value for color plot') 283 294 (opt,args) = parser.parse_args() 284 295 if opt.namefile is None: … … 315 326 name = winds (zefile,int(zelevel),\ 316 327 proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds,\ 317 addchar=lschar,interv=[zehour,zehourin] )328 addchar=lschar,interv=[zehour,zehourin],vmin=opt.vmin,vmax=opt.vmax) 318 329 319 330 #########################################################
Note: See TracChangeset
for help on using the changeset viewer.