Index: /trunk/tools/nc_var_tools.py
===================================================================
--- /trunk/tools/nc_var_tools.py	(revision 280)
+++ /trunk/tools/nc_var_tools.py	(revision 281)
@@ -10311,5 +10311,5 @@
             varns = objfile.variables
         else:
-            varns = varn
+            varns = [varn]
 
     if len(lonobj.shape) == 3:
@@ -10453,5 +10453,4 @@
 
 # circle values
-            cslicev.append(gtrajvals[it,0])
             circdist = radius_dist(dimy, dimx, gtrajvals[it,2], gtrajvals[it,1])
 
@@ -10497,13 +10496,7 @@
                 cxrangeslice2D.append([gtrajvals[it,1]-Nrad, gtrajvals[it,1]+Nrad + 1])
 
-
         iline = iline + 1
 
     trajobj.close()
-
-    print 'Lluis _________'
-    print yrangeslice
-
-    quit()
 
 # Creation of the netCDF file
@@ -10526,7 +10519,11 @@
 ##
     ivar = 0
+    print 'Lluis varns:',varns
+
     for vn in varns:
         varobj = objfile.variables[vn]
         Nvardims = len(varobj.shape)
+
+        print '  ' + fname + ": getting '" + vn + "' ... .. ." 
 
         slicev = []
@@ -10575,24 +10572,23 @@
 
             for it in range(dimt):
-# box values
-                print it,'/',dimt, yrangeslice
-                quit()
-                slicev.append(slice(0,dimz))
-                slicev.append(slice(yrangeslice[it]))
-                slicev.append(slice(xrangeslice[it]))
-
-                slicevnoT.append(slice(0,dimz))
-                slicevnoT.append(slice(yrangeslice[it]))
-                slicevnoT.append(slice(xrangeslice[it]))
-
-                slice2D.append(slice(0,dimz))
-                slice2D.append(slice(yrangeslice2D[it]))
-                slice2D.append(slice(xrangeslice2D[it]))
 
                 if gtrajvals[it,2]-box2 < 0 or gtrajvals[it,2]+box2 + 1 > dimy + 1   \
                   or gtrajvals[it,1]-box2 < 0 or gtrajvals[it,1]+box2 + 1 > dimx + 1:
 
-                    rvarvalst = np.ones((dimz,Nrad*2+1,Nrad*2+1),dtype=np.float)*    \
+                    varvalst = np.ones((dimz,Nrad*2+1,Nrad*2+1),dtype=np.float)*    \
                       fillValue
+
+# box values
+                    slicev.append(slice(0,dimz))
+                    slicev.append(slice(yrangeslice[it]))
+                    slicev.append(slice(xrangeslice[it]))
+
+                    slicevnoT.append(slice(0,dimz))
+                    slicevnoT.append(slice(yrangeslice[it]))
+                    slicevnoT.append(slice(xrangeslice[it]))
+
+                    slice2D.append(slice(0,dimz))
+                    slice2D.append(slice(yrangeslice2D[it]))
+                    slice2D.append(slice(xrangeslice2D[it]))
 
                     varvalst[tuple(slice2D)] = varobj[tuple(slicev)]
@@ -10622,5 +10618,5 @@
                     slice2D.append(slice(gtrajvals[it,1]-box2, gtrajvals[it,1]+box2 +\
                       1))
-
+                    print 'Lluis',it,'shapes varvalst:',varvals.shape,'varobj:',slicev
                     varvalst = varobj[tuple(slicev)]
 # box values
@@ -10788,19 +10784,29 @@
 
             for it in range(dimt):
-# box values
-                slicev.append(slice(yrangeslice[it]))
-                slicev.append(slice(xrangeslice[it]))
-
-                slicevnoT.append(slice(yrangeslice[it]))
-                slicevnoT.append(slice(xrangeslice[it]))
-
-                slice2D.append(slice(yrangeslice2D[it]))
-                slice2D.append(slice(xrangeslice2D[it]))
-
+                slicev = []
+                slice2D = []
+                slicevnoT = []
+                cslicev = []
+                cslice2D = []
+                cslicevnoT = []
+
+                slicev.append(gtrajvals[it,0])
                 if gtrajvals[it,2]-box2 < 0 or gtrajvals[it,2]+box2 + 1 > dimy + 1   \
                   or gtrajvals[it,1]-box2 < 0 or gtrajvals[it,1]+box2 + 1 > dimx + 1:
+# box values
+                    slicev.append(slice(yrangeslice[0][it],yrangeslice[1][it]))
+                    slicev.append(slice(xrangeslice[0][it],xrangeslice[1][it]))
+
+                    slicevnoT.append(slice(yrangeslice[0][it],yrangeslice[1][it]))
+                    slicevnoT.append(slice(xrangeslice[0][it],xrangeslice[1][it]))
+
+                    slice2D.append(slice(yrangeslice2D[0][it],yrangeslice2D[1][it]))
+                    slice2D.append(slice(xrangeslice2D[0][it],xrangeslice2D[1][it]))
 
                     rvarvalst = np.ones((Nrad*2+1, Nrad*2+1),dtype=np.float)*fillValue
 
+                    print it,'Lluis: shapes yrangeslice2D:',yrangeslice2D[it],'xrangeslice:',xrangeslice[it]
+                    print it,'Lluis: shapes slice2D:',slice2D,'slicev:',slicev
+                    print it,'Lluis: shapes varvalst:',varvalst.shape,'varobj:',varobj.shape
                     varvalst[tuple(slice2D)] = varobj[tuple(slicev)]
                     varvals[it,:,:] = varvalst
@@ -10835,4 +10841,5 @@
                       1))
 
+                    print 'Lluis: shapes obj:',varobj.shape,'slice:',slicev
                     varvalst = varobj[tuple(slicev)]
 # box values
@@ -10857,14 +10864,15 @@
 
 # Circle values
-                cslicev.append(slice(cyrangeslice[it]))
-                cslicev.append(slice(cxrangeslice[it]))
-
-                cslicevnoT.append(slice(cyrangeslice[it]))
-                cslicevnoT.append(slice(cxrangeslice[it]))
-
-                cslice2D.append(slice(cyrangeslice2D[it]))
-                cslice2D.append(slice(cxrangeslice2D[it]))
+                cslicev.append(gtrajvals[it,0])
                 if gtrajvals[it,2]-Nrad < 0 or gtrajvals[it,2]+Nrad + 1 > dimy + 1   \
                   or gtrajvals[it,1]-Nrad < 0 or gtrajvals[it,1]+Nrad + 1 > dimx + 1:
+                    cslicev.append(slice(cyrangeslice[it]))
+                    cslicev.append(slice(cxrangeslice[it]))
+
+                    cslicevnoT.append(slice(cyrangeslice[it]))
+                    cslicevnoT.append(slice(cxrangeslice[it]))
+
+                    cslice2D.append(slice(cyrangeslice2D[it]))
+                    cslice2D.append(slice(cxrangeslice2D[it]))
 
                     rvarvalst = np.ones((Nrad*2+1,Nrad*2+1),dtype=np.float)*fillValue
@@ -10887,13 +10895,13 @@
 
                 else:
-                    slicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1))
-                    slicev.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1))
-                    slicevnoT.append(slice(gtrajvals[it,2]-Nrad, gtrajvals[it,2]+    \
+                    cslicev.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1))
+                    cslicev.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1))
+                    cslicevnoT.append(slice(gtrajvals[it,2]-Nrad, gtrajvals[it,2]+    \
                       Nrad+1))
-                    slicevnoT.append(slice(gtrajvals[it,1]-Nrad, gtrajvals[it,1]+    \
+                    cslicevnoT.append(slice(gtrajvals[it,1]-Nrad, gtrajvals[it,1]+    \
                       Nrad+1))
 
-                    slice2D.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1))
-                    slice2D.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1))
+                    cslice2D.append(slice(gtrajvals[it,2]-Nrad,gtrajvals[it,2]+Nrad+1))
+                    cslice2D.append(slice(gtrajvals[it,1]-Nrad,gtrajvals[it,1]+Nrad+1))
 
                     rvarvalst = varobj[tuple(cslicev)]
@@ -10902,4 +10910,6 @@
                     rvarvalst = np.where(cdist > np.float(Nrad),fillValue,rvarvalst)
 
+
+                    print 'Lluis shapes: rvarvals:',rvarvals[it,:,:].shape,'rvarvalst:',rvarvalst.shape
                     rvarvals[it,:,:] = rvarvalst
 
@@ -11044,6 +11054,6 @@
 #  'control/wss.nc', 'wss')
 # in camelot, /bdd/PCER/workspace/lfita/etudes/FF/50sims
-compute_tevolboxtraj('001/trajectory.dat@0,XLONG,XLAT,ZNU,Times,wrf,3,3',       \
-  '001/full_concatenated.nc', 'PSFC')
+#compute_tevolboxtraj('001/trajectory.dat@0,XLONG,XLAT,ZNU,Times,wrf,3,3',       \
+#  '001/full_concatenated.nc', 'PSFC')
 
 def numVector_String(vec,char):
