Index: /inundation/ga/storm_surge/pyvolution/_test_sww2domain.py
===================================================================
--- /inundation/ga/storm_surge/pyvolution/_test_sww2domain.py	(revision 1132)
+++ /inundation/ga/storm_surge/pyvolution/_test_sww2domain.py	(revision 1133)
@@ -55,5 +55,6 @@
 #Evolution
 for t in domain.evolve(yieldstep = 1, finaltime = 2.0):
-    domain.write_time()
+#    domain.write_time()
+    pass
 
 
@@ -63,7 +64,7 @@
 from Numeric import allclose
 
-filename = domain.filename+'.sww'
+filename = domain.datadir+'\\'+domain.filename+'.sww'
 
-domain2 = sww2domain(filename,fail_if_NaN=False)
+domain2 = sww2domain(filename,fail_if_NaN=False,verbose = False)
 
 
@@ -74,6 +75,6 @@
 
 for bit in bits:
-    print 'testing that domain.'+bit+' has been restored'
+#    print 'testing that domain.'+bit+' has been restored'
     assert allclose(eval('domain.'+bit),eval('domain2.'+bit))
 
-print 'passed'
+#print 'passed'
Index: /inundation/ga/storm_surge/pyvolution/_test_sww2domain2.py
===================================================================
--- /inundation/ga/storm_surge/pyvolution/_test_sww2domain2.py	(revision 1132)
+++ /inundation/ga/storm_surge/pyvolution/_test_sww2domain2.py	(revision 1133)
@@ -23,4 +23,5 @@
 domain.filename = 'bedslope'
 domain.default_order=2
+domain.quantities_to_be_stored=['stage']
 
 #######################
@@ -49,10 +50,9 @@
 
 domain.check_integrity()
-dir(domain)
-
 ######################
 #Evolution
 for t in domain.evolve(yieldstep = 1, finaltime = 2.0):
-    domain.write_time()
+    pass
+    #domain.write_time()
 
 
@@ -62,11 +62,12 @@
 from Numeric import allclose
 
-filename = domain.filename+'.sww'
+filename = domain.datadir+'\\'+domain.filename+'.sww'
 
 try:
-    domain2 = sww2domain(filename)
+    domain2 = sww2domain(filename,verbose=False)
     assert True == False
 except:
-    domain2 = sww2domain(filename,fail_if_NaN=False)
+    filler = 0
+    domain2 = sww2domain(filename,fail_if_NaN=False,NaN_filler = filler,verbose=False)
 
 bits = ['xllcorner','yllcorner','vertex_coordinates','time','starttime']
@@ -76,16 +77,20 @@
 
 for bit in bits:
-    print 'testing that domain.'+bit+' has been restored'
+#    print 'testing that domain.'+bit+' has been restored'
     assert allclose(eval('domain.'+bit),eval('domain2.'+bit))
 
-print max(max(domain2.get_quantity('xmomentum')))
-print min(min(domain2.get_quantity('xmomentum')))
-print max(max(domain2.get_quantity('ymomentum')))
-print min(min(domain2.get_quantity('ymomentum')))
+#print max(max(domain2.get_quantity('xmomentum')))
+#print min(min(domain2.get_quantity('xmomentum')))
+#print max(max(domain2.get_quantity('ymomentum')))
+#print min(min(domain2.get_quantity('ymomentum')))
 
-assert max(max(domain2.get_quantity('xmomentum')))==0
-assert min(min(domain2.get_quantity('xmomentum')))==0
-assert max(max(domain2.get_quantity('ymomentum')))==0
-assert min(min(domain2.get_quantity('ymomentum')))==0
+assert max(max(domain2.get_quantity('xmomentum')))==filler
+assert min(min(domain2.get_quantity('xmomentum')))==filler
+assert max(max(domain2.get_quantity('ymomentum')))==filler
+assert min(min(domain2.get_quantity('ymomentum')))==filler
 
