Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 916)
+++ trunk/tools/nc_var_tools.py	(revision 917)
@@ -8795,4 +8795,5 @@
     """ 
     fname = 'operdim'
+    readyop = ['max', 'mean', 'mean2', 'min', 'std', 'sum']
 
     operslice = []
@@ -8813,7 +8814,10 @@
                 varoper = np.mean(varoper, axis=idim-noper)
             elif oper == 'mean2':
-                varoper = np.mean(varoper, axis=idim-noper)
+                varoper1 = np.mean(varoper, axis=idim-noper)
+                varoper = varoper1*varoper1
             elif oper == 'min':
                 varoper = np.min(varoper, axis=idim-noper)
+            elif oper == 'std':
+                varoper = np.std(varoper, axis=idim-noper)
             elif oper == 'sum':
                 varoper = np.sum(varoper, axis=idim-noper)
@@ -8821,4 +8825,5 @@
                 print errormsg
                 print '  ' + fname + ': operation "' + oper + '" not ready!!'
+                print '    operations available:', readyop
                 quit(-1)
             noper = noper + 1
@@ -8917,4 +8922,6 @@
                 elif opkind == 'sum':
                     varoper = np.sum(origvar, axis=ids-noper)
+                elif opkind == 'std':
+                    varoper = np.std(origvar, axis=ids-noper)
                 else:
                     print errormsg
@@ -8990,5 +8997,5 @@
 # Operations with which when the variable dimensions will be ajusted to the file
 #   the zero value along the operated dimensions will be taken
-    zerodimops = ['max', 'mean', 'mean2', 'min', 'sum']
+    zerodimops = ['max', 'mean', 'mean2', 'min', 'sum', 'std']
 
     dimsoperS = gen.numVector_String(dimsoper,', ')
@@ -9024,5 +9031,5 @@
     dimfinalfile = []
 
-    print '  ' + fname + ": '" + operkind + "' with:",dimsoper,'_______'
+    print '  ' + fname + ": '" + operkind + "' with:", dimsoper, '_______'
     newNdim = 0
     newNvar = 0
@@ -9082,4 +9089,5 @@
                   tuple(finaldims))
                 newNvar = newNvar + 1
+            print fname + ': Lluis; shapes:', newvar.shape,' finalvarvals:', finalvarvals.shape
             newvar[:] = finalvarvals[:]
 
@@ -9128,5 +9136,5 @@
     
     # Statistics of the variable dimension along the dimensions operated
-    basicoper = ['min', 'max', 'menan', 'mean2', 'sum']
+    basicoper = ['min', 'max', 'mean', 'mean2', 'sum', 'std']
 
 # operating variable dimension
@@ -9225,18 +9233,44 @@
             objnewnc.sync()
 
+# Statistics of the variable dimension along the dimensions operated in case 
+#   dimension after operation disapears
+    print '  ' + fname + ': Statisitcs of operated variable dimension _______'
+    for vn in dimvn:
+        print "' " + vn + "' ... .. ."
+        if not objnc.variables.has_key(vn):
+            print warnmsg
+            print '  ' + fname + ': netCDF file "' + ncfile +                        \
+              '" does not have variable "' + vn + '" skipping it !!'
+            continue
+        varslice, varsliceddims = SliceVarDict(ov,dimslice)
+        varvals0 = ov[tuple(varslice)]
+        varvals = np.squeeze(varvals0)
+
+        varname = gen.variables_values(vn)[0]
+        if gen.searchInlist(oldvarattr, 'standard_name'):
+            stdname = ov.getncattr('standard_name')
+        else:
+            stdname = gen.variables_values(vn)[1]
+        
+        if gen.searchInlist(oldvarattr, 'long_name'):
+            lname = ov.getncattr('long_name')
+        else:
+            lname = gen.variables_values(vn)[4].replace('|',' ')
+
+        if gen.searchInlist(oldvarattr, 'units'):
+            uname = ov.getncattr('units')
+        else:
+            uname = gen.variables_values(vn)[5]
+
+        if len(varvals.shape) == 1:
             # Statistics of the variable dimension along the dimensions operated
+            newvar = objnewnc.createVariable(vn+'stats', 'f4' )
+            newattr = basicvardef(newvar, stdname + 'statistics', lname +            \
+              ' statistics', uname)
+
+            newattr = set_attributek(newvar, 'Nvalues', len(varvals), 'I')
             for op in basicoper:
-                if op != operkind:
-                    finalvarv, finalds = operdim(varvals,varsliceddims,dimsoper,op)
-                    if varinf.FillValue is not None:
-                        newvar = objnewnc.createVariable(vn+op, nctype(varinf.dtype),\
-                          tuple(finalds), fillValue=varinf.FillValue)
-                    else:
-                        newvar = objnewnc.createVariable(vn+op, nctype(varinf.dtype),\
-                          tuple(finalds))
-                    newNvar = newNvar + 1
-                    newvar[:] = finalvarv[:]
-                    newattr = basicvardef(newvar, stdname + op, lname + ' '+ op +    \
-                      ' along ' + dimsoperS, uname)
+                finalvarv, finalds = operdim(varvals,varsliceddims,dimsoper,op)
+                newattr = set_attributek(newvar, op, finalvarv, 'R')
             objnewnc.sync()
 
