Index: trunk/tools/nc_var_tools.py
===================================================================
--- trunk/tools/nc_var_tools.py	(revision 289)
+++ trunk/tools/nc_var_tools.py	(revision 290)
@@ -10259,5 +10259,5 @@
     check_arguments(fname,len(arguments.split(',')),arguments,',',8)
 
-    ofile = 'tevolboxtraj_' + varn + '.nc'
+    ofile = 'tevolboxtraj_' + varn.replace(',','-') + '.nc'
 
     trajfile = values.split(',')[0].split('@')[0]
@@ -10325,9 +10325,4 @@
     timv = timobj[:]
 
-    if not searchInlist(objfile.variables, varn):
-        print errormsg
-        print '  ' + fname + ": variable name '" + varn + "' is not in file " +     \
-          ncfile + '" !!!!!'
-        quit(-1)
 
 # Selecting accordingly a trajectory
@@ -10522,7 +10517,12 @@
 ##
     ivar = 0
-    print 'Lluis varns:',varns
 
     for vn in varns:
+        if not searchInlist(objfile.variables, vn):
+            print errormsg
+            print '  ' + fname + ": variable name '" + vn + "' is not in file " +    \
+              ncfile + '" !!!!!'
+            quit(-1)
+
         varobj = objfile.variables[vn]
         Nvardims = len(varobj.shape)
@@ -10556,13 +10556,13 @@
                     vsname = varzobj.getncattr('standard_name')
                 else:
-                    vsname = variables_values(varn)[1]
+                    vsname = variables_values(zn)[1]
                 if searchInlist(varzobj.ncattrs(),'long_name'):
                     vlname = varzobj.getncattr('long_name')
                 else:
-                    vlname = variables_values(varn)[4].replace('|',' ')
+                    vlname = variables_values(zn)[4].replace('|',' ')
                 if searchInlist(varzobj.ncattrs(),'units'):
                     vunits = varzobj.getncattr('units')
                 else:
-                    vunits = variables_values(varn)[5].replace('|',' ')
+                    vunits = variables_values(zn)[5].replace('|',' ')
     
                 newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -10697,5 +10697,5 @@
                     maskedvals2 = maskedvals*maskedvals
                     for iz in range(dimz):
-                        rtatvarvals[it,:,0] = varvalst[:,box2,box2]
+                        rtatvarvals[it,iz,0] = varvalst[iz,box2,box2]
                         rtatvarvals[it,iz,1] = np.min(varvalst[iz,:,:])
                         rtatvarvals[it,iz,2] = np.max(varvalst[iz,:,:])
@@ -10727,5 +10727,4 @@
 
                     rvarvalst = varobj[tuple(cslicev)]
-                    cdist = circdist[tuple([it] + cslicevnoThor)]
 # circle values
                     for iz in range(dimz):
@@ -10741,7 +10740,7 @@
                     for iz in range(dimz):
                         rstatvarvals[it,iz,0] = rvarvalst[iz,Nrad,Nrad]
