- Timestamp:
- Sep 1, 2016, 8:14:41 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/model_graphics.py
r1078 r1080 1625 1625 axisvals + ':' + ','.join(CFvplot) + ':' + Aline + ',' + Bline + \ 1626 1626 ':2.,2.:' + Akind + ',' + Bkind + ':,:' + figtit + ':' + spacedim + \ 1627 ':0:' + finame + ':' + kfig1627 ':0:' + finame.replace('.'+kfig, '') + ':' + kfig 1628 1628 1629 1629 fvarS = ','.join(vplot) … … 1692 1692 timefmt + ':' + timeaxis + ':' + ','.join(CFvplot) + ':' + Aline + ',' \ 1693 1693 + Bline + ':2.,2.:' + Akind + ',' + Bkind + ':2.,2.:,:' + figtit + ':' \ 1694 + timelabel + ':0:' + finame + ':' + kfig1694 + timelabel + ':0:' + finame.replace('.'+kfig, '') + ':' + kfig 1695 1695 1696 1696 fvarS = ','.join(vplot) … … 1885 1885 return 1886 1886 1887 def optitle(op,opexp): 1888 """ Function to creat the operation section in the title of a figure ('!' for spaces) 1889 op= '+' separated list of operations 1890 opexp= dictionary with the `explanation'(text in title) to appear for each operation 1891 >>> optitle('pinterp+xmean+tmean',{'pinterp':'pinterp', 'xmean':'xmean', 'tmean':'tmean'}) 1892 $_{[pinterp\!xmean\!tmean]}$ 1893 """ 1894 fname = 'optitle' 1895 1896 opvals = op.split('+') 1897 for op1 in opvals: 1898 if not opexp.has_key(op1): 1899 print errmsg 1900 print ' '+fname+": no explanation for operation '"+op1+"' !!" 1901 print ' provided:', opexp.keys() 1902 quit(-1) 1903 if op1 == opvals[0]: 1904 titop = '$_{[' + opexp[op1].replace(' ','!') 1905 if len(opvals) == 1: titop = titop + ']}$' 1906 elif op1 == opvals[len(opvals)-1]: 1907 titop = titop + '\!' + opexp[op1].replace(' ','!') + ']}$' 1908 else: 1909 titop = titop + '\!' + opexp[op1].replace(' ','!') 1910 1911 return titop 1912 1913 def create_figure_title(mod,exp,varops,explop): 1914 """ Function to create the title of a figure ('!' for spaces) 1915 mod: model name 1916 exp: experiment name 1917 varops: list with [var]|[op] values from wich create the title 1918 explop: dictionary with the `explanation'(text in title) to appear for each operation 1919 >>> expops = {'pinterp':'pinterp', 'xmean':'xmean', 'tmean':'tmean', 'last':'last'} 1920 >>> create_figure_title('WRF','current',['ua|pinterp+xmean+tmean', 'va|pinterp+xmean+tmean'], expops) 1921 WRF!current!ua!&!va$_{[pinterp\!xmean\!tmean]}$ 1922 >>> create_figure_title('WRF','current',['ua|pinterp+xmean+tmean', 'ua|pinterp+xmean+last'], expops) 1923 WRF!current!ua$_{[pinterp\!xmean\!tmean]}$!&!!$_{[pinterp\!xmean\!last]}$ 1924 >>> create_figure_title('WRF','current',['ua|pinterp+xmean+tmean', 'va|pinterp+xmean+last'], expops) 1925 WRF!current!ua$_{[pinterp\!xmean\!tmean]}$!&!va$_{[pinterp\!xmean\!last]}$ 1926 """ 1927 fname = 'create_figure_title' 1928 1929 titfig = mod + '!' + exp + '!' 1930 1931 varns = [] 1932 opns = [] 1933 for varop in varops: 1934 vn = varop.split('|')[0] 1935 op = varop.split('|')[1] 1936 varns.append(vn) 1937 opns.append(op) 1938 if varop == varops[0]: 1939 allvarequal = True 1940 allopequal = True 1941 varinfig = vn 1942 opinfig = op 1943 else: 1944 if vn != varinfig: allvarequal = False 1945 if op != opinfig: allopequal = False 1946 1947 Nvars = len(varns) 1948 Nops = len(opns) 1949 1950 if allvarequal: 1951 titfig = titfig + '!' + varns[0] 1952 if allopequal: 1953 opS = optitle(op,explop) 1954 titfig = titfig + opS 1955 else: 1956 for opn in opns: 1957 opS = optitle(opn,explop) 1958 if opn == opns[0]: 1959 titfig = titfig + opS 1960 elif opn == opns[Nops-1]: 1961 titfig = titfig + '!&!' + opS 1962 else: 1963 titfig = titfig + ',!' + opS 1964 else: 1965 if allopequal: 1966 opS = optitle(op,explop) 1967 for vn in varns: 1968 if vn == varns[0]: 1969 titfig = titfig + '!' + vn 1970 elif vn == varns[Nvars-1]: 1971 titfig = titfig + '!&!' + vn 1972 else: 1973 titfig = titfig + ',!' + vn 1974 titfig = titfig + opS 1975 else: 1976 for ivop in range(Nvars): 1977 vn = varns[ivop] 1978 op = opns[ivop] 1979 vnop = vn + optitle(op,explop) 1980 1981 if vn == varns[0]: 1982 titfig = titfig + '!' + vnop 1983 elif vn == varns[Nvars-1]: 1984 titfig = titfig + '!&!' + vnop 1985 else: 1986 titfig = titfig + ',!' + vnop 1987 1988 return titfig 1989 1887 1990 def draw_plots(config, plots, mod, exp, odir, allvarcomp, figscr, debug): 1888 1991 """ Function to draw all plots … … 2057 2160 figname = figname + '-'+vn+'_'+headf+'_'+op.replace('+','-') 2058 2161 2059 # Title of the figure:2060 if ivp == 0:2061 titfigure = mod + '!' + exp + "!'" + vn + "'"2062 else:2063 titfigure = titfigure + "!&!'" + vn + "'"2064 opvals = op.split('+')2065 for op1 in opvals:2066 if not opexplained.has_key(op1):2067 print errmsg2068 print ' '+fname+": no explanation for operation '"+op1+"' !!"2069 print ' provided:', opexplained.keys()2070 quit(-1)2071 if op1 == opvals[0]:2072 titfigure = titfigure + '$_{[' + opexplained[op1]2073 if len(opvals) == 1: titfigure = titfigure + ']}$'2074 elif op1 == opvals[len(opvals)-1]:2075 titfigure = titfigure + '\!' + opexplained[op1] + ']}$'2076 else:2077 titfigure = titfigure + '\!' + opexplained[op1]2078 2079 2162 ivp = ivp + 1 2080 2163 # End of variable-operation 2081 2164 figname = figname + '.' + kindfigure 2165 2166 # Title of figure 2167 titfigure = create_figure_title(mod, exp, varops, opexplained) 2082 2168 2083 2169 draw_plot(kplot, CFvarsplot, filesplot, varsplot, dimsplot, pictplot, \ … … 2693 2779 elif op == 'xvar': 2694 2780 # x-axis variance values 2695 vals='lon|-1,lon,var,' + ':'.join(varnCFs) + ':' + vdnz2696 dims = gen.dictvar_listS(varnCFs,CFdimvardict,',','@') + dnz+'@'+vdnz2781 vals='lon|-1,lon,var,' + ':'.join(varnCFs) 2782 dims = gen.dictvar_listS(varnCFs,CFdimvardict,',','@') 2697 2783 if dofile: 2698 2784 try: … … 2714 2800 "' -f " + prevfile + " -v " + CFvarnp 2715 2801 otrackf.write("\n") 2716 otrackf.write("# " + CFvarn + " " + Fopers + "\n")2802 otrackf.write("# " + varn + " " + Fopers + "\n") 2717 2803 otrackf.write(pyins + "\n") 2718 2804 … … 3084 3170 headf = vopvals[4] 3085 3171 3086 modexpdiff = mod2 + '/' + exp2 + ' -' + mod1 + '/' + exp13172 modexpdiff = mod2 + '/' + exp2 + '-' + mod1 + '/' + exp1 3087 3173 modexpdiffS = mod2 + '-' + exp2 + '_' + mod1 + '-' + exp1 3088 3174 … … 3137 3223 modexptit = modexpdiff 3138 3224 3139 if ivp == 0:3140 titfigure = modexptit + "!" + kdiff + "!'" + vn + "'"3141 vnS = vn3142 else:3143 titfigure = titfigure + "!&!'" + vn + "'"3144 vnS = vnS + '!&!' + vn3145 3146 opvals = op.split('+')3147 for op1 in opvals:3148 if not opexplained.has_key(op1):3149 print errormsg3150 print ' '+fname+": no explanation for operation '"+op1+"' !!"3151 print ' provided:', opexplained.keys()3152 quit(-1)3153 if op1 == opvals[0]:3154 titfigure = titfigure + '$_{[' + opexplained[op1]3155 if len(opvals) == 1: titfigure = titfigure + ']}$'3156 elif op1 == opvals[len(opvals)-1]:3157 titfigure = titfigure + '\!' + opexplained[op1] + ']}$'3158 else:3159 titfigure = titfigure + '\!' + opexplained[op1]3160 3161 3225 ivp = ivp + 1 3162 3226 # End of variable-operation 3163 3227 figname = figname + '.' + kindfigure 3228 3229 # Title of figure 3230 titfigure = create_figure_title(modexptit, kdiff, varops, opexplained) 3164 3231 3165 3232 if len(titfigure) > 80:
Note: See TracChangeset
for help on using the changeset viewer.