Index: trunk/tools/drawing_tools.py
===================================================================
--- trunk/tools/drawing_tools.py	(revision 2709)
+++ trunk/tools/drawing_tools.py	(revision 2710)
@@ -159,5 +159,4 @@
 # file_nlines:
 # variables_values:
-# units_lunits: Function to provide LaTeX equivalences from a given units
 # ASCII_LaTeX:
 # DegGradSec_deg:
@@ -1934,178 +1933,4 @@
     return colbarn, fmtcolbar, colbaror
 
-def units_lunits(u):
-    """ Function to provide LaTeX equivalences from a given units
-      u= units to transform
-    >>> units_lunits('kgkg-1')
-    '$kgkg^{-1}$'    
-    """
-    fname = 'units_lunits'
-
-    if u == 'h':
-        print fname + '_____________________________________________________________'
-        print units_lunits.__doc__
-        quit()
-
-# Units which does not change
-    same = ['1', 'category', 'cm', 'counts', 'day', 'deg', 'degree', 'degrees',      \
-      'degrees East', 'degrees Nord', 'degrees North', 'g', 'gpm', 'hour', 'hPa',    \
-      'J', 'K', 'Km', 'kg', 'km', 'm', 'minute', 'mm', 'month', 'Pa', 'rad', 's',    \
-      'second', 'um', 'x', 'y', 'year', '-']
-
-    if searchInlist(same,u):
-        lu = '$' + u + '$'
-    elif len(u.split(' ')) > 1 and u.split(' ')[1] == 'since':
-        uparts = u.split(' ')
-        ip=0
-        for up in uparts:
-            if ip == 0:
-               lu = '$' + up
-            else:
-               lu = lu + '\ ' + up
-            ip=ip+1
-        lu = lu + '$'
-    else:
-        if u == '': lu='-'
-        elif u == 'C': lu='$^{\circ}C$'
-        elif u == 'Celsius/d': lu='$^{\circ}Cd^{-1}$'
-        elif u == 'cm/yr': lu='$cm yr^{-1}$'
-        elif u == 'cmyr-1': lu='$cm yr^{-1}$'
-        elif u == 'cm yr-1': lu='$cm yr^{-1}$'
-        elif u == 'cm/year': lu='$cm year^{-1}$'
-        elif u == 'cmyear-1': lu='$cm year^{-1}$'
-        elif u == 'cm year-1': lu='$cm year^{-1}$'
-        elif u == 'days': lu='$day$'
-        elif u == 'Degrees': lu='$degrees$'
-        elif u == 'grid box centre degrees east': lu='$degrees\ East$'
-        elif u == 'degrees_East': lu='$degrees\ East$'
-        elif u == 'degrees_east': lu='$degrees\ East$'
-        elif u == 'degree_east': lu='$degrees\ East$'
-        elif u == 'degree east': lu='$degrees\ East$'
-        elif u == 'degrees longitude': lu='$degrees\ East$'
-        elif u == 'degrees latitude': lu='$degrees\ North$'
-        elif u == 'grid box centre degrees north': lu='$degrees\ North$'
-        elif u == 'degrees_North': lu='$degrees\ North$'
-        elif u == 'degrees_north': lu='$degrees\ North$'
-        elif u == 'degree_north': lu='$degrees\ North$'
-        elif u == 'degree north': lu='$degrees\ North$'
-        elif u == 'deg C': lu='$^{\circ}C$'
-        elif u == 'degC': lu='$^{\circ}C$'
-        elif u == 'deg K': lu='$K$'
-        elif u == 'degK': lu='$K$'
-        elif u == 'g/g': lu='$gg^{-1}$'
-        elif u == 'g/kg': lu='$gkg^{-1}$'
-        elif u == 'gkg-1': lu='$gkg^{-1}$'
-        elif u == 'gC/m^2': lu='$gCm^{-2}$'
-        elif u == 'gC/day/m^2': lu='$gCday^{-1}m^{-2}$'
-        elif u == 'gC/day/(m^2 tot)': lu='$gCday^{-1}(m^{-2}\ tot)$'
-        elif u == 'gC/m^2/pft': lu='$gCm^{-2}pft^{-1}$'
-        elif u == 'hPa/d': lu='$hPad^{-1}$'
-        elif u == 'hours': lu='$hour$'
-        elif u == 'J/kg': lu='$Jkg^{-1}$'
-        elif u == 'Jkg-1': lu='$Jkg^{-1}$'
-        elif u == 'K/h': lu='$Kh^{-1}$'
-        elif u == 'Kh-1': lu='$Kh^{-1}$'
-        elif u == 'K/m': lu='$Km^{-1}$'
-        elif u == 'Km-1': lu='$Km^{-1}$'
-        elif u == 'Km-3': lu='$Km^{-3}$'
-        elif u == 'K/s': lu='$Ks^{-1}$'
-        elif u == 'Ks-1': lu='$Ks^{-1}$'
-        elif u == 'K s-1': lu='$Ks^{-1}$'
-        elif u == 'K/day': lu='$Kday^{-1}$'
-        elif u == 'Kday-1': lu='$Kday^{-1}$'
-        elif u == 'K day-1': lu='$Kday^{-1}$'
-        elif u == 'kg/kg': lu='$kgkg^{-1}$'
-        elif u == 'kgkg-1': lu='$kgkg^{-1}$'
-        elif u == 'kg kg-1': lu='$kgkg^{-1}$'
-        elif u == 'kg kg**-1': lu='$kgkg^{-1}$'
-        elif u == '(kg/kg)/s': lu='$kgkg^{-1}s^{-1}$'
-        elif u == 'kgkg-1s-1': lu='$kgkg^{-1}s^{-1}$'
-        elif u == 'kg kg-1 s-1': lu='$kgkg^{-1}s^{-1}$'
-        elif u == 'Kg/m^2': lu='$kgm^{-2}$'
-        elif u == 'kg/m2': lu='$kgm^{-2}$'
-        elif u == 'kgm-2': lu='$kgm^{-2}$'
-        elif u == 'kg m-2': lu='$kgm^{-2}$'
-        elif u == 'Kg m-2': lu='$kgm^{-2}$'
-        elif u == 'kg/m2/s': lu='$kgm^{-2}s^{-1}$'
-        elif u == 'kg/m^2/s': lu='$kgm^{-2}s^{-1}$'
-        elif u == 'kg/(m2*s)': lu='$kgm^{-2}s^{-1}$'
-        elif u == 'kg/(s*m2)': lu='$kgm^{-2}s^{-1}$'
-        elif u == 'kg m-2d-1': lu='$kgm^{-2}d^{-1}$'
-        elif u == 'kg m-2 d-1': lu='$kgm^{-2}d^{-1}$'
-        elif u == 'kg m-2 day-1': lu='$kgm^{-2}d^{-1}$'
-        elif u == 'kgm-2s-1': lu='$kgm^{-2}s^{-1}$'
-        elif u == 'kg m-2 s-1': lu='$kgm^{-2}s^{-1}$'
-        elif u == 'kg-1 s-1': lu='$kg^{-1}s^{-1}$'
-        elif u == 'kg/dt_sechiba': lu='$kgdt_{sechiba}^{-1}$'
-        elif u == 'kmh-1': lu='$kmh^{-1}$'
-        elif u == 'km h-1': lu='$km h^{-1}$'
-        elif u == 'Knot': lu='$kt$'
-        elif u == 'knot': lu='$kt$'
-        elif u == 'kt': lu='$kt$'
-        elif u == '1/m': lu='$m^{-1}$'
-        elif u == 'm-1': lu='$m^{-1}$'
-        elif u == 'm2': lu='$m^{2}$'
-        elif u == 'm^2': lu='$m^{2}$'
-        elif u == 'm2/s': lu='$m2s^{-1}$'
-        elif u == 'm2s-1': lu='$m2s^{-1}$'
-        elif u == 'm2/s2': lu='$m2s^{-2}$'
-        elif u == 'm**2 s**-2': lu='$m2s^{-2}$'
-        elif u == 'm3/s': lu='$m^{3}s^{-1}$'
-        elif u == 'm^3/s': lu='$m^{3}s^{-1}$'
-        elif u == 'm/s': lu='$ms^{-1}$'
-        elif u == 'mmh-3': lu='$mmh^{-3}$'
-        elif u == 'mm/d': lu='$mm\ d^{-1}$'
-        elif u == 'mmd-1': lu='$mm\ d^{-1}$'
-        elif u == 'mm/day': lu='$mm\ day^{-1}$'
-        elif u == 'mmday-1': lu='$mm\ day^{-1}$'
-        elif u == 'mmmon-1': lu='$mm\ mon^{-1}$'
-        elif u == 'mm mon-1': lu='$mm\ mon^{-1}$'
-        elif u == 'mmmonth-1': lu='$mm\ month^{-1}$'
-        elif u == 'mm month-1': lu='$mm\ month^{-1}$'
-        elif u == 'mm yr-1': lu='$mm\ yr^{-1}$'
-        elif u == 'mmyear-1': lu='$mm\ year^{-1}$'
-        elif u == 'mm year-1': lu='$mm\ year^{-1}$'
-        elif u == 'ms-1': lu='$ms^{-1}$'
-        elif u == 'm s-1': lu='$ms^{-1}$'
-        elif u == 'm s**-1': lu='$ms^{-1}$'
-        elif u == 'ms-1m-1': lu='$ms^{-1}m^{-1}$'
-        elif u == 'm s-1m-1': lu='$ms^{-1}m^{-1}$'
-        elif u == 'm/s2': lu='$ms^{-2}$'
-        elif u == 'ms-2': lu='$ms^{-2}$'
-        elif u == 'minutes': lu='$minute$'
-        elif u == 'meters MSL': lu='$m$'
-        elif u == 'No.': lu='$number$'
-        elif u == 'numkg-1': lu='$numkg^{-1}$'
-        elif u == '#kg-1': lu='$numkg^{-1}$'
-        elif u == '\#kg-1': lu='$numkg^{-1}$'
-        elif u == '  kg(-1)': lu='$numkg^{-1}$'
-        elif u == 'numkg-1s-1': lu='$numkg^{-1}s^{-1}$'
-        elif u == '#kg-1 s-1': lu='$numkg^{-1}s^{-1}$'
-        elif u == '\#kg-1 s-1': lu='$numkg^{-1}s^{-1}$'
-        elif u == '  kg(-1) s-1': lu='$numkg^{-1}s^{-1}$'
-        elif u == 'none': lu='-'
-        elif u == 'Pa/s': lu='$Pas^{-1}$'
-        elif u == 'Pas-1': lu='$Pas^{-1}$'
-        elif u == 'W m-2': lu='$Wm^{-2}$'
-        elif u == 'Wm-2': lu='$Wm^{-2}$'
-        elif u == 'W/m2': lu='$Wm^{-2}$'
-        elif u == 'W/m^2': lu='$Wm^{-2}$'
-        elif u == '1/s': lu='$s^{-1}$'
-        elif u == 's-1': lu='$s^{-1}$'
-        elif u == 's-1 ': lu='$s^{-1}$'
-        elif u == 'seconds': lu='$second$'
-        elif u == '%': lu='\%'
-        elif u == '?': lu='-'
-        else:
-            print errormsg
-            print '  ' + fname + ': units "' + u + '" not ready!!!!'
-            Schar = []
-            for ic in range(len(u)):
-              Schar.append(ord(u[ic:ic+1]))
-            print '    character combination by ASCII numbers: ', Schar
-            quit(-1)
-
-    return lu
-
 def ASCII_LaTeX(ln):
     """ Function to transform from an ASCII line to LaTeX codification
@@ -3415,5 +3240,5 @@
     plt.legend(loc=lloc, prop={'size':lsiz})
     plt.xlabel(ttit)
-    plt.ylabel(gen.latex_text(vtit) + " (" + units_lunits(vunits) + ")")
+    plt.ylabel(gen.latex_text(vtit) + " (" + gen.units_lunits(vunits) + ")")
     plt.title(tit)
 
@@ -3456,5 +3281,5 @@
 #linesname = ['line 1', 'line 2', 'line 3']
 
-#plot_TimeSeries(vtvalsv, units_lunits(varu), timeu, 'test', 'vartest', 'time', title, linesname, 'png')
+#plot_TimeSeries(vtvalsv, gen.units_lunits(varu), timeu, 'test', 'vartest', 'time', title, linesname, 'png')
 #quit()
 
@@ -3650,5 +3475,5 @@
             cbar = plt.colorbar(format=extrapar[4],orientation=extrapar[5])
 
-        cbar.set_label(gen.latex_text(extrapar[0]) +'('+ units_lunits(extrapar[6]) + \
+        cbar.set_label(gen.latex_text(extrapar[0]) +'('+ gen.units_lunits(extrapar[6]) + \
           ')')
 
@@ -4622,6 +4447,6 @@
     for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     if mapv is not None:
@@ -4792,5 +4617,5 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
+    cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')')
 
     figname = '2Dfields_shadow'
@@ -4888,5 +4713,5 @@
           style=vaxv[1]))
         dimyT0 = gen.latex_text(variables_values(dimn[1])[0]) + ' (' +               \
-          units_lunits(dimvu) + ')'
+          gen.units_lunits(dimvu) + ')'
 
         # No following data values
@@ -4913,5 +4738,5 @@
           style=vaxv[1]))
         dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) + ' (' +               \
-          units_lunits(dimvu) + ')'
+          gen.units_lunits(dimvu) + ')'
 
         dimyt0 = tpos
@@ -4975,5 +4800,5 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
+    cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')')
 
     figname = '2Dfields_shadow_time'
@@ -5111,6 +4936,6 @@
             dimyl0.append('{:{style}}'.format(yv, style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     if reva is not None:
@@ -5269,6 +5094,6 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')')
-    plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' +  \
+    cbar.set_label(gen.latex_text(vnames[0]) + ' (' + gen.units_lunits(uts[0]) + ')')
+    plt.annotate(gen.latex_text(vnames[1]) +' (' + gen.units_lunits(uts[1]) + ') [' +  \
       mincntS + ', ' + maxcntS + ']', xy=(0.55,0.04), xycoords='figure fraction',    \
       color=coln)
@@ -5383,5 +5208,5 @@
     dimyl0 = list(timlab)
 
-    dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) +' ('+ units_lunits(valu) +\
+    dimxT0 = gen.latex_text(variables_values(dimn[0])[0]) +' ('+ gen.units_lunits(valu) +\
       ')'
     dimyT0 = timeu
@@ -5396,5 +5221,5 @@
         reva = 'transpose'
         dimxT0 = gen.latex_text(variables_values(dimn[1])[0]) + ' (' +               \
-          units_lunits(valu) + ')'
+          gen.units_lunits(valu) + ')'
     if reva is not None:
         varcv, dimxv, dimyv, dimxt, dimyt, dimxl, dimyl, dimxT, dimyT =              \
@@ -5472,6 +5297,6 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')')
-    plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' +    \
+    cbar.set_label(gen.latex_text(vnames[0]) + ' (' + gen.units_lunits(uts[0]) + ')')
+    plt.annotate(gen.latex_text(vnames[1]) +' (' + gen.units_lunits(uts[1]) + ') [' +    \
       mincntS + ', ' + maxcntS + ']', xy=(0.55,0.04), xycoords='figure fraction',    \
       color=coln)
@@ -5787,6 +5612,6 @@
     for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     if mapv is not None:
@@ -5927,5 +5752,5 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
+    cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')')
 
     # line ticks
@@ -5951,5 +5776,5 @@
 #          xycoords='axes fraction')
 
-    plt.annotate(gen.latex_text(vnamel)+ ' ('+units_lunits(utl)+')', xy=(0.75,0.04), \
+    plt.annotate(gen.latex_text(vnamel)+ ' ('+gen.units_lunits(utl)+')', xy=(0.75,0.04), \
       xycoords='figure fraction', color=linev[0])
     figname = '2Dfields_shadow_line'
@@ -6046,5 +5871,5 @@
         for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i],    \
           style=xaxv[1]))
-        dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+        dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
         # No following data values
@@ -6062,5 +5887,5 @@
         for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i],    \
           style=yaxv[1]))
-        dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
+        dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
 
         dimyt0 = (tpos-np.min(tpos))/(np.max(tpos)-np.min(tpos))
@@ -6153,5 +5978,5 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
+    cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')')
 
     # line ticks
@@ -6174,5 +5999,5 @@
         plt.annotate(dimll[it], xy=(1.01,yval), xycoords='axes fraction')
 
-    plt.annotate(gen.latex_text(vnamel)+ ' ('+units_lunits(utl)+')', xy=(0.75,0.04), \
+    plt.annotate(gen.latex_text(vnamel)+ ' ('+gen.units_lunits(utl)+')', xy=(0.75,0.04), \
       xycoords='figure fraction', color=linev[0])
     figname = '2Dfields_shadow_line'
@@ -6349,5 +6174,5 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
+    cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')')
 
     figname = 'Neighbourghood_evol'
@@ -6431,5 +6256,5 @@
 
     dimxT0 = gen.latex_text(dtit)
-    dimyT0 = gen.latex_text(vtit) + ' (' + units_lunits(vaxis) + ')'
+    dimyT0 = gen.latex_text(vtit) + ' (' + gen.units_lunits(vaxis) + ')'
 
     pixkind = 'fixpixel'
@@ -6823,5 +6648,5 @@
 
     dimxT0 = gen.latex_text(dtit)
-    dimyT0 = gen.latex_text(vtit) + ' (' + units_lunits(vaxis) + ')'
+    dimyT0 = gen.latex_text(vtit) + ' (' + gen.units_lunits(vaxis) + ')'
 
     pixkind = 'fixpixel'
@@ -7046,6 +6871,6 @@
          style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimu[0]) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimu[1]) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimu[0]) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimu[1]) + ')'
 
     if mapv is not None:
@@ -7164,5 +6989,5 @@
           uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], color=vcolor, pivot='tip', \
           length=blength)
-        plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')',       \
+        plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')',       \
           xy=(0.85,-0.10), xycoords='axes fraction', color=vcolor)
 
@@ -7171,5 +6996,5 @@
           uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], wspeed, pivot='tip',        \
           length=blength, cmap=plt.get_cmap(cmap))
-        plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')',       \
+        plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')',       \
           xy=(0.85,-0.10), xycoords='axes fraction', color='k')
 #        cbar = plt.colorbar()
@@ -7180,5 +7005,5 @@
 
 # No legend so it is imposed
-##    windlabel=windn.replace('_','\_') +' (' + units_lunits(wuts[1]) + ')'
+##    windlabel=windn.replace('_','\_') +' (' + gen.units_lunits(wuts[1]) + ')'
 ##    vecpatch = mpatches.Patch(color=vcolor, label=windlabel)
 
@@ -7274,6 +7099,6 @@
     for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
 
-    dimxT0 = variables_values(xvn)[0] + ' (' + units_lunits(xvu) + ')'
-    dimyT0 = variables_values(yvn)[0] + ' (' + units_lunits(yvu) + ')'
+    dimxT0 = variables_values(xvn)[0] + ' (' + gen.units_lunits(xvu) + ')'
+    dimyT0 = variables_values(yvn)[0] + ' (' + gen.units_lunits(yvu) + ')'
 
     if mapv is not None:
@@ -7387,5 +7212,5 @@
         cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
 
-    cbar.set_label(gen.latex_text(vname) +' ('+ units_lunits(vunits) + ')')
+    cbar.set_label(gen.latex_text(vname) +' ('+ gen.units_lunits(vunits) + ')')
 
     # Legend
@@ -7519,6 +7344,6 @@
     for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
 
-    dimxT0 = variables_values(xaxn)[0] + ' (' + units_lunits(xaxu) + ')'
-    dimyT0 = variables_values(yaxn)[0] + ' (' + units_lunits(yaxu) + ')'
+    dimxT0 = variables_values(xaxn)[0] + ' (' + gen.units_lunits(xaxu) + ')'
+    dimyT0 = variables_values(yaxn)[0] + ' (' + gen.units_lunits(yaxu) + ')'
 
     dx=xvals.shape[1]
@@ -7600,5 +7425,5 @@
         plt.quiver(xvals[::yfreq,::xfreq], yvals[::yfreq,::xfreq],                   \
           uvals[::yfreq,::xfreq], vvals[::yfreq,::xfreq], color=vcolor, pivot='middle')
-        plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')',       \
+        plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')',       \
           xy=(0.80,-0.15), xycoords='axes fraction', color=vcolor)
     else:
@@ -7618,11 +7443,11 @@
 
         if VecN == 'wind':
-            cbar.set_label('$\sqrt{u^{2} + v^{2}}$ (' + units_lunits(wuts) + ')')
+            cbar.set_label('$\sqrt{u^{2} + v^{2}}$ (' + gen.units_lunits(wuts) + ')')
         else:
             vN = vecoln.split('@')[2]
             vU = vecoln.split('@')[3]
-            cbar.set_label(vN + ' (' + units_lunits(vU) + ')')
-
-        plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')',       \
+            cbar.set_label(vN + ' (' + gen.units_lunits(vU) + ')')
+
+        plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')',       \
           xy=(0.80,-0.15), xycoords='axes fraction', color='black')
 
@@ -7784,5 +7609,5 @@
     vN = vecoln.split('@')[1]
     vU = vecoln.split('@')[2]
-    cbar.set_label(vN + ' (' + units_lunits(vU) + ')')
+    cbar.set_label(vN + ' (' + gen.units_lunits(vU) + ')')
 
     if basinid:
@@ -7799,5 +7624,5 @@
             plt.plot(xlabpos[i], ylabpos[i], 'h', color=labcol[i])
 
-    plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')',           \
+    plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')',           \
       xy=(0.80,-0.08), xycoords='axes fraction', color='black')
 
@@ -8466,8 +8291,8 @@
 #                plt.contour(lons, lats, sarea, levels = [1.], colors='gray', linewidths=1.)
 
-    cbar.set_label('upstream (' + units_lunits(uuts) + ')')
+    cbar.set_label('upstream (' + gen.units_lunits(uuts) + ')')
     plt.legend(loc=lloc)
 
-#    plt.annotate(windn.replace('_','\_') +' (' + units_lunits(wuts) + ')',           \
+#    plt.annotate(windn.replace('_','\_') +' (' + gen.units_lunits(wuts) + ')',           \
 #      xy=(0.80,-0.15), xycoords='axes fraction', color='black')
 
@@ -9197,5 +9022,5 @@
             sm._A = []
             cbar = plt.colorbar(sm)
-            cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')
+            cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')')
 
         elif lkind == 'multicoltime':
@@ -9258,5 +9083,5 @@
             plt.scatter(ang, speed, c=ev, cmap=colbar, marker=lmrk)
             cbar = plt.colorbar()
-            cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')
+            cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')')
         elif lkind == 'multicoltime':
             lmrk = gen.auto_val(lpvals[3],'x')
@@ -9297,5 +9122,5 @@
     ax.set_theta_zero_location('N')
     ax.set_theta_direction(-1)
-    plt.annotate('wind (' + units_lunits(windu) + ')', xy=(0.75,0.06), color='k',    \
+    plt.annotate('wind (' + gen.units_lunits(windu) + ')', xy=(0.75,0.06), color='k',    \
       xycoords='figure fraction', horizontalalignment='center')
 
@@ -9477,5 +9302,5 @@
             sm._A = []
             cbar = plt.colorbar(sm)
-            cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')
+            cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')')
 
         elif lkind == 'multicoltime':
@@ -9567,5 +9392,5 @@
 
             cbar = plt.colorbar()
-            cbar.set_label(lpvals[2] + ' (' + units_lunits(eunit) + ')')
+            cbar.set_label(lpvals[2] + ' (' + gen.units_lunits(eunit) + ')')
         elif lkind == 'multicoltime':
             colbar = gen.auto_val(lpvals[4],'spectral_r')
@@ -9624,5 +9449,5 @@
     ax.set_theta_zero_location('N')
     ax.set_theta_direction(-1)
-    plt.annotate('wind (' + units_lunits(windu) + ')', xy=(0.75,0.06), color='k',    \
+    plt.annotate('wind (' + gen.units_lunits(windu) + ')', xy=(0.75,0.06), color='k',    \
       xycoords='figure fraction', horizontalalignment='center')
 
@@ -9826,5 +9651,5 @@
         labstd = 'standard deviation (norm.)'
     else:
-        labstd = 'standard deviation (' + units_lunits(vunits) + ')'
+        labstd = 'standard deviation (' + gen.units_lunits(vunits) + ')'
 
     output_kind(kfig, 'Taylor', closefig)
@@ -9963,6 +9788,6 @@
             dimyl0.append('{:{style}}'.format(yv, style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     if reva is not None:
@@ -10124,9 +9949,9 @@
 
 # units labels
-    cbar.set_label(gen.latex_text(vnames[0]) + ' (' + units_lunits(uts[0]) + ')')
-    plt.annotate(gen.latex_text(vnames[1]) +' (' + units_lunits(uts[1]) + ') [' +    \
+    cbar.set_label(gen.latex_text(vnames[0]) + ' (' + gen.units_lunits(uts[0]) + ')')
+    plt.annotate(gen.latex_text(vnames[1]) +' (' + gen.units_lunits(uts[1]) + ') [' +    \
       mincntS1 + ', ' + maxcntS1 + ']', xy=(0.05,0.04), xycoords='figure fraction',  \
       color=coln1)
-    plt.annotate(gen.latex_text(vnames[2]) +' (' + units_lunits(uts[2]) + ') [' +    \
+    plt.annotate(gen.latex_text(vnames[2]) +' (' + gen.units_lunits(uts[2]) + ') [' +    \
       mincntS2 + ', ' + maxcntS2 + ']', xy=(0.55,0.04), xycoords='figure fraction',  \
       color=coln2)
@@ -10285,7 +10110,7 @@
         plt.xticks(dimyt, dimyl, rotation=yaxv[3])
         plt.yticks(dimxt, dimxl, rotation=xaxv[3])
-        plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         if dimxu is not None:
-            plt.ylabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')') 
+            plt.ylabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 
         else:
             plt.ylabel(gen.latex_text(xlabel)) 
@@ -10294,8 +10119,8 @@
         plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
         if dimxu is not None:
-            plt.xlabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')') 
+            plt.xlabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 
         else:
             plt.xlabel(gen.latex_text(xlabel))
-        plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
 
     if labels is not None:
@@ -10415,5 +10240,5 @@
         plt.xticks(dimyt, dimyl, rotation=yaxv[3])
         plt.yticks(tpos, tlabs, rotation=0)
-        plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         plt.ylabel(gen.latex_text(xlabel))
         plt.xlim(dyn, dyx)
@@ -10422,5 +10247,5 @@
         plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
         plt.xlabel(gen.latex_text(xlabel))
-        plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         plt.ylim(dyn, dyx)
 
@@ -10629,7 +10454,7 @@
         plt.xticks(dimyt, dimyl, rotation=yaxv[3])
         plt.yticks(dimxt, list(dimxl), rotation=xaxv[3])
-        plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         if dimxu is not None:
-            plt.ylabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')') 
+            plt.ylabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 
         else:
             plt.ylabel(gen.latex_text(xlabel))
@@ -10639,8 +10464,8 @@
         plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
         if dimxu is not None:
-            plt.xlabel(gen.latex_text(xlabel) + ' (' + units_lunits(dimxu) + ')') 
+            plt.xlabel(gen.latex_text(xlabel) + ' (' + gen.units_lunits(dimxu) + ')') 
         else:
             plt.xlabel(gen.latex_text(xlabel)) 
-        plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         plt.ylim(dyn, dyx)
 
@@ -10825,5 +10650,5 @@
         plt.xticks(dimyt, dimyl, rotation=yaxv[3])
         plt.yticks(tpos, tlabs, rotation=0)
-        plt.xlabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.xlabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         plt.ylabel(gen.latex_text(xlabel))
         plt.xlim(dyn, dyx)
@@ -10832,5 +10657,5 @@
         plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
         plt.xlabel(gen.latex_text(xlabel))
-        plt.ylabel(gen.latex_text(ylabel) + ' (' + units_lunits(dimyu) + ')')
+        plt.ylabel(gen.latex_text(ylabel) + ' (' + gen.units_lunits(dimyu) + ')')
         plt.ylim(dyn, dyx)
 
@@ -11112,9 +10937,9 @@
     plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
     if preu != 'None':
-        plt.xlabel(gen.latex_text(prelab) + ' (' + units_lunits(preu) + ')')
+        plt.xlabel(gen.latex_text(prelab) + ' (' + gen.units_lunits(preu) + ')')
     else:
         plt.xlabel(gen.latex_text(prelab))
     if futu != 'None':
-        plt.ylabel(gen.latex_text(futlab) + ' (' + units_lunits(futu) + ')')
+        plt.ylabel(gen.latex_text(futlab) + ' (' + gen.units_lunits(futu) + ')')
     else:
         plt.xlabel(gen.latex_text(futlab))
@@ -11371,5 +11196,5 @@
         if valuesvals[2] != 'None':
             plt.xlabel(gen.latex_text(valuesvals[1]) + ' (' +                        \
-              units_lunits(valuesvals[2]) + ')')
+              gen.units_lunits(valuesvals[2]) + ')')
         else:
             plt.xlabel(gen.latex_text(valuesvals[1]))
@@ -11383,5 +11208,5 @@
         if valuesvals[2] != 'None':
             plt.ylabel(gen.latex_text(valuesvals[1]) + ' (' +                        \
-              units_lunits(valuesvals[2]) + ')')
+              gen.units_lunits(valuesvals[2]) + ')')
         else:
             plt.ylabel(gen.latex_text(valuesvals[1]))
@@ -11656,5 +11481,5 @@
         plt.yticks(dimyt, list(dimyl), rotation=yaxv[3])
         if axunits != 'None':
-            plt.ylabel(gen.latex_text(axlab) + ' (' + units_lunits(axunits) + ')')
+            plt.ylabel(gen.latex_text(axlab) + ' (' + gen.units_lunits(axunits) + ')')
         else:
             plt.ylabel(gen.latex_text(axlab))
@@ -11665,5 +11490,5 @@
         plt.yticks(cycp, cycl, rotation=xaxv[3])
         if axunits != 'None':
-            plt.xlabel(gen.latex_text(axlab) + ' (' + units_lunits(axunits) + ')')
+            plt.xlabel(gen.latex_text(axlab) + ' (' + gen.units_lunits(axunits) + ')')
         else:
             plt.xlabel(gen.latex_text(axlab))
@@ -11795,6 +11620,6 @@
     for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     if mapv is not None:
@@ -11951,5 +11776,5 @@
     #fig.colorbar(im, cax=cbar_ax)
 # units labels
-    ulab = units_lunits(uts)
+    ulab = gen.units_lunits(uts)
     cbar_ax.set_label(ulab)
     plt.annotate(ulab, xy=(0.96,0.5), xycoords='figure fraction', rotation=90)
@@ -12057,6 +11882,6 @@
     for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i], style=yaxv[1]))
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     if mapv is not None:
@@ -12195,5 +12020,5 @@
 
             # units labels
-            cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
+            cbar.set_label(gen.latex_text(vnames) + ' (' + gen.units_lunits(uts) + ')')
 
             graphtit = gen.latex_text(ltit[it])
@@ -12719,6 +12544,6 @@
     dimyu = diminf['units'][1]
 
-    dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimxT0 = variables_values(dimn[0])[0] + ' (' + gen.units_lunits(dimxu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     pixkind = 'data'
@@ -12930,5 +12755,5 @@
 # units labels
     cbar.set_label(gen.latex_text(varinf['name']) + ' (' +                           \
-      units_lunits(varinf['units']) + ')')
+      gen.units_lunits(varinf['units']) + ')')
     
     plt.title(gen.latex_text(figtitle))
@@ -13039,5 +12864,5 @@
 
     dimxT0 = timeinf['name']
-    dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+    dimyT0 = variables_values(dimn[1])[0] + ' (' + gen.units_lunits(dimyu) + ')'
 
     pixkind = 'data'
@@ -13244,5 +13069,5 @@
 # units labels
     cbar.set_label(gen.latex_text(varinf['name']) + ' (' +                           \
-      units_lunits(varinf['units']) + ')')
+      gen.units_lunits(varinf['units']) + ')')
     
     plt.title(gen.latex_text(figtitle))
@@ -14278,5 +14103,5 @@
 # units labels
     if cbarv[1] is not None:
-        cbar.set_label(gen.latex_text(cbarv[0]) + ' (' + units_lunits(cbarv[1]) + ')')
+        cbar.set_label(gen.latex_text(cbarv[0]) + ' (' + gen.units_lunits(cbarv[1]) + ')')
     else:
         cbar.set_label(gen.latex_text(cbarv[0]))
Index: trunk/tools/generic_tools.py
===================================================================
--- trunk/tools/generic_tools.py	(revision 2709)
+++ trunk/tools/generic_tools.py	(revision 2710)
@@ -246,4 +246,5 @@
 # timefmt_timelab: Function to transform from C-like time format to general one
 # unitsdsDate: Function to know how many units of time are from a given pair of dates
+# units_lunits: Function to provide LaTeX equivalences from a given units
 # vals_around: Function to provide the 3x3 values around a given j,i point
 # xtrm_nx: Function to provide the extreme (a percentage above min,max) of a series of values
@@ -3839,4 +3840,5 @@
     fname = 'index_vec'
 
+    valpos = -1
     if type(vec) == type(np.arange(2)):
         valpos = -1
@@ -16946,4 +16948,183 @@
     return pastelc
 
+def units_lunits(u):
+    """ Function to provide LaTeX equivalences from a given units
+      u= units to transform
+    >>> units_lunits('kgkg-1')
+    '$kgkg^{-1}$'    
+    """
+    fname = 'units_lunits'
+
+    if u == 'h':
+        print fname + '_____________________________________________________________'
+        print units_lunits.__doc__
+        quit()
+
+# Units which does not change
+    same = ['1', 'category', 'cm', 'counts', 'day', 'deg', 'degree', 'degrees',      \
+      'degrees East', 'degrees Nord', 'degrees North', 'g', 'gpm', 'hour', 'hPa',    \
+      'J', 'K', 'Km', 'kg', 'km', 'm', 'minute', 'mm', 'month', 'Pa', 'rad', 's',    \
+      'second', 'um', 'x', 'y', 'year', '-']
+
+    if searchInlist(same,u):
+        lu = '$' + u + '$'
+    elif len(u.split(' ')) > 1 and u.split(' ')[1] == 'since':
+        uparts = u.split(' ')
+        ip=0
+        for up in uparts:
+            if ip == 0:
+               lu = '$' + up
+            else:
+               lu = lu + '\ ' + up
+            ip=ip+1
+        lu = lu + '$'
+    else:
+        if u == '': lu='-'
+        elif u == 'C': lu='$^{\circ}C$'
+        elif u == 'Celsius/d': lu='$^{\circ}Cd^{-1}$'
+        elif u == 'cm/yr': lu='$cm yr^{-1}$'
+        elif u == 'cmyr-1': lu='$cm yr^{-1}$'
+        elif u == 'cm yr-1': lu='$cm yr^{-1}$'
+        elif u == 'cm/year': lu='$cm year^{-1}$'
+        elif u == 'cmyear-1': lu='$cm year^{-1}$'
+        elif u == 'cm year-1': lu='$cm year^{-1}$'
+        elif u == 'days': lu='$day$'
+        elif u == 'Degrees': lu='$degrees$'
+        elif u == 'grid box centre degrees east': lu='$degrees\ East$'
+        elif u == 'degrees_East': lu='$degrees\ East$'
+        elif u == 'degrees_east': lu='$degrees\ East$'
+        elif u == 'degree_east': lu='$degrees\ East$'
+        elif u == 'degree east': lu='$degrees\ East$'
+        elif u == 'degrees longitude': lu='$degrees\ East$'
+        elif u == 'degrees latitude': lu='$degrees\ North$'
+        elif u == 'grid box centre degrees north': lu='$degrees\ North$'
+        elif u == 'degrees_North': lu='$degrees\ North$'
+        elif u == 'degrees_north': lu='$degrees\ North$'
+        elif u == 'degree_north': lu='$degrees\ North$'
+        elif u == 'degree north': lu='$degrees\ North$'
+        elif u == 'deg C': lu='$^{\circ}C$'
+        elif u == 'degC': lu='$^{\circ}C$'
+        elif u == 'deg K': lu='$K$'
+        elif u == 'degK': lu='$K$'
+        elif u == 'g/g': lu='$gg^{-1}$'
+        elif u == 'g/kg': lu='$gkg^{-1}$'
+        elif u == 'gkg-1': lu='$gkg^{-1}$'
+        elif u == 'gC/m^2': lu='$gCm^{-2}$'
+        elif u == 'gC/day/m^2': lu='$gCday^{-1}m^{-2}$'
+        elif u == 'gC/day/(m^2 tot)': lu='$gCday^{-1}(m^{-2}\ tot)$'
+        elif u == 'gC/m^2/pft': lu='$gCm^{-2}pft^{-1}$'
+        elif u == 'hPa/d': lu='$hPad^{-1}$'
+        elif u == 'hours': lu='$hour$'
+        elif u == 'J/kg': lu='$Jkg^{-1}$'
+        elif u == 'Jkg-1': lu='$Jkg^{-1}$'
+        elif u == 'K/h': lu='$Kh^{-1}$'
+        elif u == 'Kh-1': lu='$Kh^{-1}$'
+        elif u == 'K/m': lu='$Km^{-1}$'
+        elif u == 'Km-1': lu='$Km^{-1}$'
+        elif u == 'Km-3': lu='$Km^{-3}$'
+        elif u == 'K/s': lu='$Ks^{-1}$'
+        elif u == 'Ks-1': lu='$Ks^{-1}$'
+        elif u == 'K s-1': lu='$Ks^{-1}$'
+        elif u == 'K/day': lu='$Kday^{-1}$'
+        elif u == 'Kday-1': lu='$Kday^{-1}$'
+        elif u == 'K day-1': lu='$Kday^{-1}$'
+        elif u == 'kg/kg': lu='$kgkg^{-1}$'
+        elif u == 'kgkg-1': lu='$kgkg^{-1}$'
+        elif u == 'kg kg-1': lu='$kgkg^{-1}$'
+        elif u == 'kg kg**-1': lu='$kgkg^{-1}$'
+        elif u == '(kg/kg)/s': lu='$kgkg^{-1}s^{-1}$'
+        elif u == 'kgkg-1s-1': lu='$kgkg^{-1}s^{-1}$'
+        elif u == 'kg kg-1 s-1': lu='$kgkg^{-1}s^{-1}$'
+        elif u == 'Kg/m^2': lu='$kgm^{-2}$'
+        elif u == 'kg/m2': lu='$kgm^{-2}$'
+        elif u == 'kgm-2': lu='$kgm^{-2}$'
+        elif u == 'kg m-2': lu='$kgm^{-2}$'
+        elif u == 'Kg m-2': lu='$kgm^{-2}$'
+        elif u == 'kg/m2/s': lu='$kgm^{-2}s^{-1}$'
+        elif u == 'kg/m^2/s': lu='$kgm^{-2}s^{-1}$'
+        elif u == 'kg/(m2*s)': lu='$kgm^{-2}s^{-1}$'
+        elif u == 'kg/(s*m2)': lu='$kgm^{-2}s^{-1}$'
+        elif u == 'kg m-2d-1': lu='$kgm^{-2}d^{-1}$'
+        elif u == 'kg m-2 d-1': lu='$kgm^{-2}d^{-1}$'
+        elif u == 'kg m-2 day-1': lu='$kgm^{-2}d^{-1}$'
+        elif u == 'kgm-2s-1': lu='$kgm^{-2}s^{-1}$'
+        elif u == 'kg m-2 s-1': lu='$kgm^{-2}s^{-1}$'
+        elif u == 'kg-1 s-1': lu='$kg^{-1}s^{-1}$'
+        elif u == 'kg/dt_sechiba': lu='$kgdt_{sechiba}^{-1}$'
+        elif u == 'kmh-1': lu='$kmh^{-1}$'
+        elif u == 'km h-1': lu='$km h^{-1}$'
+        elif u == 'Knot': lu='$kt$'
+        elif u == 'knot': lu='$kt$'
+        elif u == 'kt': lu='$kt$'
+        elif u == '1/m': lu='$m^{-1}$'
+        elif u == 'm-1': lu='$m^{-1}$'
+        elif u == 'm2': lu='$m^{2}$'
+        elif u == 'm^2': lu='$m^{2}$'
+        elif u == 'm2/s': lu='$m2s^{-1}$'
+        elif u == 'm2s-1': lu='$m2s^{-1}$'
+        elif u == 'm2/s2': lu='$m2s^{-2}$'
+        elif u == 'm**2 s**-2': lu='$m2s^{-2}$'
+        elif u == 'm3/s': lu='$m^{3}s^{-1}$'
+        elif u == 'm^3/s': lu='$m^{3}s^{-1}$'
+        elif u == 'm/s': lu='$ms^{-1}$'
+        elif u == 'mmh-3': lu='$mmh^{-3}$'
+        elif u == 'mm/d': lu='$mm\ d^{-1}$'
+        elif u == 'mmd-1': lu='$mm\ d^{-1}$'
+        elif u == 'mm/day': lu='$mm\ day^{-1}$'
+        elif u == 'mmday-1': lu='$mm\ day^{-1}$'
+        elif u == 'mmmon-1': lu='$mm\ mon^{-1}$'
+        elif u == 'mm mon-1': lu='$mm\ mon^{-1}$'
+        elif u == 'mmmonth-1': lu='$mm\ month^{-1}$'
+        elif u == 'mm month-1': lu='$mm\ month^{-1}$'
+        elif u == 'mm yr-1': lu='$mm\ yr^{-1}$'
+        elif u == 'mmyear-1': lu='$mm\ year^{-1}$'
+        elif u == 'mm year-1': lu='$mm\ year^{-1}$'
+        elif u == 'ms-1': lu='$ms^{-1}$'
+        elif u == 'm s-1': lu='$ms^{-1}$'
+        elif u == 'm s**-1': lu='$ms^{-1}$'
+        elif u == 'ms-1m-1': lu='$ms^{-1}m^{-1}$'
+        elif u == 'm s-1m-1': lu='$ms^{-1}m^{-1}$'
+        elif u == 'm/s2': lu='$ms^{-2}$'
+        elif u == 'ms-2': lu='$ms^{-2}$'
+        elif u == 'minutes': lu='$minute$'
+        elif u == 'meters MSL': lu='$m$'
+        elif u == 'No.': lu='$number$'
+        elif u == 'numkg-1': lu='$numkg^{-1}$'
+        elif u == '#kg-1': lu='$numkg^{-1}$'
+        elif u == '\#kg-1': lu='$numkg^{-1}$'
+        elif u == '  kg(-1)': lu='$numkg^{-1}$'
+        elif u == 'numkg-1s-1': lu='$numkg^{-1}s^{-1}$'
+        elif u == '#kg-1 s-1': lu='$numkg^{-1}s^{-1}$'
+        elif u == '\#kg-1 s-1': lu='$numkg^{-1}s^{-1}$'
+        elif u == '  kg(-1) s-1': lu='$numkg^{-1}s^{-1}$'
+        elif u == 'none': lu='-'
+        elif u == 'Pa/s': lu='$Pas^{-1}$'
+        elif u == 'Pas-1': lu='$Pas^{-1}$'
+        elif u == 'W m-2': lu='$Wm^{-2}$'
+        elif u == 'Wm-2': lu='$Wm^{-2}$'
+        elif u == 'W/m2': lu='$Wm^{-2}$'
+        elif u == 'W/m^2': lu='$Wm^{-2}$'
+        elif u == '1/s': lu='$s^{-1}$'
+        elif u == 's-1': lu='$s^{-1}$'
+        elif u == 's-1 ': lu='$s^{-1}$'
+        elif u == 'seconds': lu='$second$'
+        elif u == '%': lu='\%'
+        elif u == '?': lu='-'
+        else:
+            print errormsg
+            print '  ' + fname + ': units "' + u + '" not ready!!!!'
+            Schar = []
+            for ic in range(len(u)):
+              Schar.append(ord(u[ic:ic+1]))
+            print '    character combination by ASCII numbers: ', Schar
+            quit(-1)
+
+    return lu
+
+def euqal_units(units1, units2):
+    """ Function to provide the same units of two datasets
+      units1: units of reference (from units_lunits)
+    """
+
 #quit()
 
