Changeset 232 for trunk/MESOSCALE_DEV/PLOT
- Timestamp:
- Jul 16, 2011, 1:06:45 AM (13 years ago)
- Location:
- trunk/MESOSCALE_DEV/PLOT/PYTHON
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/MESOSCALE_DEV/PLOT/PYTHON/mylib/myplot.py
r228 r232 35 35 return wlon,wlat 36 36 37 #def landers (map)38 # map.plot(blue_calf_lon,blue_calf_lat, 'gs')39 # return40 41 37 def getlschar ( namefile ): 42 38 #### strangely enough this does not work for api or ncrcat results! … … 256 252 return m 257 253 254 #### test temporaire 255 def putpoints (map,plot): 256 #### from http://www.scipy.org/Cookbook/Matplotlib/Maps 257 # lat/lon coordinates of five cities. 258 lats = [18.4] 259 lons = [-134.0] 260 points=['Olympus Mons'] 261 # compute the native map projection coordinates for cities. 262 x,y = map(lons,lats) 263 # plot filled circles at the locations of the cities. 264 map.plot(x,y,'bo') 265 # plot the names of those five cities. 266 wherept = 0 #1000 #50000 267 for name,xpt,ypt in zip(points,x,y): 268 plot.text(xpt+wherept,ypt+wherept,name) 269 ## le nom ne s'affiche pas... 270 return 271 272 258 273 def fmtvar (whichvar="def"): 259 274 fmtvar = { \ … … 265 280 "USTM": "%.2f",\ 266 281 "HFX": "%.0f",\ 282 "ICETOT": "%.1e",\ 267 283 } 268 284 if whichvar not in fmtvar: … … 278 294 "USTM": "YlOrRd",\ 279 295 "HFX": "RdYlBu",\ 296 "ICETOT": "YlGnBu",\ 280 297 } 281 298 if whichone not in whichcolorb: … … 305 322 "vis": "http://maps.jpl.nasa.gov/pix/mar0kuu2.jpg",\ 306 323 "vishires": "http://dl.dropbox.com/u/11078310/MarsMap_2500x1250.jpg",\ 324 "geolocal": "http://dl.dropbox.com/u/11078310/geolocal.jpg",\ 307 325 "mola": "http://www.lns.cornell.edu/~seb/celestia/mars-mola-2k.jpg",\ 308 326 "molabw": "http://dl.dropbox.com/u/11078310/MarsElevation_2500x1250.jpg",\ -
trunk/MESOSCALE_DEV/PLOT/PYTHON/scripts/winds.py
r225 r232 32 32 from netCDF4 import Dataset 33 33 from myplot import getcoord2d,define_proj,makeplotpng,simplinterv,vectorfield,ptitle,latinterv,getproj,wrfinterv,dumpbdy,\ 34 fmtvar,definecolorvec,getwinds,defcolorb,getprefix 34 fmtvar,definecolorvec,getwinds,defcolorb,getprefix,putpoints 35 35 from mymath import deg,max,min,mean 36 36 from matplotlib.pyplot import contour,contourf, subplot, figure, rcParams, savefig, colorbar, pcolor … … 124 124 elif dimension == 3: field = nc.variables[var][:,:,:] 125 125 elif dimension == 4: field = nc.variables[var][:,nvert,:,:] 126 dev = np.std(field)*3.0 127 if vmin is None: zevmin = mean(field) - dev 126 fieldcalc = field[ field < 9e+35 ] 127 dev = np.std(fieldcalc)*2.0 128 if vmin is None: zevmin = mean(fieldcalc) - dev 128 129 else: zevmin = vmin 129 if vmax is None: zevmax = mean(field ) + dev130 if vmax is None: zevmax = mean(fieldcalc) + dev 130 131 else: zevmax = vmax 131 132 if vmin == vmax: 132 zevmin = mean(field ) - dev ### for continuity133 zevmax = mean(field ) + dev ### for continuity134 print "field ", min(field ), max(field)133 zevmin = mean(fieldcalc) - dev ### for continuity 134 zevmax = mean(fieldcalc) + dev ### for continuity 135 print "field ", min(fieldcalc), max(fieldcalc) 135 136 print "bounds ", zevmin, zevmax 136 137 ### some already defined colormaps … … 157 158 elif typefile is 'mesoapi': 158 159 zelevel = int(nc.variables['vert'][nvert]) 159 if 'altitude' in nc.dimensions: stralt = "_"+str(zelevel)+"m-AMR" 160 elif 'altitude_abg' in nc.dimensions: stralt = "_"+str(zelevel)+"m-ALS" 161 elif 'bottom_top' in nc.dimensions: stralt = "_"+str(zelevel)+"m" 160 if abs(zelevel) < 10000.: strheight=str(zelevel)+"m" 161 else: strheight=str(int(zelevel/1000.))+"km" 162 if 'altitude' in nc.dimensions: stralt = "_"+strheight+"-AMR" 163 elif 'altitude_abg' in nc.dimensions: stralt = "_"+strheight+"-ALS" 164 elif 'bottom_top' in nc.dimensions: stralt = "_"+strheight 162 165 elif 'pressure' in nc.dimensions: stralt = "_"+str(zelevel)+"Pa" 163 166 else: stralt = "" … … 179 182 elif numplot == 2: 180 183 sub = 121 181 fig.subplots_adjust(wspace = 0.3 )184 fig.subplots_adjust(wspace = 0.35) 182 185 rcParams['font.size'] = int( rcParams['font.size'] * 3. / 4. ) 183 186 elif numplot == 3: … … 253 256 if not tile: 254 257 zelevels = np.linspace(zevmin,zevmax) 255 what_I_plot[ what_I_plot < zevmin ] = zevmin*(1. + 1.e-7) 256 what_I_plot[ what_I_plot > zevmax ] = zevmax*(1. - 1.e-7) 258 hole = True 259 if not hole: 260 what_I_plot[ what_I_plot < zevmin ] = zevmin*(1. + 1.e-7) 261 what_I_plot[ what_I_plot > 9e+35 ] = -9e+35 262 what_I_plot[ what_I_plot > zevmax ] = zevmax*(1. - 1.e-7) 257 263 contourf( x, y, what_I_plot, 10, cmap = palette, levels = zelevels ) 258 264 else: 259 265 pcolor( x, y, what_I_plot, cmap = palette, vmin=zevmin, vmax=zevmax ) 266 #putpoints(m,fig) 260 267 if var in ['HGT']: pass 261 268 elif colorb:
Note: See TracChangeset
for help on using the changeset viewer.