- Timestamp:
- Apr 25, 2017, 9:28:24 PM (8 years ago)
- Location:
- trunk/tools
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/documentation/plotting/gallery.html
r1515 r1540 18 18 <A HREF="2Dshad_line.html"><IMG SRC="figs/hus-hgt_vert-sec_shad-line.png" ALT="2D shadow line" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A> 19 19 <A HREF="2Dshad_line_time.html"><IMG SRC="figs/hus-ps_vert-sec_shad-line_time.png" ALT="2D shadow line time" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A> 20 <A HREF="draw_bar.html"><IMG SRC="figs/bar_rain_CRU-NCEP_norm.png" ALT="bar char plot" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A> 20 21 <A HREF="barbs.html"><IMG SRC="figs/wind_barbs_2001111003_wss.png" ALT="wind-barbs" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A> 21 22 <A HREF="barbs.html"><IMG SRC="figs/wind_barbs_2001111003_uw.png" ALT="wind-barbs" STYLE="float:left;width:200px;height:200px" TARGET="value"></IMG></A> -
trunk/tools/documentation/plotting/plotting.html
r1515 r1540 14 14 <A CLASS="lc" HREF="2Dshad_line.html" TARGET="value">2D shadow line</A><BR> 15 15 <A CLASS="lc" HREF="2Dshad_line_time.html" TARGET="value">2D shadow line time</A><BR> 16 <A CLASS="lc" HREF="draw_bar.html" TARGET="value">bar</A><BR> 16 17 <A CLASS="lc" HREF="barbs.html" TARGET="value">barbs</A><BR> 17 18 <A CLASS="lc" HREF="basins.html" TARGET="value">ORCHIDEE's basins</A><BR> -
trunk/tools/drawing.py
r1524 r1540 45 45 ## e.g. # drawing.py -o draw_river_desc -f river_desc.nc -S 'Y|lat|lat|-1,X|lon|lon|-1:red,green:Blues:cyl,l:ORCDHIEE|rivers:png:0:or_rivers:True' -v Amazon,Parana 46 46 ## e.g. #drawing.py -f forcing_Amazonia.nc,forcing_Amazonia.nc -o draw_2lines_time -S 'tstep:Excts:Excts:exct,5,y;%Y:x:tas,wss:r,b:2.:-,-:None:,;,:WFD!forcing!evolution!at!Amazonia:year:0|12:../LaTeX/figs/forcing_Amazonia_tas-wss:png:yes' -v Tair,Wind 47 ## e.g. #drawing.py -o draw_bar -f 'Forcing_rainstats_OKstomate_CRUNCEP_spinup_SESA_norm_meanstd_stat2.nc;time_counter,0@12@1;time_counter;rainnorm:Forcing_rainstats_OKstomate_CRUNCEP_spinup_SACZ_norm_meanstd_stat2.nc;time_counter,0@12@1;time_counter;rainnorm' -S 'Stringlist,%s,January@Feburary@March@Arpil@May@June@July@August@September@October@November@December,25,pretty,auto,auto,auto:time!since!1958-01-01:pr:y:seconds:mmd-1:SESA,SACZ:#AA0000,#0000AA:1000000.:normalized!evolution!of!precipitaion!with!CRU-NCEP!forcing:0|10:png:bar_rain_CRU-NCEP_norm:yes' 47 48 48 49 … … 79 80 # draw_2lines: Fucntion to plot two lines in different axes (x/x2 or y/y2) 80 81 # draw_2lines_time: Function to plot two time-lines in different axes (x/x2 or y/y2) 82 # draw_bar: Function to plot a bar char figure with multiple sources 81 83 # draw_barbs: Function to plot wind barbs 82 84 # draw_basins: Function to plot river basins with their discharge vector and basins id (from 'routing.nc') … … 110 112 'draw_2D_shad_cont', 'draw_2D_shad_2cont', 'draw_2D_shad_cont_time', \ 111 113 'draw_2D_shad_line', \ 112 'draw_2D_shad_line_time', 'draw_bar bs', 'draw_basins',\114 'draw_2D_shad_line_time', 'draw_bar', 'draw_barbs', 'draw_basins', \ 113 115 'draw_2lines', 'draw_2lines_time', 'draw_lines', 'draw_lines_time', \ 114 116 'draw_Neighbourghood_evol', \ … … 6429 6431 return 6430 6432 6433 def draw_bar(ncfile, values): 6434 """ Function to plot a bar char figure with multiple sources 6435 ncfile = ':' list of [filen];[dimslice];[xvarn];[yvarn] 6436 [filen]: name of the file 6437 [dimslice]: '|' list of [dimn],[dimrange] 6438 [dimn]: name of the dimension 6439 [dimrange]: range for the slice 6440 * [integer]: which value of the dimension 6441 * -1: all along the dimension 6442 * -9: last value of the dimension 6443 * [beg]@[end]@[inc] slice from [beg] to [end] every [inc] 6444 * NOTE, no dim name all the dimension size 6445 [xvarn]: name of the variable to use for the x-positions 6446 [yvarn]: name of the variable to use for the values 6447 values = [dimxyfmt]:[xaxislab]:[yaxislab]:[xunits]:[yunits]:[aval]:[labels]:[colors]:[wdth]:[graphtit]: 6448 [legvalues]:[kindfig]:[fign]:[close] 6449 [dimxyfmt]=[dxs],[dxf],[Ndx],[ordx],[dys],[dyf],[Ndy],[ordy]: format of the values at each 6450 axis (or single 'auto' for 'auto','auto') 6451 [dxs]: style of x-axis ('auto' for 'pretty') 6452 'Nfix', values computed at even 'Ndx' 6453 'Stringlist', a given list of strings 6454 'Vfix', values computed at even 'Ndx' increments 6455 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10) 6456 [dxf]: format of the labels at the x-axis 6457 [Ndx]: Number of ticks at the x-axis (for 'Stringlist', '@' list of labels) 6458 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal) 6459 [dys]: style of y-axis ('auto' for 'pretty') 6460 [dyf]: format of the labels at the y-axis 6461 [Ndy]: Number of ticks at the y-axis 6462 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal) 6463 [xaxislab]: Label for the x-axis ('!' for spaces) 6464 [yaxislab]: Label for the y-axis ('!' for spaces) 6465 [xunits]: units of the x-label ('None' for no units) 6466 [yunits]: units of the y-label 6467 [aval]: which acis should be used for the values ('x' or 'y') 6468 [labels]: ',' list of labels for the legend ('None' for no-labels) 6469 [colors]: ',' list of colors (single value same color, 'auto' automatic) 6470 [wdth]: width of the bars 6471 [graphtit]: title of the figure '!' for spaces 6472 [legvalues]=[locleg]|[fontsize]: 6473 [locleg]: location of the legend (0, autmoatic) 6474 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 6475 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 6476 9: 'upper center', 10: 'center' 6477 [fontsize]: font size for the legend (auto for 12) 6478 [kindfig]: kind of output figure (png, pdf, ps) 6479 [fign]: name of the figure (without extension) 6480 [close]: whether figure should be close or not 6481 """ 6482 fname = 'draw_bar' 6483 6484 if values == 'h': 6485 print fname + '____________________________________________________________' 6486 print draw_bar.__doc__ 6487 quit() 6488 6489 expectargs = '[dimxyfmt]:[xaxislab]:[yaxislab]:[aval]:[xunits]:[yunits]:' + \ 6490 '[labels]:[colors]:[wdth]:[graphtit]:[legvalues]:[kindfig]:[fign]:[close]' 6491 drw.check_arguments(fname,values,expectargs,':') 6492 6493 dimxyfmt = values.split(':')[0] 6494 xaxislab = values.split(':')[1].replace('!',' ') 6495 yaxislab = values.split(':')[2].replace('!',' ') 6496 aval = values.split(':')[3] 6497 xunits = values.split(':')[4] 6498 yunits = values.split(':')[5] 6499 labels = gen.str_list(values.split(':')[6], ',') 6500 colors = gen.str_list(values.split(':')[7], ',') 6501 wdth = np.float(values.split(':')[8]) 6502 graphtit = values.split(':')[9].replace('!',' ') 6503 legvalues = values.split(':')[10] 6504 kindfig = values.split(':')[11] 6505 fign = values.split(':')[12] 6506 close = gen.Str_Bool(values.split(':')[13]) 6507 6508 # files and values 6509 filedvs = ncfile.split(':') 6510 xvals = [] 6511 yvals = [] 6512 6513 for fdv in filedvs: 6514 filen = fdv.split(';')[0] 6515 dimrange = fdv.split(';')[1] 6516 xvarn = fdv.split(';')[2] 6517 yvarn = fdv.split(';')[3] 6518 6519 if not os.path.isfile(filen): 6520 print errormsg 6521 print ' ' + fname + ': file "' + filen + '" does not exist !!' 6522 quit(-1) 6523 6524 onc = NetCDFFile(filen, 'r') 6525 if not onc.variables.has_key(xvarn): 6526 print errormsg 6527 print ' ' + fname + ': file "' + filen + "' does not have variable '" + \ 6528 xvarn + "' for the x-values !!" 6529 print ' available ones:', onc.variables.keys() 6530 onc.close() 6531 quit(-1) 6532 if not onc.variables.has_key(yvarn): 6533 print errormsg 6534 print ' ' + fname + ': file "' + filen + "' does not have variable '" + \ 6535 yvarn + "' for the y-values !!" 6536 print ' available ones:', onc.variables.keys() 6537 onc.close() 6538 quit(-1) 6539 6540 oxvar = onc.variables[xvarn] 6541 oyvar = onc.variables[yvarn] 6542 xvs, xdims = ncvar.slice_variable(oxvar, dimrange.replace(',',':')) 6543 yvs, ydims = ncvar.slice_variable(oyvar, dimrange.replace(',',':')) 6544 if len(xvs.shape) != 1: 6545 print errormsg 6546 print ' ' + fname + ': provided slice:', dimrange, "for variable '" + \ 6547 xvarn + "' does not provide a rank-1 value !!" 6548 print ' resultant shape:', xvs.shape, 'dimensions:', xdims, 'fix it!!' 6549 quit(-1) 6550 if len(yvs.shape) != 1: 6551 print errormsg 6552 print ' ' + fname + ': provided slice:', dimrange, "for variable '" + \ 6553 yvarn + "' does not provide a rank-1 value !!" 6554 print ' resultant shape:', yvs.shape, 'dimensions:', ydims, 'fix it!!' 6555 quit(-1) 6556 xvals.append(list(xvs)) 6557 yvals.append(list(yvs)) 6558 6559 onc.close() 6560 6561 xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimxyfmt,',') 6562 xaxis = [xstyl, xaxf, Nxax, xaxor] 6563 yaxis = [ystyl, yaxf, Nyax, yaxor] 6564 6565 # Legend 6566 legloc, legsiz = drw.legend_values(legvalues,'|') 6567 6568 # units 6569 if xunits == 'None': dxu = None 6570 else: dxu = xunits 6571 dyu = yunits 6572 6573 drw.plot_bars(xvals, yvals, xaxis, yaxis, dxu, dyu, aval, xaxislab, yaxislab, \ 6574 labels, colors, wdth, graphtit, legloc, legsiz, kindfig, fign, close) 6575 6576 return 6431 6577 6432 6578 #quit() … … 6450 6596 # Not checking file operation 6451 6597 Notcheckingfile = ['draw_2D_shad_cont', 'draw_2D_shad_2cont', \ 6452 'draw_2D_shad_cont_time',\6598 'draw_2D_shad_cont_time', \ 6453 6599 'draw_2D_shad_line', 'draw_2D_shad_line_time', 'draw_2lines', 'draw_2lines_time', \ 6454 'draw_ lines',\6600 'draw_bar', 'draw_lines', \ 6455 6601 'draw_lines_time', 'draw_points', 'draw_Taylor', 'draw_topo_geogrid_boxes', \ 6456 6602 'draw_trajectories', 'draw_vals_trajectories', 'variable_values'] … … 6508 6654 elif oper == 'draw_2D_shad_line_time': 6509 6655 draw_2D_shad_line_time(opts.ncfile, opts.values, opts.varname) 6656 elif oper == 'draw_bar': 6657 draw_bar(opts.ncfile, opts.values) 6510 6658 elif oper == 'draw_barbs': 6511 6659 draw_barbs(opts.ncfile, opts.values, opts.varname)
Note: See TracChangeset
for help on using the changeset viewer.