Index: trunk/tools/drawing.py
===================================================================
--- trunk/tools/drawing.py	(revision 1203)
+++ trunk/tools/drawing.py	(revision 1204)
@@ -9,6 +9,8 @@
 
 ## e.g. # drawing.py -f /media/data2/etudes/WRF_LMDZ/WL_HyMeX/IIphase/medic950116/wlmdza/wrfout/wrfout_d01_1995-01-13_00:00:00 -o create_movie -S 'draw_2D_shad#Time@WRFTimes@10@95@191@1#tas:East_West|-1,North_South|-1,Time|2:longitude:latitude:Summer:270.,300.:tas|at|t=0:pdf:None:None' -v T2
-## e.g. # drawing.py -f wrfout_d01_1980-03-01_00\:00\:00_Time_B0-E48-I1.nc -o draw_2D_shad -S 'tas:East_West|-1,North_South|-1,Time|2:longitude:latitude:Summer:270.,300.:tas|at|t=0:pdf:None:cyl,i' -v T2
-## e.g. # drawing.py -f ~/etudes/domains/MEDCORDEX/geo_em.d01.nc -o draw_2D_shad_cont -S 'landmask,height:Time|0:Time|0:XLONG_M:XLAT_M:auto:rainbow,auto,auto:fixc,k:%.2f:0.,1.:0.,3000.,10:landmask & height:pdf:None:lcc,i:True' -v LANDMASK,HGT_M
+## e.g. # drawing.py -o draw_2D_shad -f wrfout_d01_2001-11-11_00:00:00 -S 'tas:west_east|-1,south_north|-1,Time|2:XLONG:XLAT:auto:rainbow,auto,auto:Srange,Srange:tas|at|2001-11-11|02|UTC:png:None:cyl,l:True' -v T2
+## e.g. # drawing.py -o draw_2D_shad_time -f wrfout_d01_2001-11-11_00:00:00 -S 'hurs~west_east|-1,south_north|27,Time|-1~XLONG~WRFtime~auto~Blues,auto,auto~Srange,Srange~tas|evolution|at|south_north=27~png~None~WRFtime|hours!since!1949-12-01|exct,1,h|$%d^{%H}$|date!($[DD]^{[HH]}$)~True' -v Q2
+## e.g. # drawing.py -o draw_2D_shad_cont -f wrfout_d01_2001-11-11_00:00:00 -S 'huss,tas:west_east|-1,south_north|-1,Time|2:Time|2:XLONG:XLAT:auto:Blues,auto,auto:fixc,r:%3g:Srange,Srange:260,300,9:huss|&|tas|at|2001-11-11|02|UTC:png:None:cyl,c:True' -v Q2,T2 
+## e.g. # drawing.py -o draw_2D_shad_cont_time -f wrfout_d01_2001-11-11_00:00:00 -S 'hfls,tas;west_east|-1,south_north|27,Time|-1;south_north|27;XLONG;WRFtime;auto;BuPu,auto,auto;fixc,y;%3g;Srange,Srange;260,300,9;huss|&|tas|evolution|at|south_north=27;png;None;WRFtime|hours!since!1949-12-01|exct,1,h|$%d^{%H}$|date!($[DD]^{[HH]}$);True' -v LH,T2
 ## e.g. # drawing.py -f ~/etudes/domains/MEDCORDEX/geo_em.d01.nc -o draw_2D_shad_cont -S 'height,landmask:Time|0:Time|0:XLONG_M:XLAT_M:terrain:fixc,k:None:0.,3000.:0,1,10:MEDCORDEX height & landmask:pdf:False:lcc,i' -v HGT_M,LANDMASK
 ## e.g. # drawing.py -o draw_2D_shad_line -f 'mean_dtcon-pluc-pres_lat.nc,mean_dtcon-pluc-pres_lat.nc' -S 'dtcon,prc:bottom_top|-1,south_north|-1:latmean:presmean:seismic,k:-5.,5.:monthly|dtcon|&|prc:pdf:flip@y:None:True' -v 'dtconmean,prcmean'
@@ -35,5 +37,5 @@
 ## e.g. # drawing.py -o draw_2lines_time -f /home/lluis/etudes/WRF_LMDZ/WaquaL_highres/tests/model_graphics/WRF/current/wss_wrfout_xvar_ymean.nc,/home/lluis/etudes/WRF_LMDZ/WaquaL_highres/tests/model_graphics/WRF/current/tas_wrfout_xvar_ymean.nc -v wssvarmean,tasvarmean -S 'time:0.,20.:0.,4.:exct,1,d;%d:x:wss,tas:red,blue:2.,2.:-:2.,2.:,:wss!tas!mean!longitudinal!xvar:time!($[DD]$):0:wss_tas_wrfout_xvar_ymean:pdf'
 
