Changeset 201 for trunk/MESOSCALE/PLOT/PYTHON
- Timestamp:
- Jul 7, 2011, 7:10:54 PM (13 years ago)
- Location:
- trunk/MESOSCALE/PLOT/PYTHON
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE/PLOT/PYTHON/mylib/myplot.py
r199 r201 255 255 return m 256 256 257 def fmtvar (whichvar="def"): 258 fmtvar = { \ 259 "tk": "%.0f",\ 260 "tpot": "%.0f",\ 261 "def": "%.1e",\ 262 "PTOT": "%.0f",\ 263 "USTM": "%.2f",\ 264 } 265 if whichvar not in fmtvar: 266 whichvar = "def" 267 return fmtvar[whichvar] 268 257 269 def marsmap (whichone="vishires"): 258 270 whichlink = { \ 259 271 "vis": "http://maps.jpl.nasa.gov/pix/mar0kuu2.jpg",\ 260 "vishires": "http:// users.info.unicaen.fr/~karczma/TEACH/InfoGeo/Images/Planets/MarsMap_2500x1250.jpg",\272 "vishires": "http://dl.dropbox.com/u/11078310/MarsMap_2500x1250.jpg",\ 261 273 "mola": "http://www.lns.cornell.edu/~seb/celestia/mars-mola-2k.jpg",\ 262 "molabw": "http:// users.info.unicaen.fr/~karczma/TEACH/InfoGeo/Images/Planets/MarsElevation_2500x1250.jpg",\274 "molabw": "http://dl.dropbox.com/u/11078310/MarsElevation_2500x1250.jpg",\ 263 275 } 264 276 if whichone not in whichlink: -
trunk/MESOSCALE/PLOT/PYTHON/scripts/winds.py
r199 r201 16 16 numplot=4,\ 17 17 var=None,\ 18 colorb= None,\18 colorb=True,\ 19 19 winds=True,\ 20 20 addchar=None,\ 21 21 interv=[0,1],\ 22 22 vmin=None,\ 23 vmax=None): 23 vmax=None,\ 24 tile=False): 24 25 25 26 #################################################################################################################### … … 29 30 ### Load librairies and functions 30 31 from netCDF4 import Dataset 31 from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy 32 from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy,fmtvar 32 33 from mymath import deg,max,min,mean 33 34 from matplotlib.pyplot import contourf, subplot, figure, rcParams, savefig, colorbar, pcolor … … 111 112 elif dimension == 3: field = nc.variables[var][:,:,:] 112 113 elif dimension == 4: field = nc.variables[var][:,nvert,:,:] 113 dev = np.std(field)* 2.5114 dev = np.std(field)*3.0 114 115 if vmin is None: zevmin = mean(field) - dev 115 116 else: zevmin = vmin … … 117 118 else: zevmax = vmax 118 119 print "bounds ", zevmin, zevmax 119 120 120 121 ########################### 121 122 ### Get length of time axis … … 146 147 if numplot == 4: 147 148 sub = 221 148 fig.subplots_adjust(wspace = 0.1, hspace = 0.3) 149 #fig.subplots_adjust(wspace = 0.1, hspace = 0.3) 150 fig.subplots_adjust(wspace = 0.3, hspace = 0.3) 149 151 rcParams['font.size'] = int( rcParams['font.size'] * 2. / 3. ) 150 152 elif numplot == 2: … … 203 205 ### If only one local time is requested (numplot < 0) 204 206 elif numplot <= 0: 205 if ltst + numplot != 0:continue206 else: 207 if int(ltst) + numplot != 0: continue 208 else: found_lct = True 207 209 208 210 ### Map projection … … 216 218 if dimension == 2: what_I_plot = field[:,:] 217 219 elif dimension == 3: what_I_plot = field[i,:,:] 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') 220 if not tile: 221 zelevels = np.linspace(zevmin,zevmax) 222 contourf( x, y, what_I_plot, cmap = get_cmap(name=colorb), levels = zelevels ) 223 else: 224 pcolor( x, y, what_I_plot, cmap = get_cmap(name=colorb), vmin=zevmin, vmax=zevmax ) 225 if colorb: colorbar(fraction=0.05,pad=0.1,format=fmtvar(var)) 221 226 222 227 ### Vector plot … … 288 293 parser.add_option('-n', action='store', dest='numplot', type="int", default=4, help='number of plots (def=1)(<0: 1 plot of LT -*numplot*)') 289 294 parser.add_option('-i', action='store', dest='interp', type="int", default=None, help='interpolation method (2: press, 3: z-amr, 4:z-als)') 290 parser.add_option('-c', action='store', dest='colorb', type="string", default= None, help='change colormap (and draw a colorbar)')295 parser.add_option('-c', action='store', dest='colorb', type="string", default=True, help='change colormap (and draw a colorbar)') 291 296 parser.add_option('-x', action='store_false', dest='winds', default=True, help='flag: no wind vectors') 292 297 parser.add_option('-m', action='store', dest='vmin', type="float", default=None, help='bounding minimum value for color plot') 293 298 parser.add_option('-M', action='store', dest='vmax', type="float", default=None, help='bounding maximum value for color plot') 299 parser.add_option('-T', action='store_true', dest='tile', default=False, help='draw a tiled plot') 300 #parser.add_option('-V', action='store', dest='comb', type="float", default=None, help='a defined combination of variables') 294 301 (opt,args) = parser.parse_args() 295 302 if opt.namefile is None: … … 326 333 name = winds (zefile,int(zelevel),\ 327 334 proj=opt.proj,back=opt.back,target=opt.target,stride=opt.stride,var=opt.var,numplot=opt.numplot,colorb=opt.colorb,winds=opt.winds,\ 328 addchar=lschar,interv=[zehour,zehourin],vmin=opt.vmin,vmax=opt.vmax )335 addchar=lschar,interv=[zehour,zehourin],vmin=opt.vmin,vmax=opt.vmax,tile=opt.tile) 329 336 330 337 #########################################################
Note: See TracChangeset
for help on using the changeset viewer.