Index: anuga_core/source/anuga/shallow_water/data_manager.py
===================================================================
--- anuga_core/source/anuga/shallow_water/data_manager.py	(revision 5470)
+++ anuga_core/source/anuga/shallow_water/data_manager.py	(revision 5473)
@@ -4838,6 +4838,18 @@
 NORTH_VELOCITY_MUX2_LABEL =  '-n-mux2'    
 
-def read_mux2_py(filenames,weights,verbose=False):
-
+def read_mux2_py(filenames,weights,permutation=None,verbose=False):
+    """
+    Access the mux files specified in the filenames list. Combine the
+    data found therin as a weighted linear sum as specifed by the weights.
+    If permutation is None extract timeseries data for all gauges within the
+    files.
+    
+    Input:
+    filenames:   List of filenames specifiying the file containing the
+                 timeseries data (mux2 format) for each source
+    weights:     Weights associated with each source
+    permutation: Specifies the gauge numbers that for which data is to be
+                 extracted
+    """
     from Numeric import ones,Float,compress,zeros,arange
     from urs_ext import read_mux2
@@ -4853,5 +4865,5 @@
         verbose=0
         
-    data=read_mux2(numSrc,filenames,weights,file_params,verbose)
+    data=read_mux2(numSrc,filenames,weights,file_params,permutation,verbose)
 
     msg='File parameter values were not read in correctly from c file'
@@ -5034,11 +5046,38 @@
                 raise IOError, msg
 
-    #need to do this for velocity-e-mux2 and velocity-n-mux2 files as well
-    #for now set x_momentum and y_moentum quantities to zero
+    if ordering_filename is not None:
+        # Read ordering file 
+        
+        try:
+            fid=open(ordering_filename, 'r')
+            file_header=fid.readline().split(',')
+            ordering_lines=fid.readlines()
+            fid.close()
+        except:
+            msg = 'Cannot open %s'%ordering_filename
+            raise Exception, msg
+
+        reference_header = 'index, longitude, latitude\n'
+        reference_header_split = reference_header.split(',')
+        for i in range(3):
+            if not file_header[i] == reference_header_split[i]:
+                msg = 'File must contain header: '+reference_header+'\n'
+                raise Exception, msg
+
+        if len(ordering_lines)<2:
+            msg = 'File must contain at least two points'
+            raise Exception, msg
+
+   
+        
+        permutation = [int(line.split(',')[0]) for line in ordering_lines]
+    else:
+        permutation = None  
+
     if (verbose): print 'reading mux2 file'
     mux={}
     for i,quantity in enumerate(quantities):
         # For each quantity read the associated list of source mux2 file with extenstion associated with that quantity
-        times, latitudes_urs, longitudes_urs, elevation, mux[quantity],starttime = read_mux2_py(files_in[i],weights,verbose=verbose)
+        times, latitudes_urs, longitudes_urs, elevation, mux[quantity],starttime = read_mux2_py(files_in[i],weights,permutation=permutation,verbose=verbose)
         if quantity!=quantities[0]:
             msg='%s, %s and %s have inconsitent gauge data'%(files_in[0],files_in[1],files_in[2])
@@ -5053,35 +5092,8 @@
         elevation_old=elevation
         starttime_old=starttime
-
         
     if ordering_filename is not None:
-        # Read ordering file 
-        
-        try:
-            fid=open(ordering_filename, 'r')
-            file_header=fid.readline().split(',')
-            ordering_lines=fid.readlines()
-            fid.close()
-        except:
-            msg = 'Cannot open %s'%ordering_filename
-            raise Exception, msg
-
-        reference_header = 'index, longitude, latitude\n'
-        reference_header_split = reference_header.split(',')
-        for i in range(3):
-            if not file_header[i] == reference_header_split[i]:
-                msg = 'File must contain header: '+reference_header+'\n'
-                raise Exception, msg
-
-        if len(ordering_lines)<2:
-            msg = 'File must contain at least two points'
-            raise Exception, msg
-
-   
-        
-        permutation = [int(line.split(',')[0]) for line in ordering_lines]
-   
-        latitudes = take(latitudes_urs, permutation)
-        longitudes = take(longitudes_urs, permutation)
+        latitudes = latitudes_urs
+        longitudes = longitudes_urs
         
         # Self check - can be removed to improve speed
@@ -5116,5 +5128,4 @@
         longitudes=longitudes_urs
         permutation = range(latitudes.shape[0])                
-        
 
     msg='File is empty and or clipped region not in file region'
@@ -5178,11 +5189,11 @@
     if verbose: print 'Converting quantities'
     for j in range(len(times)):
-        for i, index in enumerate(permutation):
-            w = zscale*mux['HA'][index,j] + mean_stage
-            h=w-elevation[index]
+        for i in range(number_of_points):
+            w = zscale*mux['HA'][i,j] + mean_stage
+            h=w-elevation[i]
             stage[j,i] = w
 
-            xmomentum[j,i] = mux['UA'][index,j]*h
-            ymomentum[j,i] = mux['VA'][index,j]*h
+            xmomentum[j,i] = mux['UA'][i,j]*h
+            ymomentum[j,i] = mux['VA'][i,j]*h
 
     outfile.close()
