Changeset 781 in lmdz_wrf
- Timestamp:
- May 27, 2016, 6:15:05 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r776 r781 3333 3333 3334 3334 def draw_basins(ncfile, values, varns): 3335 """ Function to plot wind basins 3336 values= [lonlatbox]:[mapres]:[cbarname]:[xtrmbasin]:[mapdraw]:[veclength]:[freq]: 3337 [ifreq]:[gtit]:[kindfig]:[figuren] 3338 [lonlatbox]= [lonSW],[lonNE],[latSW],[latNE] coordinates of the lon/lat box 3339 [xtrmbasin]= pminbasin],[maxbasin] 3340 gtit= title of the graph ('|', for spaces) 3341 kindfig= kind of figure 3342 figuren= name of the figure 3343 ncfile= file to use 3344 """ 3345 fname = 'draw_basins' 3346 3347 if values == 'h': 3348 print fname + '_____________________________________________________________' 3349 print draw_vectors.__doc__ 3350 quit() 3351 3352 expectargs = '[lonlatbox]:[mapres]:[cbarname]:[xtrmbasin]:[mapdraw]:' + \ 3353 '[veclength]:[freq]:[ifreq]:[gtit]:[kindfig]:[figuren]' 3354 3355 drw.check_arguments(fname,values,expectargs,':') 3356 3357 varn='basins' 3358 lonname = 'nav_lon' 3359 latname = 'nav_lat' 3360 flowname = 'trip' 3361 3362 lonlims =[] 3363 latlims =[] 3364 3365 lonlims.append(np.float(values.split(':')[0].split(',')[0])) 3366 lonlims.append(np.float(values.split(':')[0].split(',')[1])) 3367 latlims.append(np.float(values.split(':')[0].split(',')[2])) 3368 latlims.append(np.float(values.split(':')[0].split(',')[3])) 3369 map_res = values.split(':')[1] 3370 cbarname = values.split(':')[2] 3371 vtit = 'basins' 3372 minbasin = np.int(values.split(':')[3].split(',')[0]) 3373 maxbasin = np.int(values.split(':')[3].split(',')[1]) 3374 mapdraw0 = gen.Str_Bool(values.split(':')[4]) 3375 veclength = np.float(values.split(':')[5]) 3376 freq0 = values.split(':')[6] 3377 ifreq = int(values.split(':')[7]) 3378 gtit = values.split(':')[8].replace('|',' ') 3379 kindfig = values.split(':')[9] 3380 figuren = values.split(':')[10] 3381 3382 if freq0 == 'None': freq = None 3383 3384 ofile = NetCDFFile(ncfile, 'r') 3385 3386 obasins = ofile.variables[varn] 3387 olon = ofile.variables[lonname] 3388 olat = ofile.variables[latname] 3389 oflow = ofile.variables[flowname] 3390 3391 lons = olon[:] 3392 lats = olat[:] 3393 3394 lon, lat = drw.lonlat2D(lons, lats) 3395 3396 nlon = lonlims[0] 3397 xlon = lonlims[1] 3398 nlat = latlims[0] 3399 xlat = latlims[1] 3400 3401 imin, imax, jmin, jmax = gen.ijlonlat(lon, lat, nlon, xlon, nlat, xlat) 3402 3403 drw.plot_basins(lon[jmin:jmax,imin:imax], lat[jmin:jmax,imin:imax], \ 3404 oflow[jmin:jmax,imin:imax], freq, cbarname+'@basin@-', \ 3405 obasins[jmin:jmax,imin:imax], veclength, minbasin, maxbasin, 'outflow', '-', \ 3406 'cyl,'+map_res, gtit, kindfig, figuren) 3407 3408 ofile.close() 3409 3410 return 3411 3412 def draw_basinsold(ncfile, values, varns): 3335 3413 """ Function to plot wind basins 3336 3414 values= [dimname]|[vardimname]|[value]:[vecvals]:[windlabs]:[mapvalues]: -
trunk/tools/drawing_tools.py
r776 r781 6214 6214 return 6215 6215 6216 def plot_basins(xvals,yvals,fvals,vecfreq,vecoln,veccolor,veclength, windn,wuts,\6216 def plot_basins(xvals,yvals,fvals,vecfreq,vecoln,veccolor,veclength,vcolmin,vcolmax,windn,wuts,\ 6217 6217 mapv,graphtit,kfig,figname): 6218 6218 """ Function to plot vectors … … 6283 6283 # From: http://stackoverflow.com/questions/15235630/matplotlib-pick-up-one-color-associated-to-one-value-in-a-colorbar 6284 6284 my_cmap = plt.cm.get_cmap(vcolor) 6285 vcolmin = np.min(veccolor[::yfreq,::xfreq])6286 vcolmax = np.max(veccolor[::yfreq,::xfreq])6287 vcolmin = 0.6288 vcolmax = 2500.6285 # vcolmin = np.min(veccolor[::yfreq,::xfreq]) 6286 # vcolmax = np.max(veccolor[::yfreq,::xfreq]) 6287 # vcolmin = 0. 6288 # vcolmax = 2500. 6289 6289 norm = mpl.colors.Normalize(vcolmin, vcolmax) 6290 6290 print 'min col:',vcolmin,'max col:',vcolmax … … 6354 6354 vvals = np.float(veclength)*vvals/wind 6355 6355 6356 vecolorvals = veccolor[::yfreq,::xfreq] 6357 vecolorvals = np.where(vecolorvals < vcolmin, vcolmin - 1, vecolorvals) 6358 vecolorvals = np.where(vecolorvals > vcolmax, vcolmax + 1, vecolorvals) 6359 6360 # plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq], \ 6361 # uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], veccolor[::yfreq,::xfreq], \ 6362 # cmap=plt.get_cmap(vcolor), pivot='middle') 6356 6363 plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq], \ 6357 uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], vec color[::yfreq,::xfreq],\6364 uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], vecolorvals, \ 6358 6365 cmap=plt.get_cmap(vcolor), pivot='middle') 6359 6366 cbar = plt.colorbar()
Note: See TracChangeset
for help on using the changeset viewer.