-print 'passed'
+#print 'passed'
+
+#cleanup
+#import os
+#os.remove(domain.datadir+'/'+domain.filename+'.sww')
Index: /inundation/ga/storm_surge/pyvolution/data_manager.py
===================================================================
--- /inundation/ga/storm_surge/pyvolution/data_manager.py	(revision 1132)
+++ /inundation/ga/storm_surge/pyvolution/data_manager.py	(revision 1133)
@@ -1623,17 +1623,18 @@
 
 
-def sww2domain(filename,t=None,fail_if_NaN=True,NaN_filler=0):
-    """Read sww Net CDF file containing Shallow Water Wave simulation
-
-    Quantities stage, elevation, xmomentum and ymomentum.
-
-    The momentum is not always stored.
-
+def sww2domain(filename,t=None,fail_if_NaN=True,NaN_filler=0,verbose = True):
+    """
+    Usage: domain = sww2domain('file.sww',t=time (default = last time in file))
+
+    If the sww has stages, but not 
     """
     NaN=9.969209968386869e+036
+    #initialise NaN.
+
     from Scientific.IO.NetCDF import NetCDFFile
     from domain import Domain
     from Numeric import asarray, transpose
-    #print 'Reading from ', filename
+
+    if verbose: print 'Reading from ', filename
     fid = NetCDFFile(filename, 'r')    #Open existing file for read
     time = fid.variables['time']       #Timesteps
@@ -1641,6 +1642,5 @@
         t = time[-1]
     time_interp = get_time_interp(time,t)
-################################
-########################################    
+
     # Get the variables as Numeric arrays
     x = fid.variables['x'][:]             #x-coordinates of vertices
@@ -1649,6 +1649,6 @@
     stage = fid.variables['stage']     #Water level
     xmomentum = fid.variables['xmomentum']   #Momentum in the x-direction
-    ymomentum = fid.variables['ymomentum']   #Momentum in the y-direction    
-#################################
+    ymomentum = fid.variables['ymomentum']   #Momentum in the y-direction
+
     xllcorner = fid.xllcorner[0]
     yllcorner = fid.yllcorner[0]
@@ -1657,10 +1657,10 @@
     volumes = fid.variables['volumes'][:] #Connectivity
     coordinates=transpose(asarray([x.tolist(),y.tolist()]))
-#
+
     conserved_quantities = []
     interpolated_quantities = {}
     other_quantities = []
-#
-    #print '    interpolating quantities'
+
+    if verbose: print '    interpolating quantities'
     for quantity in fid.variables.keys():
         dimensions = fid.variables[quantity].dimensions
@@ -1670,15 +1670,13 @@
                   interpolated_quantity(fid.variables[quantity][:],time_interp)
         else: other_quantities.append(quantity)
-#
+
     other_quantities.remove('x')
     other_quantities.remove('y')
     other_quantities.remove('z')
     other_quantities.remove('volumes')
-#
+
     conserved_quantities.remove('time')
-#
-    #print other_quantities
-    #print conserved_quantities
-    #print '    building domain'
+
+    if verbose: print '    building domain'
     domain = Domain(coordinates, volumes,\
                     conserved_quantities = conserved_quantities,\
@@ -1688,13 +1686,20 @@
     domain.time=t
     for quantity in other_quantities:
+        try:
+            NaN = fid.variables[quantity].missing_value
+        except:
+            pass #quantity has no missing_value number
         X = fid.variables[quantity][:]
-        #print quantity
-        #print 'max(X)'
-        #print max(X)
-        #print 'max(X)==NaN'
-        #print max(X)==NaN
+        if verbose:
+            print '       ',quantity
+            print '        NaN =',NaN
+            print '        max(X)'
+            print '       ',max(X)
+            print '        max(X)==NaN'
+            print '       ',max(X)==NaN
+            print ''
         if (max(X)==NaN) or (min(X)==NaN):
             if fail_if_NaN:
-                msg = 'quantity %s contains no_data entry'%quantity
+                msg = 'quantity "%s" contains no_data entry'%quantity
                 raise msg
             else:
@@ -1704,13 +1709,20 @@
 #
     for quantity in conserved_quantities:
+        try:
+            NaN = fid.variables[quantity].missing_value
+        except:
+            pass #quantity has no missing_value number
         X = interpolated_quantities[quantity]
-        #print quantity
-        #print 'max(X)'
-        #print max(X)
-        #print 'max(X)==NaN'
-        #print max(X)==NaN
+        if verbose:
+            print '       ',quantity
+            print '        NaN =',NaN
+            print '        max(X)'
+            print '       ',max(X)
+            print '        max(X)==NaN'
+            print '       ',max(X)==NaN
+            print ''
         if (max(X)==NaN) or (min(X)==NaN):
             if fail_if_NaN:
-                msg = 'quantity %s contains no_data entry'%quantity
+                msg = 'quantity "%s" contains no_data entry'%quantity
                 raise msg
             else:
@@ -1718,4 +1730,5 @@
                 X = (X*data)+(data==0)*NaN_filler
         domain.set_quantity(quantity,X)
+    fid.close()
     return domain
 