-main = 'drawing.py'
+mainn = 'drawing.py'
 
 errormsg = 'ERROR -- error -- ERROR -- error'
@@ -237,13 +239,24 @@
 def draw_2D_shad_time(ncfile, values, varn):
     """ plotting a fields with shading with time values
-    draw_2D_shad(ncfile, values, varn)
+    draw_2D_shad_time(ncfile, values, varn)
       ncfile= file to use
-      values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[colorbar]~[sminv],[smaxv]~[figt]~
+      values=[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~[sminv],[smaxv]~[figt]~
        [kindfig]~[reverse]~[timevals]~[close]
         [vnamefs]: Name in the figure of the variable to be shaded
         [dimvals]: ',' list of [dimname]|[value] telling at which dimension of the 
           variable a given value is required (-1, all the length, [beg]@[end] for an interval)
-        [dimx/yvn]: name of the variables with the values of the final dimensions (x,y)
-        [colorbar]: name of the color bar
+        [dimx/yvn]: name of the variables with the values of the final dimensions (x,y)  ('WRFtime' for WRF times)
+        [dimvfmt]=[dvs],[dvf],[Ndv],[ordv]: format of the values for the non-temporal axis (or 'auto')
+          [dvs]: style of non-temporal axis ('auto' for 'pretty')
+            'Nfix', values computed at even 'Ndx'
+            'Vfix', values computed at even 'Ndx' increments
+            'pretty', values computed following aprox. 'Ndx' at 'pretty' intervals (2.,2.5,4,5,10)
+          [dvf]: format of the labels at the x-axis ('auto' for '%5g')
+          [Ndv]: Number of ticks at the x-axis ('auto' for 5)
+          [ordv]: angle of orientation of ticks at the x-axis ('auto' for horizontal)
+        [colorbarvals]=[colbarn],[fmtcolorbar],[orientation]
+          [colorbarn]: name of the color bar
+          [fmtcolorbar]: format of the numbers in the color bar 'C'-like ('auto' for %6g)
+          [orientation]: orientation of the colorbar ('vertical' (default, by 'auto'), 'horizontal')
         [smin/axv]: minimum and maximum value for the shading or:
           'Srange': for full range
@@ -262,5 +275,5 @@
           * 'flip'@[x/y]: flip the axis x or y
         [timevals]: [timen]|[units]|[kind]|[tfmt]|[label]|[timeaxis] time labels characteristics
-           [timen]; name of the time variable
+           [timen]; name of the time variable ('WRFtime' for WRF times)
            [units]; units string according to CF conventions ([tunits] since 
              [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces)
@@ -274,5 +287,5 @@
            [label]; label at the graph ('!' for spaces)
         [close]: should figure be closed (finished)
-      values='dtcon~Time|-1,bottom_top|-1~presmean~time~seismic~-3.e-6,3.e-6~monthly|'
+      values='dtcon~Time|-1,bottom_top|-1~presmean~time~auto~seismic,auto,auto~-3.e-6,3.e-6~monthly|'
         'dtcon~pdf~transpose~time|hours!since!1949-12-01|exct,2,d|%d|date!([DD])~True
       varn= [varsn] name of the variable to plot with shading
@@ -285,6 +298,6 @@
         quit()
 
-    farguments = '[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[colorbar]~[sminv],[smaxv]~'+\
-      '[figt]~[kindfig]~[reverse]~[timevals]~[close]'
+    farguments = '[vnamefs]~[dimvals]~[dimxvn]~[dimyvn]~[dimvfmt]~[colorbarvals]~' + \
+      '[sminv],[smaxv]~[figt]~[kindfig]~[reverse]~[timevals]~[close]'
     drw.check_arguments(fname,values,farguments,'~')
 
@@ -293,11 +306,12 @@
     vdimxn = values.split('~')[2]
     vdimyn = values.split('~')[3]
-    colbarn = values.split('~')[4]
-    shadminmax = values.split('~')[5]
-    figtitle = values.split('~')[6].replace('|',' ')
-    figkind = values.split('~')[7]
-    revals = values.split('~')[8]
-    timevals = values.split('~')[9]
-    close = values.split('~')[10]
+    dimvfmt = values.split('~')[4]    
+    colorbarvals = values.split('~')[5]
+    shadminmax = values.split('~')[6]
+    figtitle = values.split('~')[7].replace('|',' ')
+    figkind = values.split('~')[8]
+    revals = values.split('~')[9]
+    timevals = values.split('~')[10]
+    close = gen.Str_Bool(values.split('~')[11])
 
     ncfiles = ncfile
@@ -327,31 +341,13 @@
     varunits = objvars.getncattr('units')
 
-    if  not objsf.variables.has_key(vdimxn):
-        print errormsg
-        print '  ' + fname + ': shading file "' + ncfiles +                          \
-          '" does not have dimension variable "' +  vdimxn + '" !!'
-        quit(-1)
-    if  not objsf.variables.has_key(vdimyn):
-        print errormsg
-        print '  ' + fname + ': shading file "' + ncfiles +                          \
-          '" does not have dimension variable "' +  vdimyn + '" !!'
-        quit(-1)
-
-    objdimx = objsf.variables[vdimxn]
-    objdimy = objsf.variables[vdimyn]
-    odimxu = objdimx.getncattr('units')
-    odimyu = objdimy.getncattr('units')
-
-    if len(objdimx.shape) <= 2:
-        odimxv0 = objdimx[:]
-        odimyv0 = objdimy[:]
-
-    elif len(objdimx.shape) == 3:
-        odimxv0 = objdimx[0,:]
-        odimyv0 = objdimy[0,:]
-    else:
-        print errormsg
-        print '  ' + fname + ': shape of dimension variable:', objdimx.shape,        \
-          ' not ready!!'
+    if vdimxn != 'WRFtime' and not objsf.variables.has_key(vdimxn):
+        print errormsg
+        print '  ' + fname + ": shading file '" + ncfiles +                          \
+          "' does not have dimension variable '" +  vdimxn + "' !!"
+        quit(-1)
+    if vdimyn != 'WRFtime' and not objsf.variables.has_key(vdimyn):
+        print errormsg
+        print '  ' + fname + ": shading file '" + ncfiles +                          \
+          "' does not have dimension variable '" +  vdimyn + " !!'"
         quit(-1)
 
@@ -362,21 +358,83 @@
     timelabel = timevals.split('|')[4].replace('!',' ')
 
+    if vdimxn == 'WRFtime' or vdimyn == 'WRFtime':
+        tunitsec = timeunit.split(' ')
+        if len(tunitsec) == 4:
+            refdate = tunitsec[2][0:4]+tunitsec[2][5:7]+tunitsec[2][8:10] +          \
+              tunitsec[3][0:2] + tunitsec[3][3:5] + tunitsec[3][6:8]
+        else:
+            refdate = tunitsec[2][0:4]+tunitsec[2][5:7]+tunitsec[2][8:10]+ '000000'
+        tunitsval = tunitsec[0]
+            
+        timewrfv = objsf.variables['Times']
+        dt = timewrfv.shape[0]
+        cftimes = np.zeros((dt), dtype=np.float)
+
+        for it in range(dt):
+            wrfdates = gen.datetimeStr_conversion(timewrfv[it,:],'WRFdatetime',      \
+              'matYmdHMS')
+            cftimes[it] = gen.realdatetime1_CFcompilant(wrfdates, refdate, tunitsval)
+
+    if vdimxn != 'WRFtime':
+        objdimx = objsf.variables[vdimxn]
+        objdimxv = objdimx[:]
+        odimxu = objdimx.getncattr('units')
+    else:
+        objdimxv = cftimes
+        odimxu = timeunit
+
+    if vdimyn != 'WRFtime':
+        objdimy = objsf.variables[vdimyn]
+        objdimyv = objdimy[:]
+        odimyu = objdimy.getncattr('units')
+    else:
+        objdimyv = cftimes
+        odimyu = timeunit
+
+    if len(objdimxv.shape) <= 2:
+        odimxv0 = objdimxv[:]
+    elif len(objdimxv.shape) == 3:
+        odimxv0 = objdimxv[0,:]
+    else:
+        print errormsg
+        print '  ' + fname + ': shape of dimension variable:', objdimxv.shape,       \
+          ' not ready!!'
+        quit(-1)
+    if len(objdimyv.shape) <= 2:
+        odimyv0 = objdimyv[:]
+    elif len(objdimyv.shape) == 3:
+        odimyv0 = objdimyv[0,:]
+    else:
+        print errormsg
+        print '  ' + fname + ': shape of dimension variable:', objdimyv.shape,       \
+          ' not ready!!'
+        quit(-1)
+
 # Dimensional values
-    odxv, dimsdxv = drw.slice_variable(objsf.variables[vdimxn], dimvals.replace(',','|'))
-    odyv, dimsdyv = drw.slice_variable(objsf.variables[vdimyn], dimvals.replace(',','|'))
+    if vdimxn != 'WRFtime':
+        odxv, dimsdxv = drw.slice_variable(objsf.variables[vdimxn], dimvals.replace(',','|'))
+    else:
+        odxv = cftimes
+        dimsdxv = ['Time']
+
+    if vdimyn != 'WRFtime':
+        odyv, dimsdyv = drw.slice_variable(objsf.variables[vdimyn], dimvals.replace(',','|'))
+    else:
+        odyv = cftimes
+        dimsdyv = ['Time']
 
     if vdimxn == timename:
-        odimxv = objsf.variables[vdimxn][:]
+        odimxv = odxv
         odimxu = timelabel
         timeaxis = 'x'
-        odimyv = objsf.variables[vdimyn]
-        odimyu = odimyv.getncattr('units')
+        odimyv = odyv
+        odimyu = objdimy.getncattr('units')
         timepos, timelabels = drw.CFtimes_plot(odxv, timeunit, timekind, timefmt)
     elif vdimyn == timename:
-        odimyv = objsf.variables[vdimyn]
+        odimyv = odyv
         odimyu = timelabel
         timeaxis = 'y'
-        odimxv = objsf.variables[vdimxn]
-        odimxu = odimxv.getncattr('units')
+        odimxv = odxv
+        odimxu = objdimx.getncattr('units')
         timepos, timelabels = drw.CFtimes_plot(odyv, timeunit, timekind, timefmt)
     else:
@@ -396,9 +454,17 @@
         shading_nx.append(shadminmax.split(',')[1])
 
-    closeval = drw.Str_Bool(close)
+    colbarn, fmtcolbar, colbaror = drw.colorbar_vals(colorbarvals,',')
+    colormapv = [colbarn, fmtcolbar, colbaror]
+
+    if dimvfmt != 'auto': dimvfmt = dimvfmt + 'auto,auto,auto,auto'
+    xstyl, xaxf, Nxax, xaxor, ystyl, yaxf, Nyax, yaxor = drw.format_axes(dimvfmt,',')
+    vaxis = [xstyl, xaxf, Nxax, xaxor]
+
+    if revals == 'None':
+        revals = None
 
     drw.plot_2D_shadow_time(valshad, vnamesfig, odxv, odyv, odimxu, odimyu,          \
-      dimnamesv, colbarn, shading_nx, varunits, figtitle, figkind, revals, timeaxis, \
-      timepos, timelabels, closeval)
+      dimnamesv, vaxis, colormapv, shading_nx, varunits, figtitle, figkind, revals,  \
+      timeaxis, timepos, timelabels, close)
 
     return
@@ -639,5 +705,5 @@
     Nclevels = int(contlevels.split(',')[2])
 
-    levels_cont = drw.pretty_int(clevmin, clevmax, Nclevels)
+    levels_cont = gen.pretty_int(clevmin, clevmax, Nclevels)
 
     if len(levels_cont) <= 1: 
@@ -660,5 +726,5 @@
 
     drw.plot_2D_shadow_contour(valshad, valcont, vnamesfig, odimxv, odimyv, odimxu,  \
-      odimyu, xaxis, yaxis, dimnamesv, colbarn, fmtcolbar, colbaror, countkind,      \
+      odimyu, xaxis, yaxis, dimnamesv, [colbarn, fmtcolbar, colbaror], countkind,    \
       countlfmt, shading_nx, levels_cont, varunits, figtitle, figkind, revals,       \
       mapvalue, close)
@@ -675,6 +741,6 @@
         [dimvals/c]: list of [dimname]|[value] telling at which dimension of the 
           variable a given value is required (no dimension name, all the length)
-        [dimxvn]: name of the variables with the values of the dimension of the x-axis
-        [dimyvn]: name of the variables with the values of the dimension of the y-axis
+        [dimxvn]: name of the variables with the values of the dimension of the x-axis ('WRFtime' for WRF times)
+        [dimyvn]: name of the variables with the values of the dimension of the y-axis ('WRFtime' for WRF times)
         [dimxyf]=[dxf],[Ndx],[dyf],[Ndy]: format of the values at each axis
           [dxs]: style of x-axis ('auto' for 'pretty')
@@ -715,5 +781,5 @@
           'flip',[x/y]: flip only the dimension [x] or [y]
         [timevals]: [timen]|[units]|[kind]|[tfmt]|[label] time labels characteristics
-          [timen]; name of the time variable
+          [timen]; name of the time variable ('WRFtime' for WRF times)
           [units]; units string according to CF conventions ([tunits] since 
             [YYYY]-[MM]-[DD] [[HH]:[MI]:[SS]], '!' for spaces)
@@ -825,10 +891,10 @@
     varunits.append(objvarc.getncattr('units'))
 
-    if  not objsf.variables.has_key(vdimxn):
+    if vdimxn != 'WRFtime' and not objsf.variables.has_key(vdimxn):
         print errormsg
         print '  ' + fname + ': shading file "' + ncfiles +                          \
           '" does not have dimension variable "' +  vdimxn + '" !!'
         quit(-1)
-    if  not objsf.variables.has_key(vdimyn):
+    if vdimyn != 'WRFtime' and not objsf.variables.has_key(vdimyn):
         print errormsg
         print '  ' + fname + ': shading file "' + ncfiles +                          \
@@ -842,13 +908,39 @@
     timelabel = timevals.split('|')[4].replace('!',' ')
 
+    if vdimxn == 'WRFtime' or vdimyn == 'WRFtime':
+        tunitsec = timeunit.split(' ')
+        if len(tunitsec) == 4:
+            refdate = tunitsec[2][0:4]+tunitsec[2][5:7]+tunitsec[2][8:10] +          \
+              tunitsec[3][0:2] + tunitsec[3][3:5] + tunitsec[3][6:8]
+        else:
+            refdate = tunitsec[2][0:4]+tunitsec[2][5:7]+tunitsec[2][8:10]+ '000000'
+        tunitsval = tunitsec[0]
+
+        timewrfv = objsf.variables['Times']
+        dt = timewrfv.shape[0]
+        cftimes = np.zeros((dt), dtype=np.float)
+
+        for it in range(dt):
+            wrfdates = gen.datetimeStr_conversion(timewrfv[it,:],'WRFdatetime',      \
+              'matYmdHMS')
+            cftimes[it] = gen.realdatetime1_CFcompilant(wrfdates, refdate, tunitsval)
+
     if vdimxn == timename:
-        timevals = objsf.variables[vdimxn][:]
-        timedims = objsf.variables[vdimxn].dimensions
+        if vdimxn == 'WRFtime':
+            timevals = cftimes
+            timedims = ['Time']
+        else:
+            timevals = objsf.variables[vdimxn][:]
+            timedims = objsf.variables[vdimxn].dimensions
         dimt = 'x'
         ovalaxis = objsf.variables[vdimyn]
         ovalu = ovalaxis.getncattr('units')
     elif vdimyn == timename:
-        timevals = objsf.variables[vdimyn][:]
-        timedims = objsf.variables[vdimyn].dimensions
+        if vdimyn == 'WRFtime':
+            timevals = cftimes
+            timedims = ['Time']
+        else:
+            timevals = objsf.variables[vdimyn][:]
+            timedims = objsf.variables[vdimyn].dimensions
         dimt = 'y'
         ovalaxis = objsf.variables[vdimxn]
@@ -863,15 +955,21 @@
 # Getting only that dimensions with coincident names
     dimnvx = ovalaxis.dimensions
-
-    cutslice = []
-    for idimn in dimnvx:
+    dimsliceaxis = []
+    for dimv in dimvals.split(','):
+        adimvn = dimv.split(':')[0]
+        adimval = dimv.split(':')[1]
         found = False
-        for dimsn in dimsshad:
-            if idimn == dimsn:
-                cutslice.append(slice(0,len(objsf.dimensions[idimn])))
+        for dimtn in timedims:
+            if adimvn == dimtn:
+                dimsliceaxis.append(adimvn + ':0')
                 found = True
-        if not found: cutslice.append(slice(0,len(objsf.dimensions[idimn])))
-
-    ovalaxisv = ovalaxis[tuple(cutslice)]
+                break
+        if not found:
+            dimsliceaxis.append(dimv)
+
+    dimsliceaxisS = '|'.join(dimsliceaxis)
+
+    ovalaxisv, odimaxisv = drw.slice_variable(ovalaxis,dimsliceaxisS)
+    print fname + '; Lluis odimaxisv:', odimaxisv, timedims[0]+':0'
 
     if countlabelfmt == 'None': 
@@ -895,5 +993,5 @@
     Nclevels = int(contlevels.split(',')[2])
 
-    levels_cont = drw.pretty_int(clevmin, clevmax, Nclevels)
+    levels_cont = gen.pretty_int(clevmin, clevmax, Nclevels)
 
     if len(levels_cont) <= 1: 
@@ -915,5 +1013,5 @@
     drw.plot_2D_shadow_contour_time(valshad, valcont, vnamesfig, ovalaxisv,         \
       timevals, timepos, timelabels, ovalu, timelabel, dimt, xaxis, yaxis,          \
-      dimnamesv, colbarn, fmtcolbar, colbaror, countkind, countlfmt, shading_nx,    \
+      dimnamesv, [colbarn, fmtcolbar, colbaror], countkind, countlfmt, shading_nx,  \
       levels_cont, varunits, figtitle, figkind, revals, close)
 
@@ -4636,5 +4734,5 @@
       not drw.searchInlist(Notcheckingfile, oper):
         print errormsg
-        print '  ' + main + ': File ' + opts.ncfile + ' does not exist !!'
+        print '  ' + mainn + ': File ' + opts.ncfile + ' does not exist !!'
         quit(-1)
 
Index: trunk/tools/drawing_tools.py
===================================================================
--- trunk/tools/drawing_tools.py	(revision 1203)
+++ trunk/tools/drawing_tools.py	(revision 1204)
@@ -1450,5 +1450,5 @@
         print errormsg
         print '  ' + fname + ': longitude values with shape:', lon.shape,            \
-          'is different that latitude values with shape:', lat.shape, '(dif. size) !!'
+          'is different than latitude values with shape:', lat.shape, '(dif. size) !!'
         quit(-1)
 
@@ -2529,5 +2529,5 @@
         print '      first date:',firstTdt
         print '      last date:',lastTdt
-        print '      icrement:',basedt,trefunits
+        print '      increment:',basedt,trefunits
 
         quit(-1)
@@ -4199,6 +4199,6 @@
 #quit()
 
-def plot_2D_shadow_time(varsv,vnames,dimxv,dimyv,dimxu,dimyu,dimn,colorbar,vs,uts,   \
-  vtit,kfig,reva,taxis,tpos,tlabs,ifclose):
+def plot_2D_shadow_time(varsv, vnames, dimxv, dimyv, dimxu, dimyu, dimn, vaxv, cbarv,\
+  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
@@ -4207,5 +4207,9 @@
       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
+      vaxv= list with the non-temporal axis paramteres [style, format, number and orientation]
+      cbarv= list with the parameters of the color bar [colorbar, cbarfmt, cbaror]
+        colorbar: name of the color bar to use
+        cbarfmt: format of the numbers in the colorbar
+        cbaror: orientation of the colorbar
       vs= minmum and maximum values to plot in shadow or:
         'Srange': for full range
@@ -4236,49 +4240,69 @@
         quit()
 
+    if len(varsv.shape) != 2:
+        print errormsg
+        print '  ' + fname + ': wrong variable shape:',varsv.shape,'is has to be 2D!!'
+        quit(-1)
+
+    dimxv0 = dimxv.copy()
+    dimyv0 = dimyv.copy()
+
+    dxn = dimxv.min()
+    dxx = dimxv.max()
+    dyn = dimyv.min()
+    dyx = dimyv.max()
+
 # Definning ticks labels
     if taxis == 'x':
-        txpos = tpos
-        txlabels = tlabs
-        plxlabel = dimxu
-        typos = gen.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 = gen.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
+        dimxt0 = tpos
+        dimxl0 = tlabs
+        dimxT0 = dimxu
+        if vaxv[0] == 'pretty':
+            dimyt0 = np.array(gen.pretty_int(dyn,dyx,vaxv[2]))
+        elif vaxv[0] == 'Nfix':
+            dimyt0 = np.arange(dyn,dyx,(dyx-dyn)/(1.*vaxv[2]))
+        elif vaxv[0] == 'Vfix':
+            dimyt0 = np.arange(0,dyx,vaxv[2])
+        dimyl0 = []
+        for i in range(len(dimyt0)): dimyl0.append('{:{style}}'.format(dimyt0[i],    \
+          style=vaxv[1]))
+        dimyT0 = variables_values(dimn[1])[0] + ' (' + units_lunits(dimyu) + ')'
+
+        # No following data values
+        dimyt0 = np.arange(len(dimyt0),dtype=np.float)/(len(dimyt0))
+        pixkind = 'fixpixel'
+
+    else:
+        if vaxv[0] == 'pretty':
+            dimxt0 = np.array(gen.pretty_int(dxn,dxx,vaxv[2]))
+        elif vaxv[0] == 'Nfix':
+            dimxt0 = np.arange(dxn,dxx,(dxx-dxn)/(1.*vaxv[2]))
+        elif vaxv[0] == 'Vfix':
+            dimxt0 = np.arange(0,dxx,vaxv[2])
+        dimxl0 = []
+        for i in range(len(dimxt0)): dimxl0.append('{:{style}}'.format(dimxt0[i],    \
+          style=vaxv[1]))
+        dimxT0 = variables_values(dimn[0])[0] + ' (' + units_lunits(dimxu) + ')'
+
+        dimyt0 = tpos
+        dimyl0 = tlabs
+        dimyT0 = dimyu
+        # No following data values
+        dimxt0 = np.arange(len(dimxt0),dtype=np.float)/(len(dimxt0))
+        pixkind = 'fixpixel'
+
+    if reva is not None:
+        varsv, dimxv, dimyv, dimxt, dimyt, dimxl, dimyl, dimxT, dimyT =              \
+          transform(varsv, reva, dxv=dimxv0, dyv=dimyv0, dxt=dimxt0, dyt=dimyt0,     \
+          dxl=dimxl0, dyl=dimyl0, dxtit=dimxT0, dytit=dimyT0)
+    else:
+        dimxv = dimxv0
+        dimyv = dimyv0
+        dimxt = dimxt0
+        dimyt = dimyt0
+        dimxl = dimxl0
+        dimyl = dimyl0
+        dimxT = dimxT0
+        dimyT = dimyT0
 
     if len(dimxv.shape) == 3:
@@ -4304,105 +4328,43 @@
         quit(-1)
 
-    x,y = dxdy_lonlat(dimxv,dimyv,dxget,dyget)
+    # No following data values
+    x = (dimxv-np.min(dimxv))/(np.max(dimxv) - np.min(dimxv))
+    y = (dimyv-np.min(dimyv))/(np.max(dimyv) - np.min(dimyv))
+
+# Changing limits of the colors
+    vsend = graphic_range(vs,varsv)
 
     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()
-
-#    print 'Lluis reva0:',reva0,'x min,max:',x.min(),x.max(),' y min,max:',y.min(),y.max()
-
-# set the limits of the plot to the limits of the data
-    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 searchInlist(revas, 'transpose'):
-        plt.xticks(typos, tylabels)
-        plt.yticks(txpos, txlabels)
-        plt.xlabel(plylabel)
-        plt.ylabel(plxlabel)
-    else:
-        plt.xticks(txpos, txlabels)
-        plt.yticks(typos, tylabels)
-        plt.xlabel(plxlabel)
-        plt.ylabel(plylabel)
+    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(cbarv[0]), vmin=vsend[0], vmax=vsend[1])
+    if cbarv[2] == 'horizontal':
+        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
+        # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib
+        ticklabels= cbar.ax.get_xticklabels()
+        Nticks = len(ticklabels)
+        ticklabs = []
+        for itick in range(Nticks): ticklabs.append(ticklabels[itick].get_text())
+        cbar.ax.set_xticklabels(ticklabs,rotation=90)
+    else:
+        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
+
+    if taxis == 'x':
+        plt.xticks((dimxt-dxn)/(dxx-dxn), dimxl)
+        plt.yticks(dimyt, dimyl, rotation=vaxv[3])
+    else:
+        plt.xticks(dimxt, dimxl, rotation=vaxv[3])
+        plt.yticks((dimyt-dyn)/(dyx-dyn), dimyl)
+
+    plt.xlabel(dimxT)
+    plt.ylabel(dimyT)
+
+    plt.axis([x.min(), x.max(), y.min(), y.max()])
 
 # units labels
-    cbar.set_label(vnames.replace('_','\_') + ' (' + units_lunits(uts) + ')')
+    cbar.set_label(gen.latex_text(vnames) + ' (' + units_lunits(uts) + ')')
 
     figname = '2Dfields_shadow_time'
-    graphtit = vtit.replace('_','\_').replace('&','\&')
+
+    graphtit = gen.latex_text(vtit)
 
     plt.title(graphtit)
@@ -4413,6 +4375,5 @@
 
 def plot_2D_shadow_contour(varsv, varcv, vnames, dimxv, dimyv, dimxu, dimyu, xaxv,   \
-  yaxv, dimn, colorbar, cbarfmt, cbaror, ckind, clabfmt, vs, vc, uts, vtit, kfig,    \
-  reva, mapv, ifclose):
+  yaxv, dimn, cbarv, ckind, clabfmt, vs, vc, uts, vtit, kfig, reva, mapv, ifclose):
     """ Adding labels and other staff to the graph
       varsv= 2D values to plot with shading
