- Timestamp:
- Sep 26, 2019, 2:54:41 PM (5 years ago)
- Location:
- trunk/tools
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/tools/drawing_tools.py
r2699 r2710 159 159 # file_nlines: 160 160 # variables_values: 161 # units_lunits: Function to provide LaTeX equivalences from a given units162 161 # ASCII_LaTeX: 163 162 # DegGradSec_deg: … … 1934 1933 return colbarn, fmtcolbar, colbaror 1935 1934 1936 def units_lunits(u):1937 """ Function to provide LaTeX equivalences from a given units1938 u= units to transform1939 >>> units_lunits('kgkg-1')1940 '$kgkg^{-1}$'1941 """1942 fname = 'units_lunits'1943 1944 if u == 'h':1945 print fname + '_____________________________________________________________'1946 print units_lunits.__doc__1947 quit()1948 1949 # Units which does not change1950 same = ['1', 'category', 'cm', 'counts', 'day', 'deg', 'degree', 'degrees', \1951 'degrees East', 'degrees Nord', 'degrees North', 'g', 'gpm', 'hour', 'hPa', \1952 'J', 'K', 'Km', 'kg', 'km', 'm', 'minute', 'mm', 'month', 'Pa', 'rad', 's', \1953 'second', 'um', 'x', 'y', 'year', '-']1954 1955 if searchInlist(same,u):1956 lu = '$' + u + '$'1957 elif len(u.split(' ')) > 1 and u.split(' ')[1] == 'since':1958 uparts = u.split(' ')1959 ip=01960 for up in uparts:1961 if ip == 0:1962 lu = '$' + up1963 else:1964 lu = lu + '\ ' + up1965 ip=ip+11966 lu = lu + '$'1967 else:1968 if u == '': lu='-'1969 elif u == 'C': lu='$^{\circ}C$'1970 elif u == 'Celsius/d': lu='$^{\circ}Cd^{-1}$'1971 elif u == 'cm/yr': lu='$cm yr^{-1}$'1972 elif u == 'cmyr-1': lu='$cm yr^{-1}$'1973 elif u == 'cm yr-1': lu='$cm yr^{-1}$'1974 elif u == 'cm/year': lu='$cm year^{-1}$'1975 elif u == 'cmyear-1': lu='$cm year^{-1}$'1976 elif u == 'cm year-1': lu='$cm year^{-1}$'1977 elif u == 'days': lu='$day$'1978 elif u == 'Degrees': lu='$degrees$'1979 elif u == 'grid box centre degrees east': lu='$degrees\ East$'1980 elif u == 'degrees_East': lu='$degrees\ East$'1981 elif u == 'degrees_east': lu='$degrees\ East$'1982 elif u == 'degree_east': lu='$degrees\ East$'1983 elif u == 'degree east': lu='$degrees\ East$'1984 elif u == 'degrees longitude': lu='$degrees\ East$'1985 elif u == 'degrees latitude': lu='$degrees\ North$'1986 elif u == 'grid box centre degrees north': lu='$degrees\ North$'1987 elif u == 'degrees_North': lu='$degrees\ North$'1988 elif u == 'degrees_north': lu='$degrees\ North$'1989 elif u == 'degree_north': lu='$degrees\ North$'1990 elif u == 'degree north': lu='$degrees\ North$'1991 elif u == 'deg C': lu='$^{\circ}C$'1992 elif u == 'degC': lu='$^{\circ}C$'1993 elif u == 'deg K': lu='$K$'1994 elif u == 'degK': lu='$K$'1995 elif u == 'g/g': lu='$gg^{-1}$'1996 elif u == 'g/kg': lu='$gkg^{-1}$'1997 elif u == 'gkg-1': lu='$gkg^{-1}$'1998 elif u == 'gC/m^2': lu='$gCm^{-2}$'1999 elif u == 'gC/day/m^2': lu='$gCday^{-1}m^{-2}$'2000 elif u == 'gC/day/(m^2 tot)': lu='$gCday^{-1}(m^{-2}\ tot)$'2001 elif u == 'gC/m^2/pft': lu='$gCm^{-2}pft^{-1}$'2002 elif u == 'hPa/d': lu='$hPad^{-1}$'2003 elif u == 'hours': lu='$hour$'2004 elif u == 'J/kg': lu='$Jkg^{-1}$'2005 elif u == 'Jkg-1': lu='$Jkg^{-1}$'2006 elif u == 'K/h': lu='$Kh^{-1}$'2007 elif u == 'Kh-1': lu='$Kh^{-1}$'2008 elif u == 'K/m': lu='$Km^{-1}$'2009 elif u == 'Km-1': lu='$Km^{-1}$'2010 elif u == 'Km-3': lu='$Km^{-3}$'2011 elif u == 'K/s': lu='$Ks^{-1}$'2012 elif u == 'Ks-1': lu='$Ks^{-1}$'2013 elif u == 'K s-1': lu='$Ks^{-1}$'2014 elif u == 'K/day': lu='$Kday^{-1}$'2015 elif u == 'Kday-1': lu='$Kday^{-1}$'2016 elif u == 'K day-1': lu='$Kday^{-1}$'2017 elif u == 'kg/kg': lu='$kgkg^{-1}$'2018 elif u == 'kgkg-1': lu='$kgkg^{-1}$'2019 elif u == 'kg kg-1': lu='$kgkg^{-1}$'2020 elif u == 'kg kg**-1': lu='$kgkg^{-1}$'2021 elif u == '(kg/kg)/s': lu='$kgkg^{-1}s^{-1}$'2022 elif u == 'kgkg-1s-1': lu='$kgkg^{-1}s^{-1}$'2023 elif u == 'kg kg-1 s-1': lu='$kgkg^{-1}s^{-1}$'2024 elif u == 'Kg/m^2': lu='$kgm^{-2}$'2025 elif u == 'kg/m2': lu='$kgm^{-2}$'2026 elif u == 'kgm-2': lu='$kgm^{-2}$'2027 elif u == 'kg m-2': lu='$kgm^{-2}$'2028 elif u == 'Kg m-2': lu='$kgm^{-2}$'2029 elif u == 'kg/m2/s': lu='$kgm^{-2}s^{-1}$'2030 elif u == 'kg/m^2/s': lu='$kgm^{-2}s^{-1}$'2031 elif u == 'kg/(m2*s)': lu='$kgm^{-2}s^{-1}$'2032 elif u == 'kg/(s*m2)': lu='$kgm^{-2}s^{-1}$'2033 elif u == 'kg m-2d-1': lu='$kgm^{-2}d^{-1}$'2034 elif u == 'kg m-2 d-1': lu='$kgm^{-2}d^{-1}$'2035 elif u == 'kg m-2 day-1': lu='$kgm^{-2}d^{-1}$'2036 elif u == 'kgm-2s-1': lu='$kgm^{-2}s^{-1}$'2037 elif u == 'kg m-2 s-1': lu='$kgm^{-2}s^{-1}$'2038 elif u == 'kg-1 s-1': lu='$kg^{-1}s^{-1}$'2039 elif u == 'kg/dt_sechiba': lu='$kgdt_{sechiba}^{-1}$'2040 elif u == 'kmh-1': lu='$kmh^{-1}$'2041 elif u == 'km h-1': lu='$km h^{-1}$'2042 elif u == 'Knot': lu='$kt$'2043 elif u == 'knot': lu='$kt$'2044 elif u == 'kt': lu='$kt$'2045 elif u == '1/m': lu='$m^{-1}$'2046 elif u == 'm-1': lu='$m^{-1}$'2047 elif u == 'm2': lu='$m^{2}$'2048 elif u == 'm^2': lu='$m^{2}$'2049 elif u == 'm2/s': lu='$m2s^{-1}$'2050 elif u == 'm2s-1': lu='$m2s^{-1}$'2051 elif u == 'm2/s2': lu='$m2s^{-2}$'2052 elif u == 'm**2 s**-2': lu='$m2s^{-2}$'2053 elif u == 'm3/s': lu='$m^{3}s^{-1}$'2054 elif u == 'm^3/s': lu='$m^{3}s^{-1}$'2055 elif u == 'm/s': lu='$ms^{-1}$'2056 elif u == 'mmh-3': lu='$mmh^{-3}$'2057 elif u == 'mm/d': lu='$mm\ d^{-1}$'2058 elif u == 'mmd-1': lu='$mm\ d^{-1}$'2059 elif u == 'mm/day': lu='$mm\ day^{-1}$'2060 elif u == 'mmday-1': lu='$mm\ day^{-1}$'2061 elif u == 'mmmon-1': lu='$mm\ mon^{-1}$'2062 elif u == 'mm mon-1': lu='$mm\ mon^{-1}$'2063 elif u == 'mmmonth-1': lu='$mm\ month^{-1}$'2064 elif u == 'mm month-1': lu='$mm\ month^{-1}$'2065 elif u == 'mm yr-1': lu='$mm\ yr^{-1}$'2066 elif u == 'mmyear-1': lu='$mm\ year^{-1}$'2067 elif u == 'mm year-1': lu='$mm\ year^{-1}$'2068 elif u == 'ms-1': lu='$ms^{-1}$'2069 elif u == 'm s-1': lu='$ms^{-1}$'2070 elif u == 'm s**-1': lu='$ms^{-1}$'2071 elif u == 'ms-1m-1': lu='$ms^{-1}m^{-1}$'2072 elif u == 'm s-1m-1': lu='$ms^{-1}m^{-1}$'2073 elif u == 'm/s2': lu='$ms^{-2}$'2074 elif u == 'ms-2': lu='$ms^{-2}$'2075 elif u == 'minutes': lu='$minute$'2076 elif u == 'meters MSL': lu='$m$'2077 elif u == 'No.': lu='$number$'2078 elif u == 'numkg-1': lu='$numkg^{-1}$'2079 elif u == '#kg-1': lu='$numkg^{-1}$'2080 elif u == '\#kg-1': lu='$numkg^{-1}$'2081 elif u == ' kg(-1)': lu='$numkg^{-1}$'2082 elif u == 'numkg-1s-1': lu='$numkg^{-1}s^{-1}$'2083 elif u == '#kg-1 s-1': lu='$numkg^{-1}s^{-1}$'2084 elif u == '\#kg-1 s-1': lu='$numkg^{-1}s^{-1}$'2085 elif u == ' kg(-1) s-1': lu='$numkg^{-1}s^{-1}$'2086 elif u == 'none': lu='-'2087 elif u == 'Pa/s': lu='$Pas^{-1}$'2088 elif u == 'Pas-1': lu='$Pas^{-1}$'2089 elif u == 'W m-2': lu='$Wm^{-2}$'2090 elif u == 'Wm-2': lu='$Wm^{-2}$'2091 elif u == 'W/m2': lu='$Wm^{-2}$'2092 elif u == 'W/m^2': lu='$Wm^{-2}$'2093 elif u == '1/s': lu='$s^{-1}$'2094 elif u == 's-1': lu='$s^{-1}$'2095 elif u == 's-1 ': lu='$s^{-1}$'2096 elif u == 'seconds': lu='$second$'2097 elif u == '%': lu='\%'2098 elif u == '?': lu='-'2099 else:2100 print errormsg2101 print ' ' + fname + ': units "' + u + '" not ready!!!!'2102 Schar = []2103 for ic in range(len(u)):2104 Schar.append(ord(u[ic:ic+1]))2105 print ' character combination by ASCII numbers: ', Schar2106 quit(-1)2107 2108 return lu2109 2110 1935 def ASCII_LaTeX(ln): 2111 1936 """ Function to transform from an ASCII line to LaTeX codification … … 3415 3240 plt.legend(loc=lloc, prop={'size':lsiz}) 3416 3241 plt.xlabel(ttit) 3417 plt.ylabel(gen.latex_text(vtit) + " (" + units_lunits(vunits) + ")")3242 plt.ylabel(gen.latex_text(vtit) + " (" + gen.units_lunits(vunits) + ")") 3418 3243 plt.title(tit) 3419 3244 … … 3456 3281 #linesname = ['line 1', 'line 2', 'line 3'] 3457 3282 3458 #plot_TimeSeries(vtvalsv, units_lunits(varu), timeu, 'test', 'vartest', 'time', title, linesname, 'png')3283 #plot_TimeSeries(vtvalsv, gen.units_lunits(varu), timeu, 'test', 'vartest', 'time', title, linesname, 'png') 3459 3284 #quit() 3460 3285 … … 3650 3475 cbar = plt.colorbar(format=extrapar[4],orientation=extrapar[5]) 3651 3476 3652 cbar.set_label(gen.latex_text(extrapar[0]) +'('+ units_lunits(extrapar[6]) + \3477 cbar.set_label(gen.latex_text(extrapar[0]) +'('+ gen.units_lunits(extrapar[6]) + \ 3653 3478 ')') 3654 3479 … … 4622 4447 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 4623 4448 4624 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'4625 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'4449 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 4450 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 4626 4451 4627 4452 if mapv is not None: … … 4792 4617 4793 4618 # units labels 4794 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')4619 cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')') 4795 4620 4796 4621 figname = '2Dfields_shadow' … … 4888 4713 style=vaxv[1])) 4889 4714 dimyT0 = gen.latex_text(variables_values(dimn[1])[0]) + ' (' + \ 4890 units_lunits(dimvu) + ')'4715 gen.units_lunits(dimvu) + ')' 4891 4716 4892 4717 # No following data values … … 4913 4738 style=vaxv[1])) 4914 4739 dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) + ' (' + \ 4915 units_lunits(dimvu) + ')'4740 gen.units_lunits(dimvu) + ')' 4916 4741 4917 4742 dimyt0 = tpos … … 4975 4800 4976 4801 # units labels 4977 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')4802 cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')') 4978 4803 4979 4804 figname = '2Dfields_shadow_time' … … 5111 4936 dimyl0.append('{:{style}}'.format(yv, style=yaxv[1])) 5112 4937 5113 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'5114 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'4938 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 4939 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 5115 4940 5116 4941 if reva is not None: … … 5269 5094 5270 5095 # units labels 5271 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')')5272 plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' + \5096 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + gen.units_lunits(uts[0]) + ')') 5097 plt.annotate(gen.latex_text(vnames[1]) +' (' + gen.units_lunits(uts[1]) + ') [' + \ 5273 5098 mincntS + ', ' + maxcntS + ']', xy=(0.55,0.04), xycoords='figure fraction', \ 5274 5099 color=coln) … … 5383 5208 dimyl0 = list(timlab) 5384 5209 5385 dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) +' ('+ units_lunits(valu) +\5210 dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) +' ('+ gen.units_lunits(valu) +\ 5386 5211 ')' 5387 5212 dimyT0 = timeu … … 5396 5221 reva = 'transpose' 5397 5222 dimxT0 = gen.latex_text(variables_values(dimn[1])[0]) + ' (' + \ 5398 units_lunits(valu) + ')'5223 gen.units_lunits(valu) + ')' 5399 5224 if reva is not None: 5400 5225 varcv, dimxv, dimyv, dimxt, dimyt, dimxl, dimyl, dimxT, dimyT = \ … … 5472 5297 5473 5298 # units labels 5474 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')')5475 plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' + \5299 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + gen.units_lunits(uts[0]) + ')') 5300 plt.annotate(gen.latex_text(vnames[1]) +' (' + gen.units_lunits(uts[1]) + ') [' + \ 5476 5301 mincntS + ', ' + maxcntS + ']', xy=(0.55,0.04), xycoords='figure fraction', \ 5477 5302 color=coln) … … 5787 5612 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 5788 5613 5789 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'5790 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'5614 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 5615 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 5791 5616 5792 5617 if mapv is not None: … … 5927 5752 5928 5753 # units labels 5929 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')5754 cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')') 5930 5755 5931 5756 # line ticks … … 5951 5776 # xycoords='axes fraction') 5952 5777 5953 plt.annotate(gen.latex_text(vnamel)+ ' ('+ units_lunits(utl)+')', xy=(0.75,0.04), \5778 plt.annotate(gen.latex_text(vnamel)+ ' ('+gen.units_lunits(utl)+')', xy=(0.75,0.04), \ 5954 5779 xycoords='figure fraction', color=linev[0]) 5955 5780 figname = '2Dfields_shadow_line' … … 6046 5871 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], \ 6047 5872 style=xaxv[1])) 6048 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'5873 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 6049 5874 6050 5875 # No following data values … … 6062 5887 for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i], \ 6063 5888 style=yaxv[1])) 6064 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'5889 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 6065 5890 6066 5891 dimyt0 = (tpos-np.min(tpos))/(np.max(tpos)-np.min(tpos)) … … 6153 5978 6154 5979 # units labels 6155 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')5980 cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')') 6156 5981 6157 5982 # line ticks … … 6174 5999 plt.annotate(dimll[it], xy=(1.01,yval), xycoords='axes fraction') 6175 6000 6176 plt.annotate(gen.latex_text(vnamel)+ ' ('+ units_lunits(utl)+')', xy=(0.75,0.04), \6001 plt.annotate(gen.latex_text(vnamel)+ ' ('+gen.units_lunits(utl)+')', xy=(0.75,0.04), \ 6177 6002 xycoords='figure fraction', color=linev[0]) 6178 6003 figname = '2Dfields_shadow_line' … … 6349 6174 6350 6175 # units labels 6351 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')6176 cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')') 6352 6177 6353 6178 figname = 'Neighbourghood_evol' … … 6431 6256 6432 6257 dimxT0 = gen.latex_text(dtit) 6433 dimyT0 = gen.latex_text(vtit) + ' (' + units_lunits(vaxis) + ')'6258 dimyT0 = gen.latex_text(vtit) + ' (' + gen.units_lunits(vaxis) + ')' 6434 6259 6435 6260 pixkind = 'fixpixel' … … 6823 6648 6824 6649 dimxT0 = gen.latex_text(dtit) 6825 dimyT0 = gen.latex_text(vtit) + ' (' + units_lunits(vaxis) + ')'6650 dimyT0 = gen.latex_text(vtit) + ' (' + gen.units_lunits(vaxis) + ')' 6826 6651 6827 6652 pixkind = 'fixpixel' … … 7046 6871 style=yaxv[1])) 7047 6872 7048 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimu[0]) + ')'7049 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimu[1]) + ')'6873 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimu[0]) + ')' 6874 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimu[1]) + ')' 7050 6875 7051 6876 if mapv is not None: … … 7164 6989 uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], color=vcolor, pivot='tip', \ 7165 6990 length=blength) 7166 plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')', \6991 plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')', \ 7167 6992 xy=(0.85,-0.10), xycoords='axes fraction', color=vcolor) 7168 6993 … … 7171 6996 uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], wspeed, pivot='tip', \ 7172 6997 length=blength, cmap=plt.get_cmap(cmap)) 7173 plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')', \6998 plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')', \ 7174 6999 xy=(0.85,-0.10), xycoords='axes fraction', color='k') 7175 7000 # cbar = plt.colorbar() … … 7180 7005 7181 7006 # No legend so it is imposed 7182 ## windlabel=windn.replace('_','\_') +' (' + units_lunits(wuts[1]) + ')'7007 ## windlabel=windn.replace('_','\_') +' (' + gen.units_lunits(wuts[1]) + ')' 7183 7008 ## vecpatch = mpatches.Patch(color=vcolor, label=windlabel) 7184 7009 … … 7274 7099 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 7275 7100 7276 dimxT0 = variables_values(xvn)[0] + ' (' + units_lunits(xvu) + ')'7277 dimyT0 = variables_values(yvn)[0] + ' (' + units_lunits(yvu) + ')'7101 dimxT0 = variables_values(xvn)[0] + ' (' + gen.units_lunits(xvu) + ')' 7102 dimyT0 = variables_values(yvn)[0] + ' (' + gen.units_lunits(yvu) + ')' 7278 7103 7279 7104 if mapv is not None: … … 7387 7212 cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2]) 7388 7213 7389 cbar.set_label(gen.latex_text(vname) +' ('+ units_lunits(vunits) + ')')7214 cbar.set_label(gen.latex_text(vname) +' ('+ gen.units_lunits(vunits) + ')') 7390 7215 7391 7216 # Legend … … 7519 7344 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 7520 7345 7521 dimxT0 = variables_values(xaxn)[0] + ' (' + units_lunits(xaxu) + ')'7522 dimyT0 = variables_values(yaxn)[0] + ' (' + units_lunits(yaxu) + ')'7346 dimxT0 = variables_values(xaxn)[0] + ' (' + gen.units_lunits(xaxu) + ')' 7347 dimyT0 = variables_values(yaxn)[0] + ' (' + gen.units_lunits(yaxu) + ')' 7523 7348 7524 7349 dx=xvals.shape[1] … … 7600 7425 plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq], \ 7601 7426 uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], color=vcolor, pivot='middle') 7602 plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')', \7427 plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')', \ 7603 7428 xy=(0.80,-0.15), xycoords='axes fraction', color=vcolor) 7604 7429 else: … … 7618 7443 7619 7444 if VecN == 'wind': 7620 cbar.set_label('$\sqrt{u^{2} + v^{2}}$ (' + units_lunits(wuts) + ')')7445 cbar.set_label('$\sqrt{u^{2} + v^{2}}$ (' + gen.units_lunits(wuts) + ')') 7621 7446 else: 7622 7447 vN = vecoln.split('@')[2] 7623 7448 vU = vecoln.split('@')[3] 7624 cbar.set_label(vN + ' (' + units_lunits(vU) + ')')7625 7626 plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')', \7449 cbar.set_label(vN + ' (' + gen.units_lunits(vU) + ')') 7450 7451 plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')', \ 7627 7452 xy=(0.80,-0.15), xycoords='axes fraction', color='black') 7628 7453 … … 7784 7609 vN = vecoln.split('@')[1] 7785 7610 vU = vecoln.split('@')[2] 7786 cbar.set_label(vN + ' (' + units_lunits(vU) + ')')7611 cbar.set_label(vN + ' (' + gen.units_lunits(vU) + ')') 7787 7612 7788 7613 if basinid: … … 7799 7624 plt.plot(xlabpos[i], ylabpos[i], 'h', color=labcol[i]) 7800 7625 7801 plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')', \7626 plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')', \ 7802 7627 xy=(0.80,-0.08), xycoords='axes fraction', color='black') 7803 7628 … … 8466 8291 # plt.contour(lons, lats, sarea, levels = [1.], colors='gray', linewidths=1.) 8467 8292 8468 cbar.set_label('upstream (' + units_lunits(uuts) + ')')8293 cbar.set_label('upstream (' + gen.units_lunits(uuts) + ')') 8469 8294 plt.legend(loc=lloc) 8470 8295 8471 # plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')', \8296 # plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')', \ 8472 8297 # xy=(0.80,-0.15), xycoords='axes fraction', color='black') 8473 8298 … … 9197 9022 sm._A = [] 9198 9023 cbar = plt.colorbar(sm) 9199 cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')9024 cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')') 9200 9025 9201 9026 elif lkind == 'multicoltime': … … 9258 9083 plt.scatter(ang, speed, c=ev, cmap=colbar, marker=lmrk) 9259 9084 cbar = plt.colorbar() 9260 cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')9085 cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')') 9261 9086 elif lkind == 'multicoltime': 9262 9087 lmrk = gen.auto_val(lpvals[3],'x') … … 9297 9122 ax.set_theta_zero_location('N') 9298 9123 ax.set_theta_direction(-1) 9299 plt.annotate('wind (' + units_lunits(windu) + ')', xy=(0.75,0.06), color='k', \9124 plt.annotate('wind (' + gen.units_lunits(windu) + ')', xy=(0.75,0.06), color='k', \ 9300 9125 xycoords='figure fraction', horizontalalignment='center') 9301 9126 … … 9477 9302 sm._A = [] 9478 9303 cbar = plt.colorbar(sm) 9479 cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')9304 cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')') 9480 9305 9481 9306 elif lkind == 'multicoltime': … … 9567 9392 9568 9393 cbar = plt.colorbar() 9569 cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')9394 cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')') 9570 9395 elif lkind == 'multicoltime': 9571 9396 colbar = gen.auto_val(lpvals[4],'spectral_r') … … 9624 9449 ax.set_theta_zero_location('N') 9625 9450 ax.set_theta_direction(-1) 9626 plt.annotate('wind (' + units_lunits(windu) + ')', xy=(0.75,0.06), color='k', \9451 plt.annotate('wind (' + gen.units_lunits(windu) + ')', xy=(0.75,0.06), color='k', \ 9627 9452 xycoords='figure fraction', horizontalalignment='center') 9628 9453 … … 9826 9651 labstd = 'standard deviation (norm.)' 9827 9652 else: 9828 labstd = 'standard deviation (' + units_lunits(vunits) + ')'9653 labstd = 'standard deviation (' + gen.units_lunits(vunits) + ')' 9829 9654 9830 9655 output_kind(kfig, 'Taylor', closefig) … … 9963 9788 dimyl0.append('{:{style}}'.format(yv, style=yaxv[1])) 9964 9789 9965 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'9966 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'9790 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 9791 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 9967 9792 9968 9793 if reva is not None: … … 10124 9949 10125 9950 # units labels 10126 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')')10127 plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' + \9951 cbar.set_label(gen.latex_text(vnames[0]) + ' (' + gen.units_lunits(uts[0]) + ')') 9952 plt.annotate(gen.latex_text(vnames[1]) +' (' + gen.units_lunits(uts[1]) + ') [' + \ 10128 9953 mincntS1 + ', ' + maxcntS1 + ']', xy=(0.05,0.04), xycoords='figure fraction', \ 10129 9954 color=coln1) 10130 plt.annotate(gen.latex_text(vnames[2]) +' (' + units_lunits(uts[2]) + ') [' + \9955 plt.annotate(gen.latex_text(vnames[2]) +' (' + gen.units_lunits(uts[2]) + ') [' + \ 10131 9956 mincntS2 + ', ' + maxcntS2 + ']', xy=(0.55,0.04), xycoords='figure fraction', \ 10132 9957 color=coln2) … … 10285 10110 plt.xticks(dimyt, dimyl, rotation=yaxv[3]) 10286 10111 plt.yticks(dimxt, dimxl, rotation=xaxv[3]) 10287 plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10112 plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10288 10113 if dimxu is not None: 10289 plt.ylabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')')10114 plt.ylabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 10290 10115 else: 10291 10116 plt.ylabel(gen.latex_text(xlabel)) … … 10294 10119 plt.yticks(dimyt, list(dimyl), rotation=yaxv[3]) 10295 10120 if dimxu is not None: 10296 plt.xlabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')')10121 plt.xlabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 10297 10122 else: 10298 10123 plt.xlabel(gen.latex_text(xlabel)) 10299 plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10124 plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10300 10125 10301 10126 if labels is not None: … … 10415 10240 plt.xticks(dimyt, dimyl, rotation=yaxv[3]) 10416 10241 plt.yticks(tpos, tlabs, rotation=0) 10417 plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10242 plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10418 10243 plt.ylabel(gen.latex_text(xlabel)) 10419 10244 plt.xlim(dyn, dyx) … … 10422 10247 plt.yticks(dimyt, list(dimyl), rotation=yaxv[3]) 10423 10248 plt.xlabel(gen.latex_text(xlabel)) 10424 plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10249 plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10425 10250 plt.ylim(dyn, dyx) 10426 10251 … … 10629 10454 plt.xticks(dimyt, dimyl, rotation=yaxv[3]) 10630 10455 plt.yticks(dimxt, list(dimxl), rotation=xaxv[3]) 10631 plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10456 plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10632 10457 if dimxu is not None: 10633 plt.ylabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')')10458 plt.ylabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 10634 10459 else: 10635 10460 plt.ylabel(gen.latex_text(xlabel)) … … 10639 10464 plt.yticks(dimyt, list(dimyl), rotation=yaxv[3]) 10640 10465 if dimxu is not None: 10641 plt.xlabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')')10466 plt.xlabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 10642 10467 else: 10643 10468 plt.xlabel(gen.latex_text(xlabel)) 10644 plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10469 plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10645 10470 plt.ylim(dyn, dyx) 10646 10471 … … 10825 10650 plt.xticks(dimyt, dimyl, rotation=yaxv[3]) 10826 10651 plt.yticks(tpos, tlabs, rotation=0) 10827 plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10652 plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10828 10653 plt.ylabel(gen.latex_text(xlabel)) 10829 10654 plt.xlim(dyn, dyx) … … 10832 10657 plt.yticks(dimyt, list(dimyl), rotation=yaxv[3]) 10833 10658 plt.xlabel(gen.latex_text(xlabel)) 10834 plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')10659 plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')') 10835 10660 plt.ylim(dyn, dyx) 10836 10661 … … 11112 10937 plt.yticks(dimyt, list(dimyl), rotation=yaxv[3]) 11113 10938 if preu != 'None': 11114 plt.xlabel(gen.latex_text(prelab) + ' (' + units_lunits(preu) + ')')10939 plt.xlabel(gen.latex_text(prelab) + ' (' + gen.units_lunits(preu) + ')') 11115 10940 else: 11116 10941 plt.xlabel(gen.latex_text(prelab)) 11117 10942 if futu != 'None': 11118 plt.ylabel(gen.latex_text(futlab) + ' (' + units_lunits(futu) + ')')10943 plt.ylabel(gen.latex_text(futlab) + ' (' + gen.units_lunits(futu) + ')') 11119 10944 else: 11120 10945 plt.xlabel(gen.latex_text(futlab)) … … 11371 11196 if valuesvals[2] != 'None': 11372 11197 plt.xlabel(gen.latex_text(valuesvals[1]) + ' (' + \ 11373 units_lunits(valuesvals[2]) + ')')11198 gen.units_lunits(valuesvals[2]) + ')') 11374 11199 else: 11375 11200 plt.xlabel(gen.latex_text(valuesvals[1])) … … 11383 11208 if valuesvals[2] != 'None': 11384 11209 plt.ylabel(gen.latex_text(valuesvals[1]) + ' (' + \ 11385 units_lunits(valuesvals[2]) + ')')11210 gen.units_lunits(valuesvals[2]) + ')') 11386 11211 else: 11387 11212 plt.ylabel(gen.latex_text(valuesvals[1])) … … 11656 11481 plt.yticks(dimyt, list(dimyl), rotation=yaxv[3]) 11657 11482 if axunits != 'None': 11658 plt.ylabel(gen.latex_text(axlab) + ' (' + units_lunits(axunits) + ')')11483 plt.ylabel(gen.latex_text(axlab) + ' (' + gen.units_lunits(axunits) + ')') 11659 11484 else: 11660 11485 plt.ylabel(gen.latex_text(axlab)) … … 11665 11490 plt.yticks(cycp, cycl, rotation=xaxv[3]) 11666 11491 if axunits != 'None': 11667 plt.xlabel(gen.latex_text(axlab) + ' (' + units_lunits(axunits) + ')')11492 plt.xlabel(gen.latex_text(axlab) + ' (' + gen.units_lunits(axunits) + ')') 11668 11493 else: 11669 11494 plt.xlabel(gen.latex_text(axlab)) … … 11795 11620 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 11796 11621 11797 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'11798 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'11622 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 11623 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 11799 11624 11800 11625 if mapv is not None: … … 11951 11776 #fig.colorbar(im, cax=cbar_ax) 11952 11777 # units labels 11953 ulab = units_lunits(uts)11778 ulab = gen.units_lunits(uts) 11954 11779 cbar_ax.set_label(ulab) 11955 11780 plt.annotate(ulab, xy=(0.96,0.5), xycoords='figure fraction', rotation=90) … … 12057 11882 for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1])) 12058 11883 12059 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'12060 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'11884 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 11885 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 12061 11886 12062 11887 if mapv is not None: … … 12195 12020 12196 12021 # units labels 12197 cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')12022 cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')') 12198 12023 12199 12024 graphtit = gen.latex_text(ltit[it]) … … 12719 12544 dimyu = diminf['units'][1] 12720 12545 12721 dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'12722 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'12546 dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')' 12547 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 12723 12548 12724 12549 pixkind = 'data' … … 12930 12755 # units labels 12931 12756 cbar.set_label(gen.latex_text(varinf['name']) + ' (' + \ 12932 units_lunits(varinf['units']) + ')')12757 gen.units_lunits(varinf['units']) + ')') 12933 12758 12934 12759 plt.title(gen.latex_text(figtitle)) … … 13039 12864 13040 12865 dimxT0 = timeinf['name'] 13041 dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'12866 dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')' 13042 12867 13043 12868 pixkind = 'data' … … 13244 13069 # units labels 13245 13070 cbar.set_label(gen.latex_text(varinf['name']) + ' (' + \ 13246 units_lunits(varinf['units']) + ')')13071 gen.units_lunits(varinf['units']) + ')') 13247 13072 13248 13073 plt.title(gen.latex_text(figtitle)) … … 14278 14103 # units labels 14279 14104 if cbarv[1] is not None: 14280 cbar.set_label(gen.latex_text(cbarv[0]) + ' (' + units_lunits(cbarv[1]) + ')')14105 cbar.set_label(gen.latex_text(cbarv[0]) + ' (' + gen.units_lunits(cbarv[1]) + ')') 14281 14106 else: 14282 14107 cbar.set_label(gen.latex_text(cbarv[0])) -
trunk/tools/generic_tools.py
r2705 r2710 246 246 # timefmt_timelab: Function to transform from C-like time format to general one 247 247 # unitsdsDate: Function to know how many units of time are from a given pair of dates 248 # units_lunits: Function to provide LaTeX equivalences from a given units 248 249 # vals_around: Function to provide the 3x3 values around a given j,i point 249 250 # xtrm_nx: Function to provide the extreme (a percentage above min,max) of a series of values … … 3839 3840 fname = 'index_vec' 3840 3841 3842 valpos = -1 3841 3843 if type(vec) == type(np.arange(2)): 3842 3844 valpos = -1 … … 16946 16948 return pastelc 16947 16949 16950 def units_lunits(u): 16951 """ Function to provide LaTeX equivalences from a given units 16952 u= units to transform 16953 >>> units_lunits('kgkg-1') 16954 '$kgkg^{-1}$' 16955 """ 16956 fname = 'units_lunits' 16957 16958 if u == 'h': 16959 print fname + '_____________________________________________________________' 16960 print units_lunits.__doc__ 16961 quit() 16962 16963 # Units which does not change 16964 same = ['1', 'category', 'cm', 'counts', 'day', 'deg', 'degree', 'degrees', \ 16965 'degrees East', 'degrees Nord', 'degrees North', 'g', 'gpm', 'hour', 'hPa', \ 16966 'J', 'K', 'Km', 'kg', 'km', 'm', 'minute', 'mm', 'month', 'Pa', 'rad', 's', \ 16967 'second', 'um', 'x', 'y', 'year', '-'] 16968 16969 if searchInlist(same,u): 16970 lu = '$' + u + '$' 16971 elif len(u.split(' ')) > 1 and u.split(' ')[1] == 'since': 16972 uparts = u.split(' ') 16973 ip=0 16974 for up in uparts: 16975 if ip == 0: 16976 lu = '$' + up 16977 else: 16978 lu = lu + '\ ' + up 16979 ip=ip+1 16980 lu = lu + '$' 16981 else: 16982 if u == '': lu='-' 16983 elif u == 'C': lu='$^{\circ}C$' 16984 elif u == 'Celsius/d': lu='$^{\circ}Cd^{-1}$' 16985 elif u == 'cm/yr': lu='$cm yr^{-1}$' 16986 elif u == 'cmyr-1': lu='$cm yr^{-1}$' 16987 elif u == 'cm yr-1': lu='$cm yr^{-1}$' 16988 elif u == 'cm/year': lu='$cm year^{-1}$' 16989 elif u == 'cmyear-1': lu='$cm year^{-1}$' 16990 elif u == 'cm year-1': lu='$cm year^{-1}$' 16991 elif u == 'days': lu='$day$' 16992 elif u == 'Degrees': lu='$degrees$' 16993 elif u == 'grid box centre degrees east': lu='$degrees\ East$' 16994 elif u == 'degrees_East': lu='$degrees\ East$' 16995 elif u == 'degrees_east': lu='$degrees\ East$' 16996 elif u == 'degree_east': lu='$degrees\ East$' 16997 elif u == 'degree east': lu='$degrees\ East$' 16998 elif u == 'degrees longitude': lu='$degrees\ East$' 16999 elif u == 'degrees latitude': lu='$degrees\ North$' 17000 elif u == 'grid box centre degrees north': lu='$degrees\ North$' 17001 elif u == 'degrees_North': lu='$degrees\ North$' 17002 elif u == 'degrees_north': lu='$degrees\ North$' 17003 elif u == 'degree_north': lu='$degrees\ North$' 17004 elif u == 'degree north': lu='$degrees\ North$' 17005 elif u == 'deg C': lu='$^{\circ}C$' 17006 elif u == 'degC': lu='$^{\circ}C$' 17007 elif u == 'deg K': lu='$K$' 17008 elif u == 'degK': lu='$K$' 17009 elif u == 'g/g': lu='$gg^{-1}$' 17010 elif u == 'g/kg': lu='$gkg^{-1}$' 17011 elif u == 'gkg-1': lu='$gkg^{-1}$' 17012 elif u == 'gC/m^2': lu='$gCm^{-2}$' 17013 elif u == 'gC/day/m^2': lu='$gCday^{-1}m^{-2}$' 17014 elif u == 'gC/day/(m^2 tot)': lu='$gCday^{-1}(m^{-2}\ tot)$' 17015 elif u == 'gC/m^2/pft': lu='$gCm^{-2}pft^{-1}$' 17016 elif u == 'hPa/d': lu='$hPad^{-1}$' 17017 elif u == 'hours': lu='$hour$' 17018 elif u == 'J/kg': lu='$Jkg^{-1}$' 17019 elif u == 'Jkg-1': lu='$Jkg^{-1}$' 17020 elif u == 'K/h': lu='$Kh^{-1}$' 17021 elif u == 'Kh-1': lu='$Kh^{-1}$' 17022 elif u == 'K/m': lu='$Km^{-1}$' 17023 elif u == 'Km-1': lu='$Km^{-1}$' 17024 elif u == 'Km-3': lu='$Km^{-3}$' 17025 elif u == 'K/s': lu='$Ks^{-1}$' 17026 elif u == 'Ks-1': lu='$Ks^{-1}$' 17027 elif u == 'K s-1': lu='$Ks^{-1}$' 17028 elif u == 'K/day': lu='$Kday^{-1}$' 17029 elif u == 'Kday-1': lu='$Kday^{-1}$' 17030 elif u == 'K day-1': lu='$Kday^{-1}$' 17031 elif u == 'kg/kg': lu='$kgkg^{-1}$' 17032 elif u == 'kgkg-1': lu='$kgkg^{-1}$' 17033 elif u == 'kg kg-1': lu='$kgkg^{-1}$' 17034 elif u == 'kg kg**-1': lu='$kgkg^{-1}$' 17035 elif u == '(kg/kg)/s': lu='$kgkg^{-1}s^{-1}$' 17036 elif u == 'kgkg-1s-1': lu='$kgkg^{-1}s^{-1}$' 17037 elif u == 'kg kg-1 s-1': lu='$kgkg^{-1}s^{-1}$' 17038 elif u == 'Kg/m^2': lu='$kgm^{-2}$' 17039 elif u == 'kg/m2': lu='$kgm^{-2}$' 17040 elif u == 'kgm-2': lu='$kgm^{-2}$' 17041 elif u == 'kg m-2': lu='$kgm^{-2}$' 17042 elif u == 'Kg m-2': lu='$kgm^{-2}$' 17043 elif u == 'kg/m2/s': lu='$kgm^{-2}s^{-1}$' 17044 elif u == 'kg/m^2/s': lu='$kgm^{-2}s^{-1}$' 17045 elif u == 'kg/(m2*s)': lu='$kgm^{-2}s^{-1}$' 17046 elif u == 'kg/(s*m2)': lu='$kgm^{-2}s^{-1}$' 17047 elif u == 'kg m-2d-1': lu='$kgm^{-2}d^{-1}$' 17048 elif u == 'kg m-2 d-1': lu='$kgm^{-2}d^{-1}$' 17049 elif u == 'kg m-2 day-1': lu='$kgm^{-2}d^{-1}$' 17050 elif u == 'kgm-2s-1': lu='$kgm^{-2}s^{-1}$' 17051 elif u == 'kg m-2 s-1': lu='$kgm^{-2}s^{-1}$' 17052 elif u == 'kg-1 s-1': lu='$kg^{-1}s^{-1}$' 17053 elif u == 'kg/dt_sechiba': lu='$kgdt_{sechiba}^{-1}$' 17054 elif u == 'kmh-1': lu='$kmh^{-1}$' 17055 elif u == 'km h-1': lu='$km h^{-1}$' 17056 elif u == 'Knot': lu='$kt$' 17057 elif u == 'knot': lu='$kt$' 17058 elif u == 'kt': lu='$kt$' 17059 elif u == '1/m': lu='$m^{-1}$' 17060 elif u == 'm-1': lu='$m^{-1}$' 17061 elif u == 'm2': lu='$m^{2}$' 17062 elif u == 'm^2': lu='$m^{2}$' 17063 elif u == 'm2/s': lu='$m2s^{-1}$' 17064 elif u == 'm2s-1': lu='$m2s^{-1}$' 17065 elif u == 'm2/s2': lu='$m2s^{-2}$' 17066 elif u == 'm**2 s**-2': lu='$m2s^{-2}$' 17067 elif u == 'm3/s': lu='$m^{3}s^{-1}$' 17068 elif u == 'm^3/s': lu='$m^{3}s^{-1}$' 17069 elif u == 'm/s': lu='$ms^{-1}$' 17070 elif u == 'mmh-3': lu='$mmh^{-3}$' 17071 elif u == 'mm/d': lu='$mm\ d^{-1}$' 17072 elif u == 'mmd-1': lu='$mm\ d^{-1}$' 17073 elif u == 'mm/day': lu='$mm\ day^{-1}$' 17074 elif u == 'mmday-1': lu='$mm\ day^{-1}$' 17075 elif u == 'mmmon-1': lu='$mm\ mon^{-1}$' 17076 elif u == 'mm mon-1': lu='$mm\ mon^{-1}$' 17077 elif u == 'mmmonth-1': lu='$mm\ month^{-1}$' 17078 elif u == 'mm month-1': lu='$mm\ month^{-1}$' 17079 elif u == 'mm yr-1': lu='$mm\ yr^{-1}$' 17080 elif u == 'mmyear-1': lu='$mm\ year^{-1}$' 17081 elif u == 'mm year-1': lu='$mm\ year^{-1}$' 17082 elif u == 'ms-1': lu='$ms^{-1}$' 17083 elif u == 'm s-1': lu='$ms^{-1}$' 17084 elif u == 'm s**-1': lu='$ms^{-1}$' 17085 elif u == 'ms-1m-1': lu='$ms^{-1}m^{-1}$' 17086 elif u == 'm s-1m-1': lu='$ms^{-1}m^{-1}$' 17087 elif u == 'm/s2': lu='$ms^{-2}$' 17088 elif u == 'ms-2': lu='$ms^{-2}$' 17089 elif u == 'minutes': lu='$minute$' 17090 elif u == 'meters MSL': lu='$m$' 17091 elif u == 'No.': lu='$number$' 17092 elif u == 'numkg-1': lu='$numkg^{-1}$' 17093 elif u == '#kg-1': lu='$numkg^{-1}$' 17094 elif u == '\#kg-1': lu='$numkg^{-1}$' 17095 elif u == ' kg(-1)': lu='$numkg^{-1}$' 17096 elif u == 'numkg-1s-1': lu='$numkg^{-1}s^{-1}$' 17097 elif u == '#kg-1 s-1': lu='$numkg^{-1}s^{-1}$' 17098 elif u == '\#kg-1 s-1': lu='$numkg^{-1}s^{-1}$' 17099 elif u == ' kg(-1) s-1': lu='$numkg^{-1}s^{-1}$' 17100 elif u == 'none': lu='-' 17101 elif u == 'Pa/s': lu='$Pas^{-1}$' 17102 elif u == 'Pas-1': lu='$Pas^{-1}$' 17103 elif u == 'W m-2': lu='$Wm^{-2}$' 17104 elif u == 'Wm-2': lu='$Wm^{-2}$' 17105 elif u == 'W/m2': lu='$Wm^{-2}$' 17106 elif u == 'W/m^2': lu='$Wm^{-2}$' 17107 elif u == '1/s': lu='$s^{-1}$' 17108 elif u == 's-1': lu='$s^{-1}$' 17109 elif u == 's-1 ': lu='$s^{-1}$' 17110 elif u == 'seconds': lu='$second$' 17111 elif u == '%': lu='\%' 17112 elif u == '?': lu='-' 17113 else: 17114 print errormsg 17115 print ' ' + fname + ': units "' + u + '" not ready!!!!' 17116 Schar = [] 17117 for ic in range(len(u)): 17118 Schar.append(ord(u[ic:ic+1])) 17119 print ' character combination by ASCII numbers: ', Schar 17120 quit(-1) 17121 17122 return lu 17123 17124 def euqal_units(units1, units2): 17125 """ Function to provide the same units of two datasets 17126 units1: units of reference (from units_lunits) 17127 """ 17128 16948 17129 #quit() 16949 17130
Note: See TracChangeset
for help on using the changeset viewer.