Index: /trunk/tools/drawing_tools.py
===================================================================
--- /trunk/tools/drawing_tools.py	(revision 1088)
+++ /trunk/tools/drawing_tools.py	(revision 1089)
@@ -1755,4 +1755,6 @@
         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}$'
@@ -3925,4 +3927,256 @@
         x = lon0
         y = lat0
+
+    vsend = np.zeros((2), dtype=np.float)
+# Changing limits of the colors
+    if type(vs[0]) != type(np.float(1.)):
+        if vs[0] == 'Srange':
+            vsend[0] = np.min(varsv)
+            vsend[1] = np.max(varsv)
+        elif vs[0][0:11] == 'Saroundmean':
+            meanv = np.mean(varsv)
+            permean = np.float(vs[0].split('@')[1])
+            minv = np.min(varsv)*permean
+            maxv = np.max(varsv)*permean
+            minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
+            vsend[0] = meanv-minextrm
+            vsend[1] = meanv+minextrm
+        elif vs[0][0:13] == 'Saroundminmax':
+            permean = np.float(vs[0].split('@')[1])
+            minv = np.min(varsv)*permean
+            maxv = np.max(varsv)*permean
+            vsend[0] = minv
+            vsend[1] = maxv
+        elif vs[0][0:17] == 'Saroundpercentile':
+            medianv = np.median(varsv)
+            valper = np.float(vs[0].split('@')[1])
+            minv = np.percentile(varsv, valper)
+            maxv = np.percentile(varsv, 100.-valper)
+            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
+            vsend[0] = medianv-minextrm
+            vsend[1] = medianv+minextrm
+        elif vs[0][0:5] == 'Smean':
+            meanv = np.mean(varsv)
+            permean = np.float(vs[0].split('@')[1])
+            minv = np.min(varsv)*permean
+            maxv = np.max(varsv)*permean
+            minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
+            vsend[0] = -minextrm
+            vsend[1] = minextrm
+        elif vs[0][0:7] == 'Smedian':
+            medianv = np.median(varsv)
+            permedian = np.float(vs[0].split('@')[1])
+            minv = np.min(varsv)*permedian
+            maxv = np.max(varsv)*permedian
+            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
+            vsend[0] = -minextrm
+            vsend[1] = minextrm
+        elif vs[0][0:11] == 'Spercentile':
+            medianv = np.median(varsv)
+            valper = np.float(vs[0].split('@')[1])
+            minv = np.percentile(varsv, valper)
+            maxv = np.percentile(varsv, 100.-valper)
+            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
+            vsend[0] = -minextrm
+            vsend[1] = minextrm
+        else:
+            print errormsg
+            print '  ' + fname + ": range '" + vs[0] + "' not ready!!!"
+            quit(-1)
+        print '    ' + fname + ': modified shadow min,max:',vsend
+    else:
+        vsend[0] = vs[0]
+
+    if type(vs[0]) != type(np.float(1.)):
+        if vs[1] == 'range':
+            vsend[1] = np.max(varsv)
+    else:
+        vsend[1] = vs[1]
+
+    plt.rc('text', usetex=True)
+
+    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vsend[0], vmax=vsend[1])
+    cbar = plt.colorbar()
+
+    if not mapv is None:
+        if colorbar == 'gist_gray':
+            m.drawcoastlines(color="red")
+        else:
+            m.drawcoastlines()
+
+        meridians = pretty_int(nlon,xlon,5)
+        m.drawmeridians(meridians,labels=[True,False,False,True])
+        parallels = pretty_int(nlat,xlat,5)
+        m.drawparallels(parallels,labels=[False,True,True,False])
+
+        plt.xlabel('W-E')
+        plt.ylabel('S-N')
+    else:
+        plt.xlabel(variables_values(dimn[1])[0].replace('_','\_') + ' (' +           \
+          units_lunits(dimxu) + ')')
+        plt.ylabel(variables_values(dimn[0])[0].replace('_','\_') + ' (' +           \
+          units_lunits(dimyu) + ')')
+
+    txpos = pretty_int(x.min(),x.max(),5)
+    typos = pretty_int(y.min(),y.max(),5)
+    txlabels = list(txpos)
+    for i in range(len(txlabels)): txlabels[i] = str(txlabels[i])
+    tylabels = list(typos)
+    for i in range(len(tylabels)): tylabels[i] = str(tylabels[i])
+
+# set the limits of the plot to the limits of the data
+
+    if searchInlist(revas,'transpose'):
+        x0 = y
+        y0 = x
+        x = x0
+        y = y0
+#    print 'Lluis reva0:',reva0,'x min,max:',x.min(),x.max(),' y min,max:',y.min(),y.max()
+
+    if reva0 == 'flip':
+        if reva.split('@')[1] == 'x':
+            plt.axis([x.max(), x.min(), y.min(), y.max()])
+        elif reva.split('@')[1] == 'y':
+            plt.axis([x.min(), x.max(), y.max(), y.min()])
+        else:
+            plt.axis([x.max(), x.min(), y.max(), y.min()])
+    else:
+        plt.axis([x.min(), x.max(), y.min(), y.max()])
+
+    if mapv is None:
+        plt.xticks(txpos, txlabels)
+        plt.yticks(typos, tylabels)
+
+# units labels
+    cbar.set_label(vnames.replace('_','\_') + ' (' + units_lunits(uts) + ')')
+
+    figname = '2Dfields_shadow'
+    graphtit = vtit.replace('_','\_').replace('&','\&')
+
+    plt.title(graphtit)
+    
+    output_kind(kfig, figname, ifclose)
+
+    return
+
+#Nvals=50
+#vals1 = np.zeros((Nvals,Nvals), dtype= np.float)
+#for j in range(Nvals):
+#    for i in range(Nvals):
+#      vals1[j,i]=np.sqrt((j-Nvals/2)**2. + (i-Nvals/2)**2.)
+
+#plot_2D_shadow(vals1, 'var1', np.arange(50)*1., np.arange(50)*1., 'ms-1',            \
+#  'm', ['lat','lon'], 'rainbow', [0, Nvals], 'ms-1', 'test var1', 'pdf', 'None',     \
+#  None, True)
+#quit()
+
+def plot_2D_shadow_time(varsv,vnames,dimxv,dimyv,dimxu,dimyu,dimn,colorbar,vs,uts,   \
+  vtit,kfig,reva,taxis,tpos,tlabs,ifclose):
+    """ Plotting a 2D field with one of the axes being time
+      varsv= 2D values to plot with shading
+      vnames= shading variable name for the figure
+      dim[x/y]v= values at the axes of x and y
+      dim[x/y]u= units at the axes of x and y
+      dimn= dimension names to plot
+      colorbar= name of the color bar to use
+      vs= minmum and maximum values to plot in shadow or:
+        'Srange': for full range
+        'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)
+        'Saroundminmax@val': for min*val,max*val
+        'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),
+          percentile_(100-val)-median)
+        'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)
+        'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)
+        'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),
+           percentile_(100-val)-median)
+      uts= units of the variable to shadow
+      vtit= title of the variable
+      kfig= kind of figure (jpg, pdf, png)
+      reva= 
+        * 'transpose': reverse the axes (x-->y, y-->x)
+        * 'flip'@[x/y]: flip the axis x or y
+      taxis= Which is the time-axis 
+      tpos= positions of the time ticks
+      tlabs= labels of the time ticks
+      ifclose= boolean value whether figure should be close (finish) or not
+    """
+    fname = 'plot_2D_shadow_time'
+
+    if varsv == 'h':
+        print fname + '_____________________________________________________________'
+        print plot_2D_shadow_time.__doc__
+        quit()
+
+# Definning ticks labels
+    if taxis == 'x':
+        txpos = tpos
+        txlabels = tlabs
+        plxlabel = dimxu
+        typos = pretty_int(np.min(dimyv),np.max(dimyv),10)
+        tylabels = list(typos)
+        for i in range(len(tylabels)): tylabels[i] = str(tylabels[i])
+        plylabel = variables_values(dimn[0])[0].replace('_','\_') + ' (' +           \
+          units_lunits(dimyu) + ')'
+    else:
+        txpos = pretty_int(np.min(dimxv),np.max(dimxv),10)
+        txlabels = list(txpos)
+        plxlabel = variables_values(dimn[1])[0].replace('_','\_') + ' (' +           \
+          units_lunits(dimxu) + ')'
+        typos = tpos
+        tylabels = tlabs
+        plylabel = dimyu
+
+# Transposing/flipping axis
+    if reva.find('|') != 0:
+        revas = reva.split('|')
+        reva0 = ''
+    else:
+        revas = [reva]
+        reva0 = reva
+
+    for rev in revas:
+        if rev[0:4] == 'flip':
+            reva0 = 'flip'
+            if len(reva.split('@')) != 2:
+                 print errormsg
+                 print '  ' + fname + ': flip is given', reva, 'but not axis!'
+                 quit(-1)
+            else:
+                 print "  flipping '" + rev.split('@')[1] + "' axis !"
+
+        if rev == 'transpose':
+            print '  reversing the axes of the figure (x-->y, y-->x)!!'
+# Flipping values of variable
+            varsv = np.transpose(varsv)
+            dxv = dimyv
+            dyv = dimxv
+            dimxv = dxv
+            dimyv = dyv
+
+    if len(dimxv.shape) == 3:
+        dxget='1,2'
+    elif len(dimxv.shape) == 2:
+        dxget='0,1'
+    elif len(dimxv.shape) == 1:
+        dxget='0'
+    else:
+        print errormsg
+        print '  ' + fname + ': shape of x-values:',dimxv.shape,'not ready!!'
+        quit(-1)
+
+    if len(dimyv.shape) == 3:
+        dyget='1,2'
+    elif len(dimyv.shape) == 2:
+        dyget='0,1'
+    elif len(dimyv.shape) == 1:
+        dyget='0'
+    else:
+        print errormsg
+        print '  ' + fname + ': shape of y-values:',dimyv.shape,'not ready!!'
+        quit(-1)
+
+    x,y = dxdy_lonlat(dimxv,dimyv,dxget,dyget)
+
+    plt.rc('text', usetex=True)
 
     vsend = np.zeros((2), dtype=np.float)
