Index: trunk/tools/drawing.py
===================================================================
--- trunk/tools/drawing.py	(revision 395)
+++ trunk/tools/drawing.py	(revision 396)
@@ -519,5 +519,5 @@
     odimyu = objdimy.getncattr('units')
 
-# Getting only tat dimensions with coincident names
+# Getting only that dimensions with coincident names
     dimnvx = objdimx.dimensions
     cutslice = []
@@ -580,6 +580,4 @@
 
     if mapvalue == 'None': mapvalue = None
-
-    print '  ' + fname + ': Lluis shapes valshad:',valshad.shape,'valcont:',valcont.shape
 
     drw.plot_2D_shadow_contour(valshad, valcont, vnamesfig, odimxv, odimyv, odimxu,  \
@@ -764,4 +762,5 @@
     if vdimxn == timename:
         timevals = objsf.variables[vdimxn][:]
+        timedims = objsf.variables[vdimxn].dimensions
         dimt = 'x'
         ovalaxis = objsf.variables[vdimyn]
@@ -769,4 +768,5 @@
     elif vdimyn == timename:
         timevals = objsf.variables[vdimyn][:]
+        timedims = objsf.variables[vdimyn].dimensions
         dimt = 'y'
         ovalaxis = objsf.variables[vdimxn]
@@ -779,14 +779,28 @@
     timepos, timelabels = drw.CFtimes_plot(timevals, timeunit, timekind, timefmt)
 
-    if len(ovalaxis.shape) <= 2:
-        ovalaxisv = ovalaxis[:]
-
-    elif len(ovalaxis.shape) == 3:
-        ovalaxisv = ovalaxis[0,:]
-    else:
-        print errormsg
-        print '  ' + fname + ': shape of dimension variable:', ovalaxis.shape,       \
-          ' not ready!!'
-        quit(-1)
+# Getting only that dimensions with coincident names
+    dimnvx = ovalaxis.dimensions
+
+    cutslice = []
+    for idimn in dimsshad:
+        found = False
+        for dimsn in dimnvx:
+            if idimn == dimsn:
+                cutslice.append(slice(0,len(objsf.dimensions[idimn])))
+                found = True
+        if not found: cutslice.append(0)
+
+    ovalaxisv = ovalaxis[tuple(cutslice)]
+
+##    if len(ovalaxis.shape) <= 2:
+##        ovalaxisv = ovalaxis[:]
+
+##    elif len(ovalaxis.shape) == 3:
+##        ovalaxisv = ovalaxis[0,:]
+##    else:
+##        print errormsg
+##        print '  ' + fname + ': shape of dimension variable:', ovalaxis.shape,       \
+##          ' not ready!!'
+##        quit(-1)
 
     if countlabelfmt == 'None': 
@@ -1922,6 +1936,4 @@
     dimxv = dimtvalues[0:dimtsqx]
     dimyv = dimtvalues[0:dimt:dimtsqx]
-
-    print 'Lluis lens: dimxv, dimyv:',len(dimxv), len(dimyv)
 
     dimn = ['time','time']
Index: trunk/tools/drawing_tools.py
===================================================================
--- trunk/tools/drawing_tools.py	(revision 395)
+++ trunk/tools/drawing_tools.py	(revision 396)
@@ -201,4 +201,8 @@
 
     Ndimcut = len(dimslice.split('|'))
+    if Ndimcut == 0:
+        Ndimcut = 1
+        dimcut = list(dimslice)
+
     dimsl = dimslice.split('|')
 
@@ -207,12 +211,13 @@
 
     for idd in range(Ndimvar):
+        found = False
         for idc in range(Ndimcut):
             dimcutn = dimsl[idc].split(':')[0]
             dimcutv = dimsl[idc].split(':')[1]
-            if vardims[idd] == dimcutn: 
-                posfrac = dimcutv.find(':')
+            if vardims[idd] == dimcutn:
+                posfrac = dimcutv.find('@')
                 if posfrac != -1:
-                    inifrac = int(dimcutv.split(':')[0])
-                    endfrac = int(dimcutv.split(':')[1])
+                    inifrac = int(dimcutv.split('@')[0])
+                    endfrac = int(dimcutv.split('@')[1])
                     varvalsdim.append(slice(inifrac,endfrac))
                     dimnslice.append(vardims[idd])
@@ -221,7 +226,12 @@
                         varvalsdim.append(slice(0,varobj.shape[idd]))
                         dimnslice.append(vardims[idd])
+                    elif int(dimcutv) == -9:
+                        varvalsdim.append(int(varobj.shape[idd])-1)
                     else:
                         varvalsdim.append(int(dimcutv))
                 break
+        if not found and not searchInlist(dimnslice,vardims[idd]):
+            varvalsdim.append(slice(0,varobj.shape[idd]))
+            dimnslice.append(vardims[idd])
 
     varvalues = varobj[tuple(varvalsdim)]
@@ -1447,4 +1457,5 @@
         elif u == 'kg/(s*m2)': lu='$kgm^{-2}s^{-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 == '1/m': lu='$m^{-1}$'
         elif u == 'm-1': lu='$m^{-1}$'
@@ -1583,5 +1594,4 @@
 
     potinterval = np.log10(interval)
-    print 'LLuis minv, maxv:',minv,maxv,'potinterval:',potinterval
     Ipotint = int(potinterval)
     intvalue = np.float(interval / np.float(Nint))
@@ -3692,4 +3702,5 @@
     fname = 'plot_2D_shadow_contour'
 
+
     if varsv == 'h':
         print fname + '_____________________________________________________________'
@@ -3816,5 +3827,4 @@
             else:
                 y = np.zeros((dimxv.shape), dtype=np.float)
-                print 'Lluis shapes y:',y.shape,'dimyv:',dimyv.shape,'dimxv:',dimxv.shape
 
                 if y.shape[0] == dimyv.shape[0]:
Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 395)
+++ trunk/tools/nc_var_tools.py	(revision 396)
@@ -10695,6 +10695,4 @@
         dimt = objfile.variables[timn].shape
 