@@ -4424,7 +4385,8 @@
       yaxv= list with the y-axis paramteres [style, format, number and orientation]
       dimn= dimension names to plot
-      colorbar= name of the color bar to use
-      cbarfmt= format of the numbers in the colorbar
-      cbaror= orientation of the colorbar
+      cbarv= list with the parameters of the color bar [colorbar, cbarfmt, cbaror]
+        colorbar= name of the color bar to use
+        cbarfmt= format of the numbers in the colorbar
+        cbaror= orientation of the colorbar
       ckind= contour kind
         'cmap': as it gets from colorbar
@@ -4555,8 +4517,8 @@
         dy = lon0.shape[0]
 
-        nlon = lon0[0,0]
-        xlon = lon0[dy-1,dx-1]
-        nlat = lat0[0,0]
-        xlat = lat0[dy-1,dx-1]
+        nlon = np.min(lon0)
+        xlon = np.max(lon0)
+        nlat = np.min(lat0)
+        xlat = np.max(lat0)
 
 # Thats too much! :)
@@ -4611,7 +4573,7 @@
     plt.rc('text', usetex=True)
 
-    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1])
-    if cbaror == 'horizontal':
-        cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
+    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(cbarv[0]), vmin=vs[0], vmax=vs[1])
+    if cbarv[2] == 'horizontal':
+        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
         # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib
         ticklabels= cbar.ax.get_xticklabels()