@@ -3991,255 +4245,4 @@
         vsend[1] = vs[1]
 
-    plt.rc('text', usetex=True)
-
-    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vsend[0], vmax=vsend[1])
-    cbar = plt.colorbar()
-
-    if not mapv is None:
-        if colorbar == 'gist_gray':
-            m.drawcoastlines(color="red")
-        else:
-            m.drawcoastlines()
-
-        meridians = pretty_int(nlon,xlon,5)
-        m.drawmeridians(meridians,labels=[True,False,False,True])
-        parallels = pretty_int(nlat,xlat,5)
-        m.drawparallels(parallels,labels=[False,True,True,False])
-
-        plt.xlabel('W-E')
-        plt.ylabel('S-N')
-    else:
-        plt.xlabel(variables_values(dimn[1])[0].replace('_','\_') + ' (' +           \
-          units_lunits(dimxu) + ')')
-        plt.ylabel(variables_values(dimn[0])[0].replace('_','\_') + ' (' +           \
-          units_lunits(dimyu) + ')')
-
-    txpos = pretty_int(x.min(),x.max(),5)
-    typos = pretty_int(y.min(),y.max(),5)
-    txlabels = list(txpos)
-    for i in range(len(txlabels)): txlabels[i] = str(txlabels[i])
-    tylabels = list(typos)
-    for i in range(len(tylabels)): tylabels[i] = str(tylabels[i])
-
-# set the limits of the plot to the limits of the data
-
-    if searchInlist(revas,'transpose'):
-        x0 = y
-        y0 = x
-        x = x0
-        y = y0
-#    print 'Lluis reva0:',reva0,'x min,max:',x.min(),x.max(),' y min,max:',y.min(),y.max()
-
-    if reva0 == 'flip':
-        if reva.split('@')[1] == 'x':
-            plt.axis([x.max(), x.min(), y.min(), y.max()])
-        elif reva.split('@')[1] == 'y':
-            plt.axis([x.min(), x.max(), y.max(), y.min()])
-        else:
-            plt.axis([x.max(), x.min(), y.max(), y.min()])
-    else:
-        plt.axis([x.min(), x.max(), y.min(), y.max()])
-
-    if mapv is None:
-        plt.xticks(txpos, txlabels)
-        plt.yticks(typos, tylabels)
-
-# units labels
-    cbar.set_label(vnames.replace('_','\_') + ' (' + units_lunits(uts) + ')')
-
-    figname = '2Dfields_shadow'
-    graphtit = vtit.replace('_','\_').replace('&','\&')
-
-    plt.title(graphtit)
-    
-    output_kind(kfig, figname, ifclose)
-
-    return
-
-#Nvals=50
-#vals1 = np.zeros((Nvals,Nvals), dtype= np.float)
-#for j in range(Nvals):
-#    for i in range(Nvals):
-#      vals1[j,i]=np.sqrt((j-Nvals/2)**2. + (i-Nvals/2)**2.)
-
-#plot_2D_shadow(vals1, 'var1', np.arange(50)*1., np.arange(50)*1., 'ms-1',            \
-#  'm', ['lat','lon'], 'rainbow', [0, Nvals], 'ms-1', 'test var1', 'pdf', 'None',     \
-#  None, True)
-#quit()
-
-def plot_2D_shadow_time(varsv,vnames,dimxv,dimyv,dimxu,dimyu,dimn,colorbar,vs,uts,   \
-  vtit,kfig,reva,taxis,tpos,tlabs,ifclose):
-    """ Plotting a 2D field with one of the axes being time
-      varsv= 2D values to plot with shading
-      vnames= shading variable name for the figure
-      dim[x/y]v= values at the axes of x and y
-      dim[x/y]u= units at the axes of x and y
-      dimn= dimension names to plot
-      colorbar= name of the color bar to use
-      vs= minmum and maximum values to plot in shadow or:
-        'Srange': for full range
-        'Saroundmean@val': for mean-xtrm,mean+xtrm where xtrm = np.min(mean-min@val,max@val-mean)
-        'Saroundminmax@val': for min*val,max*val
-        'Saroundpercentile@val': for median-xtrm,median+xtrm where xtrm = np.min(median-percentile_(val),
-          percentile_(100-val)-median)
-        'Smean@val': for -xtrm,xtrm where xtrm = np.min(mean-min*@val,max*@val-mean)
-        'Smedian@val': for -xtrm,xtrm where xtrm = np.min(median-min@val,max@val-median)
-        'Spercentile@val': for -xtrm,xtrm where xtrm = np.min(median-percentile_(val),
-           percentile_(100-val)-median)
-      uts= units of the variable to shadow
-      vtit= title of the variable
-      kfig= kind of figure (jpg, pdf, png)
-      reva= 
-        * 'transpose': reverse the axes (x-->y, y-->x)
-        * 'flip'@[x/y]: flip the axis x or y
-      taxis= Which is the time-axis 
-      tpos= positions of the time ticks
-      tlabs= labels of the time ticks
-      ifclose= boolean value whether figure should be close (finish) or not
-    """
-    fname = 'plot_2D_shadow_time'
-
-    if varsv == 'h':
-        print fname + '_____________________________________________________________'
-        print plot_2D_shadow_time.__doc__
-        quit()
-
-# Definning ticks labels
-    if taxis == 'x':
-        txpos = tpos
-        txlabels = tlabs
-        plxlabel = dimxu
-        typos = pretty_int(np.min(dimyv),np.max(dimyv),10)
-        tylabels = list(typos)
-        for i in range(len(tylabels)): tylabels[i] = str(tylabels[i])
-        plylabel = variables_values(dimn[0])[0].replace('_','\_') + ' (' +           \
-          units_lunits(dimyu) + ')'
-    else:
-        txpos = pretty_int(np.min(dimxv),np.max(dimxv),10)
-        txlabels = list(txpos)
-        plxlabel = variables_values(dimn[1])[0].replace('_','\_') + ' (' +           \
-          units_lunits(dimxu) + ')'
-        typos = tpos
-        tylabels = tlabs
-        plylabel = dimyu
-
-# Transposing/flipping axis
-    if reva.find('|') != 0:
-        revas = reva.split('|')
-        reva0 = ''
-    else:
-        revas = [reva]
-        reva0 = reva
-
-    for rev in revas:
-        if rev[0:4] == 'flip':
-            reva0 = 'flip'
-            if len(reva.split('@')) != 2:
-                 print errormsg
-                 print '  ' + fname + ': flip is given', reva, 'but not axis!'
-                 quit(-1)
-            else:
-                 print "  flipping '" + rev.split('@')[1] + "' axis !"
-
-        if rev == 'transpose':
-            print '  reversing the axes of the figure (x-->y, y-->x)!!'
-# Flipping values of variable
-            varsv = np.transpose(varsv)
-            dxv = dimyv
-            dyv = dimxv
-            dimxv = dxv
-            dimyv = dyv
-
-    if len(dimxv.shape) == 3:
-        dxget='1,2'
-    elif len(dimxv.shape) == 2:
-        dxget='0,1'
-    elif len(dimxv.shape) == 1:
-        dxget='0'
-    else:
-        print errormsg
-        print '  ' + fname + ': shape of x-values:',dimxv.shape,'not ready!!'
-        quit(-1)
-
-    if len(dimyv.shape) == 3:
-        dyget='1,2'
-    elif len(dimyv.shape) == 2:
-        dyget='0,1'
-    elif len(dimyv.shape) == 1:
-        dyget='0'
-    else:
-        print errormsg
-        print '  ' + fname + ': shape of y-values:',dimyv.shape,'not ready!!'
-        quit(-1)
-
-    x,y = dxdy_lonlat(dimxv,dimyv,dxget,dyget)
-
-    plt.rc('text', usetex=True)
-
-    vsend = np.zeros((2), dtype=np.float)
-# Changing limits of the colors
-    if type(vs[0]) != type(np.float(1.)):
-        if vs[0] == 'Srange':
-            vsend[0] = np.min(varsv)
-        elif vs[0][0:11] == 'Saroundmean':
-            meanv = np.mean(varsv)
-            permean = np.float(vs[0].split('@')[1])
-            minv = np.min(varsv)*permean
-            maxv = np.max(varsv)*permean
-            minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
-            vsend[0] = meanv-minextrm
-            vsend[1] = meanv+minextrm
-        elif vs[0][0:13] == 'Saroundminmax':
-            permean = np.float(vs[0].split('@')[1])
-            minv = np.min(varsv)*permean
-            maxv = np.max(varsv)*permean
-            vsend[0] = minv
-            vsend[1] = maxv
-        elif vs[0][0:17] == 'Saroundpercentile':
-            medianv = np.median(varsv)
-            valper = np.float(vs[0].split('@')[1])
-            minv = np.percentile(varsv, valper)
-            maxv = np.percentile(varsv, 100.-valper)
-            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
-            vsend[0] = medianv-minextrm
-            vsend[1] = medianv+minextrm
-        elif vs[0][0:5] == 'Smean':
-            meanv = np.mean(varsv)
-            permean = np.float(vs[0].split('@')[1])
-            minv = np.min(varsv)*permean
-            maxv = np.max(varsv)*permean
-            minextrm = np.min([np.abs(meanv-minv), np.abs(maxv-meanv)])
-            vsend[0] = -minextrm
-            vsend[1] = minextrm
-        elif vs[0][0:7] == 'Smedian':
-            medianv = np.median(varsv)
-            permedian = np.float(vs[0].split('@')[1])
-            minv = np.min(varsv)*permedian
-            maxv = np.max(varsv)*permedian
-            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
-            vsend[0] = -minextrm
-            vsend[1] = minextrm
-        elif vs[0][0:11] == 'Spercentile':
-            medianv = np.median(varsv)
-            valper = np.float(vs[0].split('@')[1])
-            minv = np.percentile(varsv, valper)
-            maxv = np.percentile(varsv, 100.-valper)
-            minextrm = np.min([np.abs(medianv-minv), np.abs(maxv-medianv)])
-            vsend[0] = -minextrm
-            vsend[1] = minextrm
-        else:
-            print errormsg
-            print '  ' + fname + ": range '" + vs[0] + "' not ready!!!"
-            quit(-1)
-        print '    ' + fname + ': modified shadow min,max:',vsend
-    else:
-        vsend[0] = vs[0]
-
-    if type(vs[0]) != type(np.float(1.)):
-        if vs[1] == 'range':
-            vsend[1] = np.max(varsv)
-    else:
-        vsend[1] = vs[1]
-
     plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vsend[0], vmax=vsend[1])
     cbar = plt.colorbar()
