Index: /inundation/damage/inundation_damage.py
===================================================================
--- /inundation/damage/inundation_damage.py	(revision 3349)
+++ /inundation/damage/inundation_damage.py	(revision 3350)
@@ -37,4 +37,5 @@
 def inundation_damage(sww_file, exposure_file_in,
                       exposure_file_out=None,
+                      ground_floor_height=0.3,
                       overwrite=False, verbose=True,
                                  use_cache = True):
@@ -51,7 +52,8 @@
     geospatial = csv.get_location()
     max_depths, max_momentums = calc_max_depth_and_momentum(sww_file,
-                                                          geospatial,
-                                                          verbose=verbose,
-                                                          use_cache=use_cache)
+                                    geospatial,
+                                    ground_floor_height=ground_floor_height,
+                                    verbose=verbose,
+                                    use_cache=use_cache)
     edm = EventDamageModel(max_depths,
                            csv.get_column('SHORE_DIST'),
@@ -62,5 +64,5 @@
     results_dic = edm.calc_damage_and_costs(verbose_csv=True)
     for title, value in results_dic.iteritems():
-        csv.set_column(title, value)
+        csv.set_column(title, value, overwrite=overwrite)
     
     # Save info back to csv file
@@ -139,4 +141,5 @@
     STRUCT_DAMAGE_TITLE = "Structure damaged (fraction)"
     COLLAPSE_CSV_INFO_TITLE = "Calculation notes"
+    MAX_DEPTH_TITLE = "Inundation height above ground floor (m)"
     double_brick_damage_array = array([[-kinds.default_float_kind.MAX, 0.0],
                                        [0.0-depth_epsilon, 0.0],
@@ -201,4 +204,8 @@
     def __init__(self,max_depths, shore_distances, walls,
                  struct_costs, content_costs):
+        """
+        max depth is Inundation height above ground floor (m), so
+                  the ground floor has been taken into account.
+        """
         self.max_depths = [float(x) for x in max_depths]
         self.shore_distances = [float(x) for x in shore_distances]
@@ -225,5 +232,5 @@
                         ,self.CONTENTS_LOSS_TITLE:self.contents_loss
                         ,self.CONTENTS_DAMAGE_TITLE:self.contents_damage
-                        #,self.:self.
+                        ,self.MAX_DEPTH_TITLE:self.max_depths
                         #,self.:self.
                         #,self.:self.
Index: /inundation/damage/test_inundation_damage.py
===================================================================
--- /inundation/damage/test_inundation_damage.py	(revision 3349)
+++ /inundation/damage/test_inundation_damage.py	(revision 3350)
@@ -18,5 +18,9 @@
 
 from Numeric import zeros, Float, allclose
-        
+
+
+def elevation_function(x, y):
+    return -x
+
 class Test_inundation_damage(unittest.TestCase):
     def setUp(self):
@@ -49,7 +53,7 @@
         points_ab = spat.get_data_points( absolute = True)
 
-        #FIXME - put this back when it is working
-        #geo =  Geo_reference(56,400000,6000000)
-        #spat.set_geo_reference(geo)
+        
+        geo =  Geo_reference(56,400000,6000000)
+        spat.set_geo_reference(geo)
 
         m = Mesh()
@@ -148,5 +152,61 @@
         #print "sww_file",sww_file 
         inundation_damage(sww_file, self.csv_file, verbose=False)
-        
+
+    
+    def ztest_inundation_damage2(self):
+
+        # 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.autoSegment()
+        m.generate_mesh(verbose=True) #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('stage', 0.3)
+        domain.set_quantity('elevation', elevation_function)
+        domain.set_quantity('friction', 0.03)
+        domain.set_quantity('xmomentum', 22.0)
+        domain.set_quantity('ymomentum', 55.0)
+
+        ######################
+        # Boundary conditions
+        B = Transmissive_boundary(domain)
+        domain.set_boundary( {'exterior': B})
+        domain.distribute_to_vertices_and_edges()
+
+        #sww_file = tempfile.mktemp("")
+        domain.filename = 'datatest' + str(time.time())
+        #domain.filename = sww_file
+        #print "domain.filename",domain.filename 
+        domain.format = 'sww'
+        domain.smooth = True
+        domain.reduction = mean
+
+        sww = get_dataobject(domain)
+        sww.store_connectivity()
+        sww.store_timestep(['stage', 'xmomentum', 'ymomentum'])
+        domain.time = 2.
+        sww.store_timestep(['stage', 'xmomentum', 'ymomentum'])
+        sww = sww # so it can be deleted
+        
+        #Create a csv file
+        csv_file = tempfile.mktemp(".csv")
+        fd = open(csv_file,'wb')
+        writer = csv.writer(fd)
+        writer.writerow(['LONGITUDE','LATITUDE','STR_VALUE','C_VALUE','ROOF_TYPE','WALLS', 'SHORE_DIST'])
+        writer.writerow(['151.5','-34','199770','130000','Metal','Timber',20])
+        writer.writerow(['151','-34.5','150000','76000','Metal','Double Brick',200])
+        writer.writerow(['151','-34.25','150000','76000','Metal','Brick Veneer',200])
+
     def ztest_add_depth_and_momentum2csv(self):
         sww_file = self.domain.filename + "." + self.domain.format
