Changeset 1157 in lmdz_wrf
- Timestamp:
- Oct 7, 2016, 10:43:24 AM (9 years ago)
- Location:
- trunk/tools
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing.py
r1151 r1157 670 670 draw_2D_shad_cont(ncfile, values, varn) 671 671 ncfile= [ncfilevars],[ncfilevarc] files to use (one value, same file) 672 values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[ colorbar];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];[reverse];[timevals]672 values=[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyfmt];[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];[reverse];[timevals];[close] 673 673 [vnamefs],[vnamefc]: Name in the figure of the shaded and the contour variables 674 674 [dimvals/c]: list of [dimname]|[value] telling at which dimension of the … … 676 676 [dimxvn]: name of the variables with the values of the dimension of the x-axis 677 677 [dimyvn]: name of the variables with the values of the dimension of the y-axis 678 [colorbar]: name of the color bar 678 [dimxyfmt]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis 679 [dxs]: style of x-axis ('auto' for 'pretty') 680 'Nfix', values computed at even 'Ndx' 681 'Vfix', values computed at even 'Ndx' increments 682 'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10) 683 [dxf]: format of the labels at the x-axis 684 [Ndx]: Number of ticks at the x-axis 685 [ordx]: angle of orientation of ticks at the x-axis ('auto' for horizontal) 686 [dys]: style of y-axis ('auto' for 'pretty') 687 [dyf]: format of the labels at the y-axis 688 [Ndy]: Number of ticks at the y-axis 689 [ordy]: angle of orientation of ticks at the y-axis ('auto' for horizontal) 690 [colorbarvals]=[colbarn],[fmtcolorbar],[orientation] 691 [colorbarn]: name of the color bar 692 [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g) 693 [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal') 679 694 [ckind]: kind of contours 680 695 'cmap': as it gets from colorbar … … 682 697 'fixsigc,[colname]': fixed color [colname], >0 stright, <0 dashed line 683 698 [clabfmt]: format of the labels in the contour (None, also possible) 684 [smin/axv]: minimum and maximum value for the shading 699 [smin/axv]: minimum and maximum value for the shading or: 700 'Srange': for full range 701 'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean) 702 'Saroundminmax@val': for min*val,max*val 703 'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val), 704 percentile_(100-val)-median) 705 'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean) 706 'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median) 707 'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val), 708 percentile_(100-val)-median) 685 709 [sminc]:[smaxv]:[Nlev]: minimum, maximum and number of values for the contour 686 710 [figt]: title of the figure ('|' for spaces) … … 690 714 'flip',[x/y]: flip only the dimension [x] or [y] 691 715 [timevals]: [timen]|[units]|[kind]|[tfmt]|[label] time labels characteristics 692 [timen]; name of the time variable 693 [units]; units string according to CF conventions ([tunits] since 694 [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces) 695 [kind]; kind of output 696 'Nval': according to a given number of values as 'Nval',[Nval] 697 'exct': according to an exact time unit as 'exct',[tunit]; 698 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month, 699 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 700 'l': milisecond 701 [tfmt]; desired format 702 [label]; label at the graph ('!' for spaces) 716 [timen]; name of the time variable 717 [units]; units string according to CF conventions ([tunits] since 718 [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces) 719 [kind]; kind of output 720 'Nval': according to a given number of values as 'Nval',[Nval] 721 'exct': according to an exact time unit as 'exct',[tunit]; 722 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month, 723 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 724 'l': milisecond 725 [tfmt]; desired format 726 [label]; label at the graph ('!' for spaces) 727 [close]: Whether figure should be finished or not 703 728 valules= 'rh,ta;z|-1,x|-1;z|-1,x|-1;lat;pressure;BuPu;fixsigc,black;%d;0.,100.;195.,305.,7;Meridonal|average|of|rh|&|ta;pdf;flip@y;time!hours!since!1949/12/01|exct,5d|%d|date!([DD])' 704 729 varn= [varsn],[varcn] name of the variable to plot with shading variable with contour … … 711 736 quit() 712 737 713 expectargs = '[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[ colorbar];' + \714 '[c kind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];[figt];[kindfig];' +\715 '[ reverse];[timevals]'738 expectargs = '[vnamefs];[dimvals];[dimvalc];[dimxvn];[dimyvn];[dimxyfmt];' + \ 739 '[colorbarvals];[ckind];[clabfmt];[sminv],[smaxv];[sminc],[smaxv],[Nlev];' + \ 740 '[figt];[kindfig];[reverse];[timevals];[close]' 716 741 717 742 drw.check_arguments(fname,values,expectargs,';') … … 722 747 vdimxn = values.split(';')[3] 723 748 vdimyn = values.split(';')[4] 724 colbarn = values.split(';')[5] 725 countkind = values.split(';')[6] 726 countlabelfmt = values.split(';')[7] 727 shadminmax = values.split(';')[8] 728 contlevels = values.split(';')[9] 729 figtitle = values.split(';')[10].replace('|',' ') 730 figkind = values.split(';')[11] 731 revals = values.split(';')[12] 732 timevals = values.split(';')[13] 749 dimxyfmt = values.split(';')[5] 750 colbarvals = values.split(';')[6] 751 countkind = values.split(';')[7] 752 countlabelfmt = values.split(';')[8] 753 shadminmax = values.split(';')[9] 754 contlevels = values.split(';')[10] 755 figtitle = values.split(';')[11].replace('|',' ') 756 figkind = values.split(';')[12] 757 revals = values.split(';')[13] 758 timevals = values.split(';')[14] 759 close = gen.Str_Bool(values.split(';')[15]) 733 760 734 761 if2filenames = ncfile.find(',') … … 852 879 countlfmt = countlabelfmt 853 880 854 shading_nx = np.zeros((2), dtype=np.float) 855 shading_nx[0] = np.float(shadminmax.split(',')[0]) 856 shading_nx[1] = np.float(shadminmax.split(',')[1]) 881 shading_nx = [] 882 if shadminmax.split(',')[0][0:1] != 'S': 883 shading_nx.append(np.float(shadminmax.split(',')[0])) 884 else: 885 shading_nx.append(shadminmax.split(',')[0]) 886 887 if shadminmax.split(',')[1][0:1] != 'S': 888 shading_nx.append(np.float(shadminmax.split(',')[1])) 889 else: 890 shading_nx.append(shadminmax.split(',')[1]) 857 891 858 892 clevmin = np.float(contlevels.split(',')[0]) … … 870 904 print ' generating default ones: ',levels_cont 871 905 906 colbarn, fmtcolbar, colbaror = drw.colorbar_vals(colorbarvals,',') 907 908 xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimxyf,',') 909 xaxis = [xstyl, xaxf, Nxax, xaxor] 910 yaxis = [ystyl, yaxf, Nyax, yaxor] 911 872 912 if revals == 'None': revals = None 873 913 874 914 drw.plot_2D_shadow_contour_time(valshad, valcont, vnamesfig, ovalaxisv, \ 875 timevals, timepos, timelabels, ovalu, timelabel, dimt, dimnamesv, colbarn,\876 countkind, countlfmt, shading_nx, levels_cont, varunits, figtitle, figkind,\877 revals)915 timevals, timepos, timelabels, ovalu, timelabel, dimt, xaxis, yaxis, \ 916 dimnamesv, colbarn, fmtcolbar, colbaror, countkind, countlfmt, shading_nx, \ 917 levels_cont, varunits, figtitle, figkind, revals, close) 878 918 879 919 return … … 1429 1469 draw_topo_geogrid_boxes(ncfile, values) 1430 1470 ncfiles= ',' list of geo_em.d[nn].nc files to use (fisrt as topographyc reference) 1431 values= [minTopo],[maxTopo]:[lonlatL]:[title]:[graphic_kind]:[mapvalues]:[labels]:[leg loc]1471 values= [minTopo],[maxTopo]:[lonlatL]:[title]:[graphic_kind]:[mapvalues]:[labels]:[legvals] 1432 1472 [min/max]Topo: minimum and maximum values of topography to draw 1433 1473 lonlatL: limits of longitudes and latitudes [lonmin, latmin, lonmax, latmax] or None … … 1445 1485 * 'h', high 1446 1486 * 'f', full 1447 legloc= location of the legend (0, autmoatic) 1448 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 1449 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 1450 9: 'upper center', 10: 'center' 1487 [legvals]=[locleg]|[fontsize]: 1488 [locleg]: location of the legend (0, autmoatic) 1489 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 1490 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 1491 9: 'upper center', 10: 'center' 1492 [fontsize]: font size for the legend (auto for 12) 1451 1493 labels= labels to write in the graph 1452 1494 """ … … 1711 1753 draw_lines(ncfilens, values, varname): 1712 1754 ncfilens= [filen] ',' separated list of netCDF files 1713 values= [dimvname]:[valuesaxis]:[dimtit]:[leglabels]:[vtit]:[title]:[l ocleg]:[colns]:[lines]1714 [points]:[lwdths]:[psizes]:[freqv]:[figname]:[graphk] 1755 values= [dimvname]:[valuesaxis]:[dimtit]:[leglabels]:[vtit]:[title]:[legvals]:[colns]:[lines] 1756 [points]:[lwdths]:[psizes]:[freqv]:[figname]:[graphk]:[close] 1715 1757 [dimvname]: ',' list of names of the variable with he values of the common dimension 1716 1758 [valuesaxis]: which axis will be used for the values ('x', or 'y') … … 1719 1761 [vartit]: name of the variable in the graph 1720 1762 [title]: title of the plot ('|' for spaces) 1721 [locleg]: location of the legend (0, autmoatic) 1722 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 1723 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 1724 9: 'upper center', 10: 'center' 1763 [legvals]=[locleg]|[fontsize]: 1764 [locleg]: location of the legend (0, autmoatic) 1765 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 1766 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 1767 9: 'upper center', 10: 'center' 1768 [fontsize]: font size for the legend (auto for 12) 1725 1769 [colns]= ',' list of color names ('None' for automatic, single value for all the same) 1726 1770 [lines]= ',' list of style of lines ('None' for automatic, single value for all the same) … … 1731 1775 [figname]= name of the figure 1732 1776 [graphk]: kind of the graphic 1777 [close]: should figure be closed (finished) 1733 1778 varname= variable to plot 1734 1779 values= 'XLAT:x:latitude:32x32:$wss^{*}$:wss Taylor's turbulence term:pdf' … … 1743 1788 1744 1789 expectargs = '[dimvname]:[valuesaxis]:[dimtit]:[leglabels]:[vtit]:[title]:' + \ 1745 '[locleg]:[colns]:[lines]:[points]:[lwdths]:[psizes]:[freqv]:[figname]:[graphk]' 1790 '[legvals]:[colns]:[lines]:[points]:[lwdths]:[psizes]:[freqv]:[figname]:' + \ 1791 '[graphk]:[close]' 1746 1792 drw.check_arguments(fname,values,expectargs,':') 1747 1793 … … 1753 1799 vartit = values.split(':')[4] 1754 1800 title = values.split(':')[5].replace('|',' ') 1755 l ocleg = int(values.split(':')[6])1801 legvals = values.split(':')[6] 1756 1802 colns = gen.str_list(values.split(':')[7], ',') 1757 1803 lines = gen.str_list(values.split(':')[8], ',') … … 1762 1808 figname = values.split(':')[13] 1763 1809 graphk = values.split(':')[14] 1810 close = gen.Str_Bool(values.split(':')[15]) 1764 1811 1765 1812 Nfiles = len(ncfiles) … … 1840 1887 freqv = int(freqv0) 1841 1888 1889 # Legend 1890 locleg, legfontsize = drw.legend_values(legvals,'|') 1891 1842 1892 drw.plot_lines(dimvalues, varvalues, valuesaxis, dimtit, leglabels.split(','), \ 1843 vartit, varunits, title, locleg, colns, lines, points, lwdths, psizes, freqv,\1844 figname,graphk)1893 vartit, varunits, title, locleg, legfontsize, colns, lines, points, lwdths, \ 1894 psizes, freqv, figname, graphk, close) 1845 1895 1846 1896 return … … 1851 1901 ncfilens= [filen] ',' separated list of netCDF files 1852 1902 values= [dimvname];[valuesaxis];[dimtit];[leglabels];[vtit];[title];[rangevals];[timevals]; 1853 [legvals];[graphk];[collines];[points];[linewidths];[pointsizes];[pointfreq];[period] 1903 [legvals];[graphk];[collines];[points];[linewidths];[pointsizes];[pointfreq];[period];[close] 1854 1904 [dimvname]: ',' list of names of the variables with he values of the common dimension 1855 1905 [valuesaxis]: which axis will be used for the values ('x', or 'y') … … 1892 1942 '-1': all period 1893 1943 [beg],[end]: beginning and end of the period in reference time-units of first file 1944 [close]: Whether figure should be finished or not 1894 1945 varname0= ',' list of variable names to plot (assuming only 1 variable per file) 1895 1946 values= 'time;y;time ([DD]${[HH]}$);32x32;$wss^{*}$;wss Taylor's turbulence term;time|hours!since!1949-12-01_00:00:00;exct,12,h|%d$^{%H}$;2;pdf' … … 1906 1957 expectargs = expectargs + '[rangevals];[timevals];[legvals];[graphk];[lines];' 1907 1958 expectargs = expectargs + '[collines];[points];[linewidths];[pointsizes];' 1908 expectargs = expectargs + '[pointfreq];[period] '1959 expectargs = expectargs + '[pointfreq];[period];[close]' 1909 1960 drw.check_arguments(fname,values,expectargs,';') 1910 1961 … … 1918 1969 rangevals = values.split(';')[6] 1919 1970 timevals = values.split(';')[7] 1920 legval ues = values.split(';')[8]1971 legvals = values.split(';')[8] 1921 1972 graphk = values.split(';')[9] 1922 1973 lines0 = values.split(';')[10] … … 1927 1978 pointfreq0 = values.split(';')[15] 1928 1979 period = values.split(';')[16] 1980 close = gen.Str_Bool(values.split(':')[17]) 1929 1981 1930 1982 Nfiles = len(ncfiles) … … 2013 2065 if valmax != 'auto': valmax = np.float(valmax) 2014 2066 2015 locleg = int(legvalues.split('|')[0]) 2016 if legvalues.split('|')[1] == 'auto': 2017 legfontsize = 12 2018 else: 2019 legfontsize = int(legvalues.split('|')[1]) 2067 # Legend 2068 locleg, legfontsize = drw.legend_values(legvals,'|') 2020 2069 2021 2070 # Getting values … … 2186 2235 drw.plot_lines_time(dimvalues, varvalues, valuesaxis, dimtit, legvals, vartit, \ 2187 2236 varunits, timepos, timelabels, title, locleg, legfontsize, graphk, valmin, \ 2188 valmax, lines, collines, points, linewidths, pointsizes, pointfreq )2237 valmax, lines, collines, points, linewidths, pointsizes, pointfreq, close) 2189 2238 2190 2239 return … … 2415 2464 """ Function to plot a series of points 2416 2465 [values]= [ptasciifile]:[gtit]:[mapvalues]:[kindfigure]:[pointcolor]:[pointlabels]: 2417 [l ocleg]:[figureko]:[figuren]2466 [legvals]:[figureko]:[figuren] 2418 2467 [ptasciifile]:[file],[comchar],[collon],[collat],[lab] 2419 2468 [file]: column ASCII file with the location of the points … … 2439 2488 [pointcolor]: color for the points ('auto' for "red") 2440 2489 [pointlabels]: ',' of labels [only used if [collab]='None'] ('None' for no labels) 2441 [locleg]: location of the legend (0, autmoatic) 2442 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2443 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2444 9: 'upper center', 10: 'center' 2490 [legvals]=[locleg]|[fontsize]: 2491 [locleg]: location of the legend (0, autmoatic) 2492 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2493 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2494 9: 'upper center', 10: 'center' 2495 [fontsize]: font size for the legend (auto for 12) 2445 2496 [figureko]: kind of the output file (pdf, png, ...) 2446 2497 [figuren]: name of the figure … … 2579 2630 def draw_points_lonlat(filen, values): 2580 2631 """ Function to plot a series of lon/lat points 2581 filen= name of the file 2582 values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[ptsize]:[labels]:[locleg]:[figureK] 2583 [lonvarname]: name of the variable longitude 2584 [latvarname]: name of the variable latitude 2585 [gkind]: kind of graphical output 2586 [gtit]: graphic title '!' for spaces 2587 [ptcolor]: color of the points ('auto', for "red") 2588 [pttype]: type of point 2589 [ptsize]: size of point 2590 [labels]: ',' list of labels to use 2591 [locleg]: location of the legend (0, automatic) 2592 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2593 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2594 9: 'upper center', 10: 'center' 2595 [figureK]= kind of figure 2596 'legend': only points in the map with the legend with the names 2597 'labelled',[txtsize],[txtcol]: points with the names and size, color of text 2632 filen= name of the file 2633 values= [lonvarname]:[latvarname]:[gkind]:[gtit]:[ptcolor]:[pttype]:[ptsize]:[labels]:[legvals]:[figureK] 2634 [lonvarname]: name of the variable longitude 2635 [latvarname]: name of the variable latitude 2636 [gkind]: kind of graphical output 2637 [gtit]: graphic title '!' for spaces 2638 [ptcolor]: color of the points ('auto', for "red") 2639 [pttype]: type of point 2640 [ptsize]: size of point 2641 [labels]: ',' list of labels to use 2642 [legvals]=[locleg]|[fontsize]: 2643 [locleg]: location of the legend (0, autmoatic) 2644 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2645 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2646 9: 'upper center', 10: 'center' 2647 [fontsize]: font size for the legend (auto for 12) 2648 [figureK]= kind of figure 2649 'legend': only points in the map with the legend with the names 2650 'labelled',[txtsize],[txtcol]: points with the names and size, color of text 2598 2651 """ 2599 2652 fname = 'draw_points_lonlat' … … 2685 2738 def draw_timeSeries(filen, values, variables): 2686 2739 """ Function to draw a time-series 2687 draw_timeSeries(filen, values, variable): 2688 filen= name of the file 2689 values= [gvarname]:[timetit]:[tkind]:[timefmt]:[title]:[locleg]:[gkind]:[colorlines]:[pointtype]:[pointfreq] 2690 [gvarname]: name of the variable to appear in the graph 2691 [timetit]: title of the time axis (assumed x-axis, '|' for spaces) 2692 [tkind]: kind of time to appear in the graph (assumed x-axis) 2693 'Nval': according to a given number of values as 'Nval',[Nval] 2694 'exct': according to an exact time unit as 'exct',[tunit]; 2695 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month, 2696 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 2697 'l': milisecond 2698 [timefmt]: format of the time labels 2699 [title]: title of the graphic ('|' for spaces) 2700 [locleg]: location of the legend (0, automatic) 2701 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2702 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2703 9: 'upper center', 10: 'center' 2704 [gkind]: kind of graphical output 2705 [colorlines]: ',' list of colors for the lines, None for automatic, single 2740 draw_timeSeries(filen, values, variable): 2741 filen= name of the file 2742 values= [gvarname]:[timetit]:[tkind]:[timefmt]:[title]:[legvals]:[gkind]:[colorlines]:[pointtype]:[pointfreq] 2743 [gvarname]: name of the variable to appear in the graph 2744 [timetit]: title of the time axis (assumed x-axis, '|' for spaces) 2745 [tkind]: kind of time to appear in the graph (assumed x-axis) 2746 'Nval': according to a given number of values as 'Nval',[Nval] 2747 'exct': according to an exact time unit as 'exct',[tunit]; 2748 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month, 2749 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 2750 'l': milisecond 2751 [timefmt]: format of the time labels 2752 [title]: title of the graphic ('|' for spaces) 2753 [legvals]=[locleg]|[fontsize]: 2754 [locleg]: location of the legend (0, autmoatic) 2755 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2756 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2757 9: 'upper center', 10: 'center' 2758 [fontsize]: font size for the legend (auto for 12) 2759 [gkind]: kind of graphical output 2760 [colorlines]: ',' list of colors for the lines, None for automatic, single 2706 2761 value all the same 2707 [pointtype]: ',' list of type of points for the lines, None for automatic, single2762 [pointtype]: ',' list of type of points for the lines, None for automatic, single 2708 2763 value all the same 2709 [pointfreq]: frequency of point plotting, 'all' for all time steps2764 [pointfreq]: frequency of point plotting, 'all' for all time steps 2710 2765 variables= [varname],[timename] names of variable and variable with times 2711 2766 draw_timeSeries('wrfout_d01_1979-12-01_00:00:00_bottom_top_B6-E6-I1_south_north_B3-E3-I1_west_east_B26-E26-I1.nc', 'dt_con:time|($[DD]^{[HH]}$):exct,12,h:$%d^{%H}$:time|evolution|at|-1|6|3|26:1:pdf', 'LDQCON,time') … … 2974 3029 def draw_vals_trajectories(ncfile, values, variable): 2975 3030 """ Function to draw values from the outputs from 'compute_tevolboxtraj' 2976 draw_vals_trajectories(ncfile, values, variable) 2977 ncfile= [ncfile] ',' list of files to use 2978 values= [statisticskind]:[Tint]:[labels]@[locleg]:[gvarname]:[timetit]:[tkind]:[timefmt]:[title]:[gkind] 2979 [statisticskind]=[statistics][kind] 2980 [statistics]: which statistics to use, from: 'center', 'min', 'max', 'mean', 2981 'mean2', 'stdev' 2982 [kind]: 'box', 'circle' statistics taking the values from a box or a circle 2983 'trj': value following the trajectory 2984 [Tint]: [Tbeg]@[Tend] or None, interval of time to plot or -1 for all the times 2985 [labels]: ',' separated list of labels for the legend 2986 [locleg]: location of the legend (0, automatic) 2987 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 2988 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 2989 9: 'upper center', 10: 'center' 2990 [gvarname]: name of the variable to appear in the graph 2991 [timetit]: title of the time axis (assumed x-axis, '|' for spaces) 2992 [tkind]: kind of time to appear in the graph (assumed x-axis) 2993 'Nval': according to a given number of values as 'Nval',[Nval] 2994 'exct': according to an exact time unit as 'exct',[tunit]; 2995 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month, 2996 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 2997 'l': milisecond 2998 [timefmt]: format of the time labels 2999 [title]: title of the graphic ('|' for spaces) 3000 [gkind]: kind of graphical output 3001 variable= variable to use 3031 draw_vals_trajectories(ncfile, values, variable) 3032 ncfile= [ncfile] ',' list of files to use 3033 values= [statisticskind]:[Tint]:[labels]@[legvals]:[gvarname]:[timetit]:[tkind]:[timefmt]:[title]:[gkind] 3034 [statisticskind]=[statistics][kind] 3035 [statistics]: which statistics to use, from: 'center', 'min', 'max', 'mean', 3036 'mean2', 'stdev' 3037 [kind]: 'box', 'circle' statistics taking the values from a box or a circle 3038 'trj': value following the trajectory 3039 [Tint]: [Tbeg]@[Tend] or None, interval of time to plot or -1 for all the times 3040 [labels]: ',' separated list of labels for the legend 3041 [legvals]=[locleg]|[fontsize]: 3042 [locleg]: location of the legend (0, autmoatic) 3043 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 3044 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 3045 9: 'upper center', 10: 'center' 3046 [fontsize]: font size for the legend (auto for 12) 3047 [gvarname]: name of the variable to appear in the graph 3048 [timetit]: title of the time axis (assumed x-axis, '|' for spaces) 3049 [tkind]: kind of time to appear in the graph (assumed x-axis) 3050 'Nval': according to a given number of values as 'Nval',[Nval] 3051 'exct': according to an exact time unit as 'exct',[tunit]; 3052 tunit= [Nunits],[tu]; [tu]= 'c': centuries, 'y': year, 'm': month, 3053 'w': week, 'd': day, 'h': hour, 'i': minute, 's': second, 3054 'l': milisecond 3055 [timefmt]: format of the time labels 3056 [title]: title of the graphic ('|' for spaces) 3057 [gkind]: kind of graphical output 3058 variable= variable to use 3002 3059 """ 3003 3004 3060 fname = 'draw_vals_trajectories' 3005 3061 … … 3671 3727 """ Function to plot rivers' description from ORCHIDEE's routing scheme 3672 3728 values= [dimname]|[vardimname]|[value]:[basinvals]:[upstreamvals]:[mapvalues]: 3673 [gtit]:[kindfig]:[leg loc]:[figuren]3729 [gtit]:[kindfig]:[legvals]:[figuren] 3674 3730 'X/Y'|[dimname]|[vardimname]|[value]: ',', list for each basic dimension '|' separated of: 3675 3731 [dimname]: name of the dimension in the file … … 3694 3750 gtit= title of the graph ('|', for spaces) 3695 3751 kindfig= kind of figure 3696 legloc= location of the legend (0, automatic) 3697 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 3698 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 3699 9: 'upper center', 10: 'center' kfig= kind of figure 3752 [legvals]=[locleg]|[fontsize]: 3753 [locleg]: location of the legend (0, autmoatic) 3754 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 3755 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 3756 9: 'upper center', 10: 'center' 3757 [fontsize]: font size for the legend (auto for 12) 3700 3758 figuren= name of the figure 3701 3759 ncfile= file to use … … 3849 3907 draw_topo_geogrid(ncfile, values, varn) 3850 3908 ncfile= file to use 3851 values= [zlogs]:[plogs]:[title]:[graphic_kind]:[leg loc]3909 values= [zlogs]:[plogs]:[title]:[graphic_kind]:[legvals] 3852 3910 zlogs= zlog,dzlog 3853 3911 zlog: to use logarithmic scale on the height axis ('true/false') … … 3858 3916 title: title of the graph ('!' for spaces) 3859 3917 graphic_kind: kind of figure (jpg, pdf, png) 3860 legloc= location of the legend (0, automatic) 3861 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 3862 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 3863 9: 'upper center', 10: 'center' kfig= kind of figure 3918 [legvals]=[locleg]|[fontsize]: 3919 [locleg]: location of the legend (0, autmoatic) 3920 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 3921 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 3922 9: 'upper center', 10: 'center' 3923 [fontsize]: font size for the legend (auto for 12) 3864 3924 varn= [varnheight],[varnpres] 3865 3925 varnheight: name of the variable with the height of the vertical levels … … 4055 4115 """ Function to plot subbasin from 'routnig.nc' ORCDHIEE 4056 4116 ncfile= file to use produced with nc_var.py#subbasin function 4057 values= [subasiname]:[rangecolors]:[mapv]:[basinlinewidth]:[drawsubid]:[gtit]:[figkind]:[leg loc]:[figurename]4117 values= [subasiname]:[rangecolors]:[mapv]:[basinlinewidth]:[drawsubid]:[gtit]:[figkind]:[legvals]:[figurename] 4058 4118 [subasiname]= name of the subbasin ('!' for spaces) 4059 4119 [rcolor]= '@', list of 'r|g|b' 1-based colors (as much as first level sub-flow). 'None' for automatic … … 4072 4132 [drawsubid]= wehther sub-flow ids should be plot or not 4073 4133 [graphtit]= title of the graph ('|', for spaces) 4074 [lloc]= location of the legend (0, automatic) 4075 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 4076 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 4077 9: 'upper center', 10: 'center' kfig= kind of figure 4134 [legvals]=[locleg]|[fontsize]: 4135 [locleg]: location of the legend (0, autmoatic) 4136 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 4137 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 4138 9: 'upper center', 10: 'center' 4139 [fontsize]: font size for the legend (auto for 12) 4078 4140 [figname]= name of the figure 4079 4141 """ … … 4165 4227 """ Fucntion to plot two lines in different axes (x/x2 or y/y2) 4166 4228 values= [commonvardim]:[varangeA]:[varangeB]:[varangeaxis]:[axisvals]:[figvarns]:[colors]: 4167 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[l loc]:[figname]:[figkind]4229 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[legvals]:[figname]:[figkind] 4168 4230 [commonvardim]: name of the common variable-dimension 4169 4231 [varangeA]: ',' separated list of range (min,max) for A values ('None', automatic; 'Extrs' from values extremes) … … 4180 4242 [graphtitle]: title of the figure ('!' for spaces) 4181 4243 [labelaxis]: label in the figure of the common axis ('!' for spaces) 4182 [lloc]: location of the legend (0, automatic) 4183 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 4184 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 4185 9: 'upper center', 10: 'center' kfig= kind of figure 4244 [legvals]=[locleg]|[fontsize]: 4245 [locleg]: location of the legend (0, autmoatic) 4246 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 4247 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 4248 9: 'upper center', 10: 'center' 4249 [fontsize]: font size for the legend (auto for 12) 4186 4250 [figname]: name of the figure 4187 4251 [figkind]: kind of figure … … 4215 4279 graphtitle = values.split(':')[11].replace('!',' ') 4216 4280 labelaxis = values.split(':')[12].replace('!',' ') 4217 l loc = np.int(values.split(':')[13])4281 legvals = values.split(':')[13] 4218 4282 figname = values.split(':')[14] 4219 4283 figkind = values.split(':')[15] … … 4327 4391 2, colors, styles, marks, widths, sizemarks, 'None') 4328 4392 4393 # legend 4394 lloc, lsize = legend_values(legvals,'|') 4395 4329 4396 drw.plot_2lines(varvalsA, varvalsB, varvalsaxisA, varvalsaxisB, varangeA, \ 4330 4397 varangeB, varangeaxis, axisvals, figvarns, varunits, colvalues, lwidths, \ 4331 linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, figname, figkind) 4398 linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, lsize, figname, \ 4399 figkind) 4332 4400 4333 4401 … … 4335 4403 """ Function to plot two time-lines in different axes (x/x2 or y/y2) 4336 4404 values= [timevardim]:[varangeA]:[varangeB]:[timeaxisfmt]:[timeaxis]:[figvarns]:[colors]: 4337 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[l loc]:[figname]:[figkind]4405 [widths]:[styles]:[sizemarks]:[marks]:[graphtitle]:[labelaxis]:[legvals]:[figname]:[figkind] 4338 4406 [timevardim]: name of the common variable-dimension time 4339 4407 [varangeA]: ',' separated list of range (min,max) for A values ('None', automatic; 'Extrs' from values extremes) … … 4356 4424 [graphtitle]: title of the figure ('!' for spaces) 4357 4425 [labelaxis]: label in the figure of the common axis ('!' for spaces) 4358 [lloc]: location of the legend (0, automatic) 4359 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 4360 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 4361 9: 'upper center', 10: 'center' kfig= kind of figure 4426 [legvals]=[locleg]|[fontsize]: 4427 [locleg]: location of the legend (0, autmoatic) 4428 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 4429 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 4430 9: 'upper center', 10: 'center' 4431 [fontsize]: font size for the legend (auto for 12) 4362 4432 [figname]: name of the figure 4363 4433 [figkind]: kind of figure … … 4391 4461 graphtitle = values.split(':')[11].replace('!',' ') 4392 4462 labelaxis = values.split(':')[12].replace('!',' ') 4393 l loc = np.int(values.split(':')[13])4463 legvals = values.split(':')[13] 4394 4464 figname = values.split(':')[14] 4395 4465 figkind = values.split(':')[15] … … 4502 4572 2, colors, styles, marks, widths, sizemarks, 'None') 4503 4573 4574 # legend 4575 lloc, lsize = legend_values(legvals,'|') 4576 4504 4577 drw.plot_2lines_time(varvalsA, varvalsB, timevalsA, varvalsaxisB, varangeA, \ 4505 4578 varangeB, tpos, tlabels, timeaxis, figvarns, varunits, colvalues, lwidths, \ 4506 linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, figname, figkind) 4579 linekinds, psizes, pointkinds, graphtitle, labelaxis, lloc, lsize, figname, \ 4580 figkind) 4507 4581 4508 4582 #quit() -
trunk/tools/drawing_tools.py
r1152 r1157 32 32 # format_axes: Function to provide the format for the ticks of the axes in a figure 33 33 # graphic_range: Function to provide the ranges of a figure following different options 34 # legend_values: Function to determine the values for the legend 34 35 # searchInlist: 35 36 # datetimeStr_datetime: … … 1696 1697 #quit() 1697 1698 1698 1699 def legend_values(legstring, char): 1700 """ Function to determine the values for the legend 1701 legstring= char separated list of [locleg][char][fontsize]: 1702 [locleg]: location of the legend (0, autmoatic) 1703 1: 'upper right', 2: 'upper left', 3: 'lower left', 4: 'lower right', 1704 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 1705 9: 'upper center', 10: 'center' 1706 [fontsize]: font size for the legend (auto for 12) 1707 char= separation character 1708 """ 1709 fname = 'legend_values' 1710 1711 locleg = int(legstring.split('|')[0]) 1712 fontsize0 = legstring.split('|')[1] 1713 if fontsize0 == 'auto': 1714 fontsize = 12 1715 else: 1716 fontsize = int(fontsize0) 1717 1718 return locleg, fontsize 1699 1719 1700 1720 ####### ####### ####### ####### ####### ####### ####### ####### ####### ####### … … 4973 4993 return 4974 4994 4975 def plot_2D_shadow_contour_time(varsv,varcv,vnames,valv,timv,timpos,timlab,valu, \ 4976 timeu,axist,dimn,colorbar,ckind,clabfmt,vs,vc,uts,vtit,kfig,reva): 4995 def plot_2D_shadow_contour_time(varsv, varcv, vnames, valv, timv, timpos, timlab, \ 4996 valu, timeu, axist, xaxv, yaxv, dimn, colorbar, cbarfmt, cbaror, ckind, clabfmt, \ 4997 vs, vc, uts, vtit, kfig, reva, ifclose): 4977 4998 """ Adding labels and other staff to the graph 4978 4999 varsv= 2D values to plot with shading … … 4986 5007 timeu = units at the axes which is time 4987 5008 axist = which is the axis time 5009 xaxv= list with the x-axis paramteres [style, format, number and orientation] 5010 yaxv= list with the y-axis paramteres [style, format, number and orientation] 4988 5011 dimn= dimension names to plot 4989 5012 colorbar= name of the color bar to use 5013 cbarfmt= format of the numbers in the colorbar 5014 cbaror= orientation of the colorbar 4990 5015 ckind= contour kind 4991 5016 'cmap': as it gets from colorbar … … 5001 5026 * 'transpose': reverse the axes (x-->y, y-->x) 5002 5027 * 'flip'@[x/y]: flip the axis x or y 5028 ifclose= boolean value whether figure should be close (finish) or not 5003 5029 """ 5004 5030 ## import matplotlib as mpl … … 5012 5038 quit() 5013 5039 5040 # Check variable consistency 5041 if len(varsv.shape) != 2: 5042 print errormsg 5043 print ' ' + fname + ': wrong variable shape:',varsv.shape,'is has to be 2D!!' 5044 quit(-1) 5045 if len(varcv.shape) != 2: 5046 print errormsg 5047 print ' ' + fname + ': wrong variable contour:',varcv.shape,'is has to be 2D!!' 5048 quit(-1) 5049 5050 # Axis ticks 5014 5051 # Usually axis > x must be the time, thus... 5015 if axist == 'x': 5016 dimxv0 = valv.copy() 5017 dimyv0 = timv.copy() 5018 dimxt0 = np.array(pretty_int(valv.min(),valv.max(),10)) 5019 dimyt0 = np.array(timpos) 5020 dimxl0 = [] 5021 for i in range(len(dimxt0)): dimxl0.append(str(dimxt0[i])) 5022 dimyl0 = list(timlab) 5023 dimxT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(valu) + ')' 5024 dimyT0 = timeu 5025 else: 5026 dimxv0 = timv.copy() 5027 dimyv0 = valv.copy() 5028 dimxt0 = np.array(timpos) 5029 dimyt0 = np.array(pretty_int(valv.min(),valv.max(),10)) 5030 dimxl0 = list(timlab) 5031 dimyl0 = [] 5032 for i in range(len(dimyt0)): dimyl0.append(str(dimyt0[i])) 5033 dimxT0 = timeu 5034 dimyT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(valu) + ')' 5035 5036 if axist == 'x': 5037 reva = 'transpose' 5052 dimxv0 = timv.copy() 5053 dimyv0 = valv.copy() 5054 5055 dxn = dimxv0.min() 5056 dxx = dimxv0.max() 5057 dyn = dimyv0.min() 5058 dyx = dimyv0.max() 5059 5060 # Time ticks-labels are already given from another function 5061 dimxt0 = np.array(timpos) 5062 if yaxv[0] == 'pretty': 5063 dimyt0 = np.array(pretty_int(dyn,dyx,yaxv[2])) 5064 elif yaxv[0] == 'Nfix': 5065 dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*yaxv[2])) 5066 elif yaxv[0] == 'Vfix': 5067 dimyt0 = np.arange(0,dyx,yaxv[2]) 5068 5069 dimxl0 = list(timlab) 5070 dimyl0 = [] 5071 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 5072 5073 dimxT0 = timeu 5074 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')' 5075 5076 # Variable values will have time variable as 0 dimension 5077 reva = 'transpose' 5078 5079 if axist == 'y': 5080 valx0 = dimyv0 5081 valy0 = dimxv0 5082 dimxv0 = valx0 5083 dimyv0 = valy0 5084 5085 valx1 = dimyt0 5086 valy1 = dimxt0 5087 dimxt0 = valx1 5088 dimyt0 = valy1 5089 5090 valx2 = dimyl0 5091 valy2 = dimxl0 5092 dimxl0 = valx2 5093 dimyl0 = valy2 5094 5095 valx3 = dimyT0 5096 valy3 = dimxT0 5097 dimxT0 = valx3 5098 dimyT0 = valy3 5099 5100 reva = None 5038 5101 5039 5102 if reva is not None: … … 5056 5119 dy=varsv.shape[0] 5057 5120 5058 x,y = gen.lonlat2D(dimxv,dimyv) 5121 # No following data values 5122 # x,y = gen.lonlat2D(dimxv,dimyv) 5123 x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv)) 5124 y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv)) 5059 5125 5060 5126 plt.rc('text', usetex=True) 5061 5127 5062 plt.xticks(dimxt, dimxl )5063 plt.yticks(dimyt, dimyl )5128 plt.xticks(dimxt, dimxl, rotation=xaxv[3]) 5129 plt.yticks(dimyt, dimyl, rotation=yaxv[3]) 5064 5130 5065 5131 plt.xlim(0,dx) … … 5067 5133 5068 5134 plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1]) 5069 cbar = plt.colorbar() 5135 if cbaror == 'horizontal': 5136 cbar = plt.colorbar(format=cbarfmt,orientation=cbaror) 5137 # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib 5138 ticklabels= cbar.ax.get_xticklabels() 5139 Nticks = len(ticklabels) 5140 ticklabs = [] 5141 for itick in range(Nticks): ticklabs.append(ticklabels[itick].get_text()) 5142 cbar.ax.set_xticklabels(ticklabs,rotation=90) 5143 else: 5144 cbar = plt.colorbar(format=cbarfmt,orientation=cbaror) 5070 5145 5071 5146 # contour … … 5101 5176 5102 5177 # units labels 5103 cbar.set_label( vnames[0].replace('_','\_') + ' (' + units_lunits(uts[0]) + ')')5104 plt.annotate( vnames[1].replace('_','\_') +' (' + units_lunits(uts[1]) + ') [' +\5178 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')') 5179 plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' + \ 5105 5180 mincntS + ', ' + maxcntS + ']', xy=(0.55,0.04), xycoords='figure fraction', \ 5106 5181 color=coln) 5107 5182 5108 5183 figname = '2Dfields_shadow-contour' 5109 graphtit = vtit.replace('_','\_').replace('&','\&')5184 graphtit = gen.latex_text(vtit) 5110 5185 5111 5186 plt.title(graphtit) 5112 5187 5113 output_kind(kfig, figname, True)5188 output_kind(kfig, figname, ifclose) 5114 5189 5115 5190 return … … 5732 5807 return 5733 5808 5734 def plot_lines(vardv, varvv, vaxis, dtit, linesn, vtit, vunit, gtit, gloc, cs, ls,\5735 ps, ws, ss, fv, fign, kfig):5809 def plot_lines(vardv, varvv, vaxis, dtit, linesn, vtit, vunit, gtit, gloc, gsiz, cs, \ 5810 ls, ps, ws, ss, fv, fign, kfig, ifclose): 5736 5811 """ Function to plot a collection of lines 5737 5812 vardv= list of set of dimension values … … 5747 5822 5: 'right', 6: 'center left', 7: 'center right', 8: 'lower center', 5748 5823 9: 'upper center', 10: 'center' 5824 gsiz= fontsize of the legend 5749 5825 cs= list of color names 5750 5826 ls= list of style of lines … … 5755 5831 fign= name of the figure 5756 5832 kfig= kind of figure 5833 ifclose= boolean value whether figure should be close (finish) or not 5757 5834 plot_lines([np.arange(10)], [np.sin(np.arange(10)*np.pi/2.5)], 'y', 'time (s)', \ 5758 5835 ['2.5'], 'sin', '-', 'sinus frequency dependency', 'sinus', 'pdf') … … 5811 5888 5812 5889 plt.title(graphtit) 5813 plt.legend(loc=gloc )5890 plt.legend(loc=gloc, fontsize=gsiz) 5814 5891 5815 output_kind(kfig, fign, True)5892 output_kind(kfig, fign, ifclose) 5816 5893 5817 5894 return … … 6055 6132 6056 6133 def plot_lines_time(vardv, varvv, vaxis, dtit, linesn0, vtit, vunit, tpos, tlabs, \ 6057 gtit, gloc, gsize, kfig, vmin, vmax, lsl, coll, ptl, lwidth, psize, ptf ):6134 gtit, gloc, gsize, kfig, vmin, vmax, lsl, coll, ptl, lwidth, psize, ptf, ifclose): 6058 6135 """ Function to plot a collection of lines with a time axis 6059 6136 vardv= list of set of dimension values … … 6083 6160 psize= ',' list of point sizes 6084 6161 ptf= frequency of point plotting, 'all' for all time steps 6162 ifclose= boolean value whether figure should be close (finish) or not 6085 6163 6086 6164 plot_lines([np.arange(10)], [np.sin(np.arange(10)*np.pi/2.5)], 'y', 'time (s)', \ … … 6218 6296 print plt.xlim(),':', plt.ylim() 6219 6297 6220 output_kind(kfig, figname, True)6298 output_kind(kfig, figname, ifclose) 6221 6299 6222 6300 return … … 7518 7596 def plot_2lines(valsA, valsB, valsaxisA, valsaxisB, rangeA, rangeB, rangeaxis, \ 7519 7597 axisvals, varns, varus, cols, wdths, styls, szmks, marks, gtitle, axisn, gloc, \ 7520 fign, figk):7598 sloc, fign, figk): 7521 7599 """ Function to plot two lines in different axes (x/x2 or y/y2) 7522 7600 valsA= values to be plotted on axis x or y … … 7538 7616 axisn= label in the figure of the common axis 7539 7617 gloc= location of the legend 7618 gsiz= fontsize of the legend 7540 7619 fign= name of the figure 7541 7620 figk= kind of figure … … 7607 7686 titleloc = (0.5,1.075) 7608 7687 7609 graphtit = g title.replace('_','\_').replace('&','\&')7688 graphtit = gen.latex_text(gtitle) 7610 7689 7611 7690 plt.title(graphtit,position=titleloc) 7612 # plt.legend([lA, lB], loc=gloc )7691 # plt.legend([lA, lB], loc=gloc, fontsize=gsiz) 7613 7692 7614 7693 output_kind(figk, fign, True) … … 7616 7695 return 7617 7696 7618 7619 7697 def plot_2lines_time(valsA, valsB, valsaxisA, valsaxisB, rangeA, rangeB, valstaxis, \ 7620 7698 labelstaxis, taxis, varns, varus, cols, wdths, styls, szmks, marks, gtitle, axisn, \ 7621 gloc, fign, figk):7699 gloc, gsize, fign, figk): 7622 7700 """ Function to plot two time-lines in different axes (x/x2 or y/y2) 7623 7701 valsA= values to be plotted on axis x or y … … 7640 7718 axisn= label in the figure of the time axis 7641 7719 gloc= location of the legend 7720 gsiz= fontsize of the legend 7642 7721 fign= name of the figure 7643 7722 figk= kind of figure … … 7714 7793 titleloc = (0.5,1.075) 7715 7794 7716 # graphtit = gtitle.replace('_','\_').replace('&','\&')7717 7795 graphtit = gen.latex_text(gtitle) 7718 7796 7719 7797 plt.title(graphtit,position=titleloc) 7720 # plt.legend([lA, lB], loc=gloc) 7798 # plt.legend([lA, lB], loc=gloc, fontsize=gsiz) 7799 7721 7800 7722 7801 output_kind(figk, fign, True) -
trunk/tools/model_graphics.py
r1153 r1157 1831 1831 axisvals + ':' + ','.join(CFvplot) + ':' + Aline + ',' + Bline + \ 1832 1832 ':2.,2.:' + Akind + ',' + Bkind + ':2.,2.:,:' + figtit + ':' + \ 1833 spacedim + ':0:' + finame.replace('.'+kfig, '') + ':' + kfig 1833 spacedim + ':0,auto:' + finame.replace('.'+kfig, '') + ':' + kfig + \ 1834 ':True' 1834 1835 1835 1836 fvarS = ','.join(vplot) … … 1898 1899 timefmt + ':' + timeaxis + ':' + ','.join(CFvplot) + ':' + Aline + ',' \ 1899 1900 + Bline + ':2.,2.:' + Akind + ',' + Bkind + ':2.,2.:,:' + figtit + ':' \ 1900 + timelabel + ':0:' + finame.replace('.'+kfig, '') + ':' + kfig 1901 + timelabel + ':0,auto:' + finame.replace('.'+kfig, '') + ':' + \ 1902 + kfig + ':True' 1901 1903 1902 1904 fvarS = ','.join(vplot) … … 1990 1992 1991 1993 graphvals = spacedim + ':' + axisvals + ':' + sdlab + ':' + leglabels + \ 1992 ':' + CFvplot[0] + ':' + figtit + ':0:' + lines + ':' + kinds + ':' +\1994 ':' + CFvplot[0] +':'+ figtit + ':0|auto:' + lines +':'+ kinds + ':' + \ 1993 1995 marks +':'+ sizes +':'+ sizes +':all:'+ finame.replace('.'+kfig, '') + \ 1994 ':' + kfig 1996 ':' + kfig + ':True' 1995 1997 1996 1998 fvarS = vplot[0] … … 2065 2067 CFvplot[0] + ';' + figtit + ';None;time|' + '|'.join(tvals) + \ 2066 2068 ';0|auto;' + kfig + ';' + kinds + ';' + lines + ';' + marks + ';' + \ 2067 sizes + ';' + sizes + ';all;-1 '2069 sizes + ';' + sizes + ';all;-1;True' 2068 2070 2069 2071 fvarS = vplot[0] … … 2165 2167 2166 2168 graphvals = ','.join(CFvplot) 2167 graphvals = graphvals + '; '+ dims +';'+ cbar +\2168 ';' + ckind + ',' + cline + ';' + cfmt + ';' + srange + ';' + crange +\2169 graphvals = graphvals + ';auto;'+ dims +';'+ cbar + ',auto,auto' + ';' + \ 2170 ckind + ',' + cline + ';' + cfmt + ';' + srange + ';' + crange + \ 2169 2171 ',9;' + figtit + ';' + kfig + ';' + reverse + ';' + 'time|' + tunits + \ 2170 '|'+ timekind + '|' + timefmt + '|' + timelabel 2172 '|'+ timekind + '|' + timefmt + '|' + timelabel + ';True' 2171 2173 2172 2174 fvarS = ','.join(vplot)
Note: See TracChangeset
for help on using the changeset viewer.