Changeset 204 for trunk/MESOSCALE/PLOT/PYTHON
- Timestamp:
- Jul 11, 2011, 1:53:25 AM (13 years ago)
- Location:
- trunk/MESOSCALE/PLOT/PYTHON
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py
r202 r204 264 264 265 265 def fmtvar (whichvar="def"): 266 267 268 269 270 271 272 273 274 275 276 266 fmtvar = { \ 267 "tk": "%.0f",\ 268 "tpot": "%.0f",\ 269 "def": "%.1e",\ 270 "PTOT": "%.0f",\ 271 "HGT": "%.1e",\ 272 "USTM": "%.2f",\ 273 } 274 if whichvar not in fmtvar: 275 whichvar = "def" 276 return fmtvar[whichvar] 277 277 278 278 def defcolorb (whichone="def"): 279 whichcolorb = { \ 280 "def": "spectral",\ 281 "HGT": "spectral",\ 282 "tk": "gist_heat",\ 283 "QH2O": "PuBu",\ 284 } 285 if whichone not in whichcolorb: 286 whichone = "def" 287 return whichcolorb[whichone] 279 whichcolorb = { \ 280 "def": "spectral",\ 281 "HGT": "spectral",\ 282 "tk": "gist_heat",\ 283 "QH2O": "PuBu",\ 284 "USTM": "YlOrRd",\ 285 #"RdPu",\ 286 } 287 if whichone not in whichcolorb: 288 whichone = "def" 289 return whichcolorb[whichone] 288 290 289 291 def definecolorvec (whichone="def"): -
trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py
r202 r204 22 22 vmin=None,\ 23 23 vmax=None,\ 24 tile=False): 24 tile=False,\ 25 zoom=None): 25 26 26 27 #################################################################################################################### … … 84 85 elif proj == "lcc": [wlon,wlat] = wrfinterv(lon2d,lat2d) 85 86 else: [wlon,wlat] = simplinterv(lon2d,lat2d) 87 if zoom: 88 dlon = abs(wlon[1]-wlon[0])/2. 89 dlat = abs(wlat[1]-wlat[0])/2. 90 [wlon,wlat] = [ [wlon[0]+zoom*dlon/100.,wlon[1]-zoom*dlon/100.],\ 91 [wlat[0]+zoom*dlat/100.,wlat[1]-zoom*dlat/100.] ] 92 print "zoom %",zoom,wlon,wlat 86 93 87 94 ############################################################################## … … 219 226 if dimension == 2: what_I_plot = field[:,:] 220 227 elif dimension == 3: what_I_plot = field[i,:,:] 228 palette = get_cmap(name=colorb) 229 #palette.set_over('b', 1.0) 221 230 if not tile: 222 231 zelevels = np.linspace(zevmin,zevmax) 223 contourf( x, y, what_I_plot, cmap = get_cmap(name=colorb), levels = zelevels )232 contourf( x, y, what_I_plot, 10, cmap = palette, levels = zelevels ) 224 233 else: 225 pcolor( x, y, what_I_plot, cmap = get_cmap(name=colorb), vmin=zevmin, vmax=zevmax )234 pcolor( x, y, what_I_plot, cmap = palette, vmin=zevmin, vmax=zevmax ) 226 235 if var in ['HGT']: pass 227 elif colorb: colorbar(fraction=0.05,pad=0.1,format=fmtvar(var)) 228 236 elif colorb: 237 ndiv = 10 238 colorbar(fraction=0.05,pad=0.1,format=fmtvar(var),\ 239 ticks=np.linspace(zevmin,zevmax,ndiv+1),\ 240 extend='max',spacing='proportional') 241 # both min max neither 229 242 ### Vector plot 230 243 if winds: … … 296 309 parser.add_option('-m', action='store', dest='vmin', type="float", default=None, help='bounding minimum value for color plot') 297 310 parser.add_option('-M', action='store', dest='vmax', type="float", default=None, help='bounding maximum value for color plot') 298 parser.add_option('-T', action='store_true', dest='tile', default=False, help='draw a tiled plot') 311 parser.add_option('-T', action='store_true', dest='tile', default=False, help='draw a tiled plot (no blank zone)') 312 parser.add_option('-z', action='store', dest='zoom', type="float", default=None, help='zoom factor in %') 299 313 #parser.add_option('-V', action='store', dest='comb', type="float", default=None, help='a defined combination of variables') 300 314 (opt,args) = parser.parse_args() … … 332 346 name = winds (zefile,int(zelevel),\ 333 347 proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds,\ 334 addchar=lschar,interv=[zehour,zehourin],vmin=opt.vmin,vmax=opt.vmax,tile=opt.tile )348 addchar=lschar,interv=[zehour,zehourin],vmin=opt.vmin,vmax=opt.vmax,tile=opt.tile,zoom=opt.zoom) 335 349 print 'Done: '+name 336 350
Note: See TracChangeset
for help on using the changeset viewer.