-    print 'Lluis Ttraj:',Ttraj+Tbeg,'dimt:',dimt
-
     if Tbeg + Ttraj > dimt:
         print errormsg
@@ -10979,5 +10977,4 @@
                       fillValue
 
-                    print 'Lluis slice2D:',slice2D,'slicev:',slicev
                     varvalst[tuple(slice2D)] = varobj[tuple(slicev)]
                     varvals[it,:,:,:] = varvalst
@@ -11935,4 +11932,8 @@
 
     Ndimcut = len(dimslice.split('|'))
+    if Ndimcut == 0:
+        Ndimcut = 1
+        dimcut = list(dimslice)
+
     dimsl = dimslice.split('|')
 
@@ -11941,4 +11942,5 @@
 
     for idd in range(Ndimvar):
+        found = False
         for idc in range(Ndimcut):
             dimcutn = dimsl[idc].split(':')[0]
@@ -11960,4 +11962,7 @@
                         varvalsdim.append(int(dimcutv))
                 break
+        if not found and not searchInlist(dimnslice,vardims[idd]):
+            varvalsdim.append(slice(0,varobj.shape[idd]))
+            dimnslice.append(vardims[idd])
 
     varvalues = varobj[tuple(varvalsdim)]
@@ -11994,23 +11999,36 @@
 
     if Nvardims != Ncutdims:
-        print errormsg
+        print warnmsg
         print '  ' + fname + ': cutting for',Ncutdims,'but variable has:',Nvardims,  \
           '!!'
-        quit(-1)
-
-    for idc in range(Ncutdims):
+#        quit(-1)
+    cutdimvals = ''
+    for idv in range(Nvardims):
         found = False
-        for idv in range(Nvardims):
+        Lcutdimvals = len(cutdimvals)
+        for idc in range(Ncutdims):
             if vardims[idv] == cutdims[idc].split(':')[0]:
+                if Lcutdimvals > 0:
+                    cutdimvals = cutdimvals + '|' + cutdims[idc]
+                else:
+                    cutdimvals = cutdims[idc]
+
                 found = True
                 break
         if not found:
-            print errormsg
-            print '  ' + fname + ": cutting by '",cutdims[idc].split(':')[0],        \
-              "' but variable has not it !!!"
-            print '  variable dims:',vardims
-            quit(-1)
-
-    slicedvar, dimslice = slice_variable(ovar, dimvals)
+#            print errormsg
+#            print '  ' + fname + ": cutting by '",cutdims[idc].split(':')[0],        \
+#              "' but variable has not it !!!"
+#            print '  variable dims:',vardims
+            print warnmsg
+            print '  ' + fname + ": variable has dimension '",vardims[idv],          \
+              "' but is not cut taking all length !!!"
+            if Lcutdimvals > 0:
+                cutdimvals = cutdimvals + '|' + vardims[idv] + ':-1'
+            else:
+                cutdimvals = vardims[idv] + ':-1'
+#            quit(-1)
+
+    slicedvar, dimslice = slice_variable(ovar, cutdimvals)
 
 # operation
