- Timestamp:
- Jan 13, 2016, 2:49:01 PM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r664 r665 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 28 28 29 main = 'drawing.py' … … 34 35 namegraphics = ['create_movie', 'draw_2D_shad', 'draw_2D_shad_time', \ 35 36 'draw_2D_shad_cont', 'draw_2D_shad_cont_time', 'draw_2D_shad_line', \ 36 'draw_2D_shad_line_time', 'draw_barbs', 'draw_points', 'draw_p tZvals',\37 'draw_timeSeries',\37 'draw_2D_shad_line_time', 'draw_barbs', 'draw_points', 'draw_points_lonlat', \ 38 'draw_ptZvals', 'draw_timeSeries', \ 38 39 'draw_topo_geogrid', \ 39 40 'draw_topo_geogrid_boxes', 'draw_trajectories', 'draw_vals_trajectories', \ … … 2436 2437 return 2437 2438 2439 def draw_points_lonlat(filen, values): 2440 """ Function to plot a series of lon/lat points 2441 filen= name of the file 2442 values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[labels]:[locleg]:[figureK] 2443 [lonvarname]: name of the variable longitude 2444 [latvarname]: name of the variable latitude 2445 [gkind]: kind of graphical output 2446 [gtit]: graphic title '!' for spaces 2447 [ptcolor]: color of the points ('auto', for "red") 2448 [pttype]: type of point 2449 [labels]: ',' list of labels to use 2450 [locleg]: location of the legend (0, automatic) 2451 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2452 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2453 9: 'upper center', 10: 'center' 2454 [figureK]= kind of figure 2455 'legend': only points in the map with the legend with the names 2456 'labelled',[txtsize],[txtcol]: points with the names and size, color of text 2457 """ 2458 fname = 'draw_points_lonlat' 2459 2460 if values == 'h': 2461 print fname + '_____________________________________________________________' 2462 print draw_points_lonlat.__doc__ 2463 quit() 2464 2465 expectargs = '[lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:' + \ 2466 '[labels]:[locleg]:[figureK]' 2467 2468 drw.check_arguments(fname,len(expectargs.split(':')),values,':', \ 2469 expectargs.split(',')) 2470 2471 lonname = values.split(':')[0] 2472 latname = values.split(':')[1] 2473 kindfigure = values.split(':')[2] 2474 gtit = values.split(':')[3].replace('!',' ') 2475 pointcolor = values.split(':')[4] 2476 pointtype = values.split(':')[5] 2477 labelsv = values.split(':')[6] 2478 loclegend = values.split(':')[7] 2479 figureK = values.split(':')[8] 2480 2481 fname = 'points_lonlat' 2482 2483 onc = NetCDFFile(filen, 'r') 2484 if not onc.variables.has_key(lonname): 2485 print errmsg 2486 print fname + ": file '" + filen + "' does not have longitudes '" + lonname +\ 2487 "' !!" 2488 quit(-1) 2489 if not onc.variables.has_key(lonname): 2490 print errmsg 2491 print fname + ": file '" + filen + "' does not have longitudes '" + lonname +\ 2492 "' !!" 2493 quit(-1) 2494 2495 olon = onc.variables[lonname] 2496 olat = onc.variables[latname] 2497 2498 if labelsv == 'None': 2499 labels = None 2500 else: 2501 labels = labelsv.split(',') 2502 2503 drw.plot_list_points(olon[:], olat[:], gtit, figureK, pointcolor, pointtype, \ 2504 labels, loclegend, kindfigure, fname) 2505 2506 onc.close() 2507 2508 return 2509 2438 2510 def draw_timeSeries(filen, values, variables): 2439 2511 """ Function to draw a time-series … … 3056 3128 elif oper == 'draw_points': 3057 3129 draw_points(opts.ncfile, opts.values) 3130 elif oper == 'draw_points_lonlat': 3131 draw_points_lonlat(opts.ncfile, opts.values) 3058 3132 elif oper == 'draw_ptZvals': 3059 3133 draw_ptZvals(opts.ncfile, opts.values, opts.varname) -
trunk/tools/drawing_tools.py
r655 r665 2763 2763 return 2764 2764 2765 def plot_list_points(xval, yval, vtit, figk, color, ptk, labels, lloc, kfig, figname): 2766 """ plotting points 2767 [x/yval]: x,y values to plot 2768 vtit= title of the graph ('|' for spaces) 2769 figK= kind of figure 2770 'legend': only points in the map with the legend with the names 2771 'labelled',[txtsize],[txtcol]: points with the names and size, color of text 2772 color= color for the points/labels ('auto', for "red") 2773 ptk= kind of point 2774 labels= list of labels for the points (None, no labels) 2775 lloc = localisation of the legend 2776 kfig= kind of figure (jpg, pdf, png) 2777 figname= name of the figure 2778 2779 """ 2780 fname = 'plot_points' 2781 # Canging line kinds every 7 pts (end of standard colors) 2782 ptkinds=['.','x','o','*','+','8','>','D','h','p','s'] 2783 2784 if color == 'auto': 2785 ptcol = "red" 2786 else: 2787 ptcol = color 2788 2789 plt.rc('text', usetex=True) 2790 2791 if labels is not None: 2792 for iv in range(len(xval)): 2793 # print iv,xval[iv],yval[iv],labels[iv],ptkinds[N7pts] 2794 plt.plot(xval[iv],yval[iv], ptk,label=labels[iv]) 2795 2796 if figk[0:8] == 'labelled': 2797 txtsize=int(figk.split(',')[1]) 2798 txtcol=figk.split(',')[2] 2799 for iv in range(len(xval)): 2800 plt.annotate(labels[iv], xy=(xval[iv],yval[iv]), xycoords='data', \ 2801 fontsize=txtsize, color=txtcol) 2802 elif figk == 'legend': 2803 plt.legend(loc=lloc) 2804 2805 else: 2806 plt.plot(xval, yval, ptk, color=ptcol) 2807 2808 graphtit = vtit.replace('_','\_').replace('&','\&') 2809 2810 plt.title(graphtit.replace('|', ' ')) 2811 2812 output_kind(kfig, figname, True) 2813 2814 return 2815 2765 2816 def plot_2Dfield(varv,dimn,colorbar,vn,vx,unit,olon,olat,ifile,vtit,zvalue,time,tk, \ 2766 2817 tkt,tobj,tvals,tind,kfig,mapv,reva): … … 3029 3080 def plot_Trajectories(lonval, latval, linesn, olon, olat, lonlatLims, gtit, kfig, \ 3030 3081 mapv, obsname): 3031 """ plotting points3082 """ plotting Trajectories 3032 3083 [lon/latval]= lon,lat values to plot (as list of vectors) 3033 3084 linesn: name of the lines
Note: See TracChangeset
for help on using the changeset viewer.