Index: /anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py
===================================================================
--- /anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py	(revision 4935)
+++ /anuga_core/source/anuga/abstract_2d_finite_volumes/test_util.py	(revision 4936)
@@ -1627,4 +1627,120 @@
         os.remove(point2_filename)
 
+
+    def test_sww2csv_gauges2(self):
+
+        def elevation_function(x, y):
+            return -x
+        
+        """Most of this test was copied from test_interpolate test_interpole_sww2csv
+        
+        This is testing the gauge_sww2csv function, by creating a sww file and
+        then exporting the gauges and checking the results.
+        
+        This is the same as sww2csv_gauges except set domain.set_starttime to 5. Therefore
+        testing the storing of the absolute time in the csv files
+        """
+        
+        # create mesh
+        mesh_file = tempfile.mktemp(".tsh")    
+        points = [[0.0,0.0],[6.0,0.0],[6.0,6.0],[0.0,6.0]]
+        m = Mesh()
+        m.add_vertices(points)
+        m.auto_segment()
+        m.generate_mesh(verbose=False)
+        m.export_mesh_file(mesh_file)
+        
+        #Create shallow water domain
+        domain = Domain(mesh_file)
+        os.remove(mesh_file)
+        
+        domain.default_order=2
+        domain.beta_h = 0
+
+        #Set some field values
+        domain.set_quantity('elevation', elevation_function)
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('xmomentum', 3.0)
+        domain.set_quantity('ymomentum', 4.0)
+        domain.set_starttime(5)
+
+        ######################
+        # Boundary conditions
+        B = Transmissive_boundary(domain)
+        domain.set_boundary( {'exterior': B})
+
+        # This call mangles the stage values.
+        domain.distribute_to_vertices_and_edges()
+        domain.set_quantity('stage', 1.0)
+        
+
+
+        domain.set_name('datatest' + str(time.time()))
+        domain.format = 'sww'
+        domain.smooth = True
+        domain.reduction = mean
+
+        sww = get_dataobject(domain)
+        sww.store_connectivity()
+        sww.store_timestep(['stage', 'xmomentum', 'ymomentum','elevation'])
+        domain.set_quantity('stage', 10.0) # This is automatically limited
+        # so it will not be less than the elevation
+        domain.time = 2.
+        sww.store_timestep(['stage','elevation', 'xmomentum', 'ymomentum'])
+
+        # test the function
+        points = [[5.0,1.],[0.5,2.]]
+
+        points_file = tempfile.mktemp(".csv")
+#        points_file = 'test_point.csv'
+        file_id = open(points_file,"w")
+        file_id.write("name, easting, northing, elevation \n\
+point1, 5.0, 1.0, 3.0\n\
+point2, 0.5, 2.0, 9.0\n")
+        file_id.close()
+
+        
+        sww2csv_gauges(sww.filename, 
+                            points_file,
+                            verbose=False,
+                            use_cache=False)
+
+#        point1_answers_array = [[0.0,1.0,-5.0,3.0,4.0], [2.0,10.0,-5.0,3.0,4.0]]
+        point1_answers_array = [[5.0,1.0,6.0,-5.0,3.0,4.0], [7.0,10.0,15.0,-5.0,3.0,4.0]]
+        point1_filename = 'gauge_point1.csv'
+        point1_handle = file(point1_filename)
+        point1_reader = reader(point1_handle)
+        point1_reader.next()
+
+        line=[]
+        for i,row in enumerate(point1_reader):
+            #print 'i',i,'row',row
+            line.append([float(row[0]),float(row[1]),float(row[2]),float(row[3]),float(row[4]),float(row[5])])
+            #print 'assert line',line[i],'point1',point1_answers_array[i]
+            assert allclose(line[i], point1_answers_array[i])
+
+        point2_answers_array = [[5.0,1.0,1.5,-0.5,3.0,4.0], [7.0,10.0,10.5,-0.5,3.0,4.0]]
+        point2_filename = 'gauge_point2.csv' 
+        point2_handle = file(point2_filename)
+        point2_reader = reader(point2_handle)
+        point2_reader.next()
+                        
+        line=[]
+        for i,row in enumerate(point2_reader):
+            #print 'i',i,'row',row
+            line.append([float(row[0]),float(row[1]),float(row[2]),float(row[3]),float(row[4]),float(row[5])])
+            #print 'assert line',line[i],'point1',point1_answers_array[i]
+            assert allclose(line[i], point2_answers_array[i])
+                         
+        # clean up
+        point1_handle.close()
+        point2_handle.close()
+        #print "sww.filename",sww.filename 
+        os.remove(sww.filename)
+        os.remove(points_file)
+        os.remove(point1_filename)
+        os.remove(point2_filename)
+
+
     def test_greens_law(self):
 