@@ -12085,4 +12103,5 @@
     dimvn = values.split(',')[3]
 
+    dimsoperS = numVector_String(dimsoper.split(':'),', ')
     objnc = NetCDFFile(ncfile, 'r')
 
@@ -12150,35 +12169,40 @@
                     objvdim = objnc.variables[vardims[ivdim]]
                     vdimtype = objvdim.dtype
-
-                    dimsvdim = objvdim.dimensions
-                    dimvslice = []
-                    dimvdims = []
-                    for idmvd in range(len(dimsvdim)):
-                        found = False
-                        for idimv in range(len(newvardimns)):
-                            if dimsvdim[idmvd] == newvardimns[idimv]:
-                                dimvslice.append(slice(0,objvdim.shape[idmvd]))
-                                dimvdims.append(dimsvdim[idmvd])
-                                found = True
-                                break
-                        if not found: 
-                            print warnmsg
-                            print '  ' + fname + ": dimension '" + dimsvdim[idmvd] + \
-                              "' not found !!"
-                            print "    adding it for variable dimension: '" +         \
-                              vardims[ivdim] + "'"
-                            if not objnewnc.dimensions.has_key(dimsvdim[idmvd]):
-                                dsize = len(objnc.dimensions[dimsvdim[idmvd]])
-                                objnewnc.createDimension(dimsvdim[idmvd], dsize)
-                            dimvslice.append(slice(len(objnc.dimensions[dimsvdim[idmvd]])))
-                            dimvdims.append(dimsvdim[idmvd])
+                    newdimvarv, newdimvardimns=operation_alongdims(objvdim,dimvals,dimsoper,operkind)
+
+# Old method introducing new dimension if needed
+##                    dimsvdim = objvdim.dimensions
+##                    dimvslice = []
+##                    dimvdims = []
+##                    for idmvd in range(len(dimsvdim)):
+##                        found = False
+##                        for idimv in range(len(newvardimns)):
+##                            if dimsvdim[idmvd] == newvardimns[idimv]:
+##                                dimvslice.append(slice(0,objvdim.shape[idmvd]))
+##                                dimvdims.append(dimsvdim[idmvd])
+##                                found = True
+##                                break
+##                        if not found: 
+##                            print warnmsg
+##                            print '  ' + fname + ": dimension '" + dimsvdim[idmvd] + \
+##                              "' not found !!"
+##                            print "    adding it for variable dimension: '" +         \
+##                              vardims[ivdim] + "'"
+##                            if not objnewnc.dimensions.has_key(dimsvdim[idmvd]):
+##                                dsize = len(objnc.dimensions[dimsvdim[idmvd]])
+##                                objnewnc.createDimension(dimsvdim[idmvd], dsize)
+##                            dimvslice.append(slice(len(objnc.dimensions[dimsvdim[idmvd]])))
+##                            dimvdims.append(dimsvdim[idmvd])
 
                     newvar = objnewnc.createVariable(vardims[ivdim], vdimtype,       \
-                      tuple(dimvdims))
-                    newvar[:] = objvdim[tuple(dimvslice)]
+                      tuple(newdimvardimns))
+                    newvar[:] = newdimvarv
                     dimvattrs = objvdim.ncattrs()
                     for attrn in dimvattrs:
                         attrv = objvdim.getncattr(attrn)
                         newattr = set_attribute(newvar,attrn,attrv)
+
+                    newattr = set_attribute(newvar, 'operation:',  operkind +        \
+                      ' along ' + dimsoperS)
 
 # new variable
@@ -12200,6 +12224,4 @@
             else:
                 uname = variables_values(vn)[5]
-
-            dimsoperS = numVector_String(dimsoper.split(':'),', ')
     
             newvar = objnewnc.createVariable(varname + operkind, 'f4', 
@@ -12505,5 +12527,4 @@
         for indima in range(Ndimvar):
             found = False
-            print '  Lluis:',fname,dimns[indimv],dimvar[indima]
             if dimns[indimv] == dimvar[indima]:
                 found = True