@@ -4621,5 +4583,5 @@
         cbar.ax.set_xticklabels(ticklabs,rotation=90)
     else:
-        cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
+        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
 
 # contour
@@ -4651,7 +4613,7 @@
         m.drawcoastlines()
 
-        meridians = gen.pretty_int(nlon,xlon,5)
+        meridians = gen.pretty_int(nlon,xlon,xaxv[2])
         m.drawmeridians(meridians,labels=[True,False,False,True])
-        parallels = gen.pretty_int(nlat,xlat,5)
+        parallels = gen.pretty_int(nlat,xlat,yaxv[2])
         m.drawparallels(parallels,labels=[False,True,True,False])
 
@@ -4700,6 +4662,6 @@
 
 def plot_2D_shadow_contour_time(varsv, varcv, vnames, valv, timv, timpos, timlab,    \
-  valu, timeu, axist, xaxv, yaxv, dimn, colorbar, cbarfmt, cbaror, ckind, clabfmt,   \
-  vs, vc, uts, vtit, kfig, reva, ifclose):
+  valu, timeu, axist, xaxv, yaxv, dimn, cbarv, ckind, clabfmt, vs, vc, uts, vtit,    \
+  kfig, reva, ifclose):
     """ Adding labels and other staff to the graph
       varsv= 2D values to plot with shading
@@ -4716,7 +4678,8 @@
       yaxv= list with the y-axis paramteres [style, format, number and orientation]
       dimn= dimension names to plot
-      colorbar= name of the color bar to use
-      cbarfmt= format of the numbers in the colorbar
-      cbaror= orientation of the colorbar
+      cbarv= list with the parameters of the color bar [colorbar, cbarfmt, cbaror]
+        colorbar= name of the color bar to use
+        cbarfmt= format of the numbers in the colorbar
+        cbaror= orientation of the colorbar
       ckind= contour kind
         'cmap': as it gets from colorbar
@@ -4816,4 +4779,7 @@
     x,y = gen.lonlat2D(dimxv,dimyv)
 
+# Changing limits of the colors
+    vsend = graphic_range(vs,varsv)
+
     plt.rc('text', usetex=True)
 
@@ -4823,7 +4789,7 @@
 #    plt.ylim(dimyt[0],dimyt[len(dimyt)-1])
 
-    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(colorbar), vmin=vs[0], vmax=vs[1])
-    if cbaror == 'horizontal':
-        cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
+    plt.pcolormesh(x, y, varsv, cmap=plt.get_cmap(cbarv[0]), vmin=vsend[0], vmax=vsend[1])
+    if cbarv[2] == 'horizontal':
+        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
         # From: http://stackoverflow.com/questions/32050030/rotation-of-colorbar-tick-labels-in-matplotlib
         ticklabels= cbar.ax.get_xticklabels()
@@ -4833,5 +4799,5 @@
         cbar.ax.set_xticklabels(ticklabs,rotation=90)
     else:
-        cbar = plt.colorbar(format=cbarfmt,orientation=cbaror)
+        cbar = plt.colorbar(format=cbarv[1],orientation=cbarv[2])
     
 # contour
