Changeset 668 in lmdz_wrf
- Timestamp:
- Jan 15, 2016, 11:19:46 AM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r665 r668 25 25 ## e.g. # drawing.py -o draw_points -S 'tslist.dat,#,3,2,1:SuperStorm|sfc|stations:cyl,i:labelled,8,black:auto:None:0:png:stations_loc' -f $HOME'/etudes/domains/WRFdynamicoSENS_SuperStorm/geo_em_west_east_B25-E180-I1_south_north_B160-E262-I1.nc,XLONG_M,XLAT_M,HGT_M,Time|0,height,0.,1500.,terrain,m' 26 26 ## e.g. # drawing.py -o draw_ptZvals -f geo_v2_2012102123_RR1.nc -S 'pracc:lon,lat:o:80:2,42,7,47,:values!of!values:Blues:cyl,l:pdf' -v pr 27 ## e.g. # drawing.py -f carteveg5km.nc -o draw_points_lonlat -S 'longitude:latitude:pdf:points!veget|type:green:.: None:0:legend'27 ## e.g. # drawing.py -f carteveg5km.nc -o draw_points_lonlat -S 'longitude:latitude:pdf:points!veget|type:green:.:0.5:None:0:legend' 28 28 29 29 main = 'drawing.py' … … 2440 2440 """ Function to plot a series of lon/lat points 2441 2441 filen= name of the file 2442 values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[ labels]:[locleg]:[figureK]2442 values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[ptsize]:[labels]:[locleg]:[figureK] 2443 2443 [lonvarname]: name of the variable longitude 2444 2444 [latvarname]: name of the variable latitude … … 2447 2447 [ptcolor]: color of the points ('auto', for "red") 2448 2448 [pttype]: type of point 2449 [ptsize]: size of point 2449 2450 [labels]: ',' list of labels to use 2450 2451 [locleg]: location of the legend (0, automatic) … … 2464 2465 2465 2466 expectargs = '[lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:' + \ 2466 '[ labels]:[locleg]:[figureK]'2467 '[ptsize]:[labels]:[locleg]:[figureK]' 2467 2468 2468 2469 drw.check_arguments(fname,len(expectargs.split(':')),values,':', \ … … 2475 2476 pointcolor = values.split(':')[4] 2476 2477 pointtype = values.split(':')[5] 2477 labelsv = values.split(':')[6] 2478 loclegend = values.split(':')[7] 2479 figureK = values.split(':')[8] 2478 pointsize = np.float(values.split(':')[6]) 2479 labelsv = values.split(':')[7] 2480 loclegend = values.split(':')[8] 2481 figureK = values.split(':')[9] 2480 2482 2481 2483 fname = 'points_lonlat' … … 2483 2485 onc = NetCDFFile(filen, 'r') 2484 2486 if not onc.variables.has_key(lonname): 2485 print err msg2487 print errormsg 2486 2488 print fname + ": file '" + filen + "' does not have longitudes '" + lonname +\ 2487 2489 "' !!" 2488 2490 quit(-1) 2489 2491 if not onc.variables.has_key(lonname): 2490 print err msg2492 print errormsg 2491 2493 print fname + ": file '" + filen + "' does not have longitudes '" + lonname +\ 2492 2494 "' !!" … … 2496 2498 olat = onc.variables[latname] 2497 2499 2500 Ndimlon = len(olon.shape) 2501 if Ndimlon == 1: 2502 lonvals = olon[:] 2503 latvals = olat[:] 2504 elif Ndimlon == 2: 2505 lonvals = olon[:].flatten() 2506 latvals = olat[:].flatten() 2507 elif Ndimlon == 3: 2508 lonvals = olon[1,:,:].flatten() 2509 latvals = olat[1,:,:].flatten() 2510 # Playing for Anna 2511 # lonvals = olon[:].flatten() 2512 # latvals = olat[:].flatten() 2513 elif Ndimlon == 4: 2514 lonvals = olon[1,0,:,:].flatten() 2515 latvals = olat[1,0,:,:].flatten() 2516 else: 2517 print errormsg 2518 print ' ' + fname + ': longitude size:',len(olon),' not ready!!' 2519 quit(-1) 2520 2498 2521 if labelsv == 'None': 2499 2522 labels = None … … 2501 2524 labels = labelsv.split(',') 2502 2525 2503 drw.plot_list_points( olon[:], olat[:], gtit, figureK, pointcolor, pointtype,\2504 labels, loclegend, kindfigure, fname)2526 drw.plot_list_points(lonvals, latvals, lonname, latname, gtit, figureK, pointcolor, pointtype, \ 2527 pointsize, labels, loclegend, kindfigure, fname) 2505 2528 2506 2529 onc.close() -
trunk/tools/drawing_tools.py
r665 r668 2763 2763 return 2764 2764 2765 def plot_list_points(xval, yval, v tit, figk, color, ptk, labels, lloc, kfig, figname):2765 def plot_list_points(xval, yval, varxn, varyn, vtit, figk, color, ptk, pts, labels, lloc, kfig, figname): 2766 2766 """ plotting points 2767 2767 [x/yval]: x,y values to plot 2768 var[x/y]n: names of the x,y variables 2768 2769 vtit= title of the graph ('|' for spaces) 2769 2770 figK= kind of figure … … 2772 2773 color= color for the points/labels ('auto', for "red") 2773 2774 ptk= kind of point 2775 pts= point size 2774 2776 labels= list of labels for the points (None, no labels) 2775 2777 lloc = localisation of the legend … … 2792 2794 for iv in range(len(xval)): 2793 2795 # print iv,xval[iv],yval[iv],labels[iv],ptkinds[N7pts] 2794 plt.plot(xval[iv],yval[iv], ptk, label=labels[iv])2796 plt.plot(xval[iv],yval[iv], ptk, markersize=pts, label=labels[iv]) 2795 2797 2796 2798 if figk[0:8] == 'labelled': … … 2804 2806 2805 2807 else: 2806 plt.plot(xval, yval, ptk, color=ptcol) 2808 plt.plot(xval, yval, ptk, markersize=pts, color=ptcol) 2809 2810 plt.xlabel(varxn) 2811 plt.ylabel(varyn) 2807 2812 2808 2813 graphtit = vtit.replace('_','\_').replace('&','\&')
Note: See TracChangeset
for help on using the changeset viewer.