Index: /anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
===================================================================
--- /anuga_core/source/anuga/abstract_2d_finite_volumes/util.py	(revision 4935)
+++ /anuga_core/source/anuga/abstract_2d_finite_volumes/util.py	(revision 4936)
@@ -9,5 +9,5 @@
 import os
 
-from os import remove, mkdir, access, F_OK, R_OK, W_OK, sep,mkdir
+from os import remove, mkdir, access, F_OK, R_OK, W_OK, sep,getcwd
 from os.path import exists, basename, split,join
 from warnings import warn
@@ -2201,8 +2201,8 @@
             attribute_dic, title_index_dic = csv2dict(dir_filename+
                                                        '.csv')
-
             directory_start_time = directories_dic[directory][1]
             directory_add_tide = directories_dic[directory][2]
 
+            if verbose: print 'reading: %s.csv' %dir_filename
 #            print 'keys',attribute_dic.keys()
             #add time to get values
@@ -2260,5 +2260,5 @@
                                quantities_axis[quantity][3],
                                quantities_label[quantity])
-        print  quantities_axis[quantity]
+        #print  quantities_axis[quantity]
 
     cstr = ['b', 'r', 'g', 'c', 'm', 'y', 'k']
@@ -2537,5 +2537,10 @@
 
     dir_name, base = os.path.split(sww_file)    
-#    print 'dirname',dir_name, base
+    #print 'dirname',dir_name, base
+    #need to get current directory so when path and file
+    #are "joined" below the directory is correct
+    if dir_name == '':
+        dir_name =getcwd()
+        
     if access(sww_file,R_OK):
         if verbose: print 'File %s exists' %(sww_file)
@@ -2574,26 +2579,28 @@
     heading.insert(0,'time')
 
-#    print heading, quantities
+#    print 'start time', callable_sww.starttime, heading, quantities
 
     #create a list of csv writers for all the points and write header
     points_writer = []
     for i,point in enumerate(points):
+        #print 'gauge file:',dir_name+sep+'gauge_'+point_name[i]+'.csv'
         points_writer.append(writer(file(dir_name+sep+'gauge_'+point_name[i]+'.csv', "wb")))
         points_writer[i].writerow(heading)
 
+    
+    if verbose: print 'Writing csv files'
+
     for time in callable_sww.get_time():
-       # points_list = []
 
         for point_i, point in enumerate(points_array):
-            points_list = [time]
+            #add domain starttime to relative time.
+            points_list = [time+callable_sww.starttime]
 #            print'time',time,'point_i',point_i,point, points_array
             point_quantities = callable_sww(time,point_i)
 #            print "quantities", point_quantities
             
-#            for i, quantity in enumerate(quantities):
-#                points_list.append(quantities)
             for quantity in quantities:
                 if quantity==NAN:
-                    if verbose: print 'quantity does not exist in' %callable_sww.get_name
+                    print 'quantity does not exist in' %callable_sww.get_name
                 else:
                     if quantity == 'stage':