-                        rstatvarvals[it,iz,1] = maskedvals.min()
-                        rstatvarvals[it,iz,2] = maskedvals.max()
-                        rstatvarvals[it,iz,3] = maskedvals.mean()
+                        rstatvarvals[it,iz,1] = maskedvals[iz,:,:].min()
+                        rstatvarvals[it,iz,2] = maskedvals[iz,:,:].max()
+                        rstatvarvals[it,iz,3] = maskedvals[iz,:,:].mean()
                         rstatvarvals[it,iz,4] = maskedvals2[iz,:,:].mean()
                         rstatvarvals[it,iz,5] = np.sqrt(rstatvarvals[it,iz,4] -      \
@@ -10751,18 +10750,18 @@
 
 # variable box values
-            newvar = objofile.createVariable(varn + 'box', 'f4', ('time','z','y','x'),\
+            newvar = objofile.createVariable(vn + 'box', 'f4', ('time','z','y','x'),\
               fill_value=fillValue)
             if searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(varn)[1]
+                vsname = variables_values(vn)[1]
             if searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(varn)[4].replace('|',' ')
+                vlname = variables_values(vn)[4].replace('|',' ')
             if searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(varn)[5].replace('|',' ')
+                vunits = variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -10771,8 +10770,8 @@
 
 # center of the trajectory
-            newvar = objofile.createVariable('trj_' + varn, 'f', ('time','z'),       \
+            newvar = objofile.createVariable('trj_' + vn, 'f', ('time','z'),       \
               fill_value=fillValue)
             newattr = basicvardef(newvar, 'trj_' + vsname, 'value along the ' +      \
-              'trajectory of '+ varn, vunits)
+              'trajectory of '+ vn, vunits)
             newvar[:] = statvarvals[:,:,0]
 
@@ -10780,8 +10779,8 @@
             ist = 0
             for statn in statnames:
-                newvar = objofile.createVariable(statn + '_' + varn,'f',('time','z'),\
+                newvar = objofile.createVariable(statn + '_' + vn,'f',('time','z'),  \
                   fill_value=fillValue)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
-                  ' the box ('+str(boxs)+'x'+str(boxs)+') of ' + varn, vunits)
+                  ' the box ('+str(boxs)+'x'+str(boxs)+') of ' + vn, vunits)
                 newvar[:] = statvarvals[:,:,ist+1]
 #                newattr = set_attributek(newvar,'_FillValue',fillValue,'npfloat')
@@ -10789,18 +10788,18 @@
         
 # variable circle values
-            newvar = objofile.createVariable(varn + 'circle','f4',('time','z','yr',  \
+            newvar = objofile.createVariable(vn + 'circle','f4',('time','z','yr',    \
               'xr'), fill_value=fillValue)
             if searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(varn)[1]
+                vsname = variables_values(vn)[1]
             if searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(varn)[4].replace('|',' ')
+                vlname = variables_values(vn)[4].replace('|',' ')
             if searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(varn)[5].replace('|',' ')
+                vunits = variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -10811,8 +10810,8 @@
             ist = 0
             for statn in cstatnames:
-                newvar = objofile.createVariable(statn + '_' + varn,'f',('time','z'),\
+                newvar = objofile.createVariable(statn + '_' + vn,'f',('time','z'),\
                   fill_value=fillValue)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
-                  ' the circle of radius ('+ str(circler)+') of ' + varn, vunits)
+                  ' the circle of radius ('+ str(circler)+') of ' + vn, vunits)
                 newvar[:] = rstatvarvals[:,:,ist+1]
 #                newattr = set_attributek(newvar,'_FillValue',fillValue,'npfloat')
@@ -10973,18 +10972,18 @@
 
 # variable box values
-            newvar = objofile.createVariable(varn + 'box', 'f4', ('time', 'y', 'x'), \
+            newvar = objofile.createVariable(vn + 'box', 'f4', ('time', 'y', 'x'), \
               fill_value=fillValue)
             if searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(varn)[1]
+                vsname = variables_values(vn)[1]
             if searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(varn)[4].replace('|',' ')
+                vlname = variables_values(vn)[4].replace('|',' ')
             if searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(varn)[5].replace('|',' ')
+                vunits = variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -10993,8 +10992,8 @@
 
 # center of the trajectory
-            newvar = objofile.createVariable('trj_' + varn, 'f', ('time'),           \
+            newvar = objofile.createVariable('trj_' + vn, 'f', ('time'),           \
               fill_value=fillValue)
             newattr = basicvardef(newvar, 'trj_' + vsname, 'value along the ' +      \
-              'trajectory of '+ varn, vunits)
+              'trajectory of '+ vn, vunits)
             newvar[:] = statvarvals[:,0]
 
@@ -11002,8 +11001,8 @@
             ist = 0
             for statn in statnames:
-                newvar = objofile.createVariable(statn + '_' + varn, 'f', ('time'),  \
+                newvar = objofile.createVariable(statn + '_' + vn, 'f', ('time'),    \
                   fill_value=fillValue)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
-                  ' the box ('+str(boxs)+'x'+str(boxs)+') of ' + varn, vunits)
+                  ' the box ('+str(boxs)+'x'+str(boxs)+') of ' + vn, vunits)
                 newvar[:] = statvarvals[:,ist+1]
 #                newattr = set_attributek(newvar,'_FillValue',fillValue,'npfloat')
@@ -11011,18 +11010,18 @@
         
 # variable circle values
-            newvar = objofile.createVariable(varn + 'circle','f4',('time','yr','xr'),\
+            newvar = objofile.createVariable(vn + 'circle','f4',('time','yr','xr'),\
               fill_value=fillValue)
             if searchInlist(varobj.ncattrs(),'standard_name'):
                 vsname = varobj.getncattr('standard_name')
             else:
-                vsname = variables_values(varn)[1]
+                vsname = variables_values(vn)[1]
             if searchInlist(varobj.ncattrs(),'long_name'):
                 vlname = varobj.getncattr('long_name')
             else:
-                vlname = variables_values(varn)[4].replace('|',' ')
+                vlname = variables_values(vn)[4].replace('|',' ')
             if searchInlist(varobj.ncattrs(),'units'):
                 vunits = varobj.getncattr('units')
             else:
-                vunits = variables_values(varn)[5].replace('|',' ')
+                vunits = variables_values(vn)[5].replace('|',' ')
 
             newattr = basicvardef(newvar, vsname, vlname, vunits)
@@ -11033,8 +11032,8 @@
             ist = 0
             for statn in cstatnames:
-                newvar = objofile.createVariable(statn + '_' + varn, 'f', ('time'),  \
+                newvar = objofile.createVariable(statn + '_' + vn, 'f', ('time'),  \
                   fill_value=fillValue)
                 newattr = basicvardef(newvar, statn + '_' + vsname, vstlname[ist] +  \
-                  ' the circle of radius ('+ str(circler)+') of ' + varn, vunits)
+                  ' the circle of radius ('+ str(circler)+') of ' + vn, vunits)
                 newvar[:] = rstatvarvals[:,ist+1]
 #                newattr = set_attributek(newvar,'_FillValue',fillValue,'npfloat')
