Index: /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/gems_comparison/project_GEMS.py
===================================================================
--- /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/gems_comparison/project_GEMS.py	(revision 7679)
+++ /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/gems_comparison/project_GEMS.py	(revision 7680)
@@ -99,22 +99,22 @@
 # Format for points easting,northing (no header)                    
 interior_regions_data = [['intermediate.csv', 2500],
-						['area_of_interest.csv', 100],
-                        ['canals_nth_2.csv', 100],  # Canal regions used to force mesh to fit canals
-                        ['canals_nth_3.csv', 100],   
-                        ['canals_nth_4.csv', 100], 
-                        ['canals_nth_5.csv', 100],
-                        ['canals_nth_6.csv', 100], 
-                        ['canals_nth_7.csv', 100],
-                        ['canals_nth_8.csv', 100], 
-                        ['canals_nth_9.csv', 100],
-                        ['canals_nth_10.csv', 100], 
-                        ['canals_nth_11.csv', 100],
-                        ['canals_nth_12.csv', 100], 
-                        ['canals_sth_1.csv', 100],
-                        ['canals_sth_2.csv', 100], 
-                        ['canals_sth_3.csv', 100],
-                        ['canals_sth_4.csv', 100], 
-                        ['canals_sth_5.csv', 100],
-                        ['canals_sth_6.csv', 100]]
+						['area_of_interest.csv', 200],
+                        ['canals_nth_2.csv', 200],  # Canal regions used to force mesh to fit canals
+                        ['canals_nth_3.csv', 200],   
+                        ['canals_nth_4.csv', 200], 
+                        ['canals_nth_5.csv', 200],
+                        ['canals_nth_6.csv', 200], 
+                        ['canals_nth_7.csv', 200],
+                        ['canals_nth_8.csv', 200], 
+                        ['canals_nth_9.csv', 200],
+                        ['canals_nth_10.csv', 200], 
+                        ['canals_nth_11.csv', 200],
+                        ['canals_nth_12.csv', 200], 
+                        ['canals_sth_1.csv', 200],
+                        ['canals_sth_2.csv', 200], 
+                        ['canals_sth_3.csv', 200],
+                        ['canals_sth_4.csv', 200], 
+                        ['canals_sth_5.csv', 200],
+                        ['canals_sth_6.csv', 200]]
                         
 # LAND - used to set the initial stage/water to be offcoast only
Index: /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/process_gems_grids.py
===================================================================
--- /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/process_gems_grids.py	(revision 7679)
+++ /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/process_gems_grids.py	(revision 7680)
@@ -22,5 +22,7 @@
 state = 'western_australia'
 scenario_folder = 'mandurah_storm_surge_scenario_2009'
-event = 'Man_1_TCAlby'
+event = 'Man1_TC_Alby'
+
+print "Processing event: ", event
 
 ENV_INUNDATIONHOME = 'INUNDATIONHOME'
@@ -37,14 +39,17 @@
 #-----------------------
 elevation_file_name = os.path.join(event_folder, 'topog_flip.asc')  # Name of the vertically flipped elevation grid
+
+print "Elevation file name: ", elevation_file_name
+
 grid_file_names = glob.glob(os.path.join(event_folder, '*.gz'))
 grid_file_names.sort()
 number_of_timesteps = len(grid_file_names)
-grid_size = 0.0005  # cellsize from the GEMSURGE output grids
+grid_size = 20  # cellsize from the GEMSURGE output grids
 start_time = 0      # all times in seconds
-end_time = 88200    # all times in seconds
-timestep = 1800     # all times in seconds
+end_time = 61200    # end_time = start_time + timestep*number of grid_file_names. all times in seconds
+timestep = 720     # all times in seconds
 refzone = 50        # UTM zone of model
-x_origin = 115.550 #364221.03   # xllcorner from GEMSURGE output grids
-y_origin = -32.790 #6371062.71  # yllcorner from GEMSURGE output grids
+x_origin = 368600 #364221.03   # xllcorner from GEMSURGE output grids
+y_origin = 6304600 #6371062.71  # yllcorner from GEMSURGE output grids
 event_sts = os.path.join(event_folder, event)
 
@@ -120,4 +125,5 @@
 assert stage.size == number_of_timesteps * elevation.size
 
+d = numpy.empty(elevation.size, dtype='d')
 depth = numpy.empty(stage.size, dtype='d')
 number_of_points = ncols * nrows
@@ -126,6 +132,12 @@
     j = number_of_points * i
     k = j + number_of_points
-    depth[j:k] = stage[j:k] - elevation     # Check GEMS elevations below sea level are negative
-
+    d = stage[j:k] - elevation     # Check GEMS elevations below sea level are negative
+    depth[j:k] = [0 if x<-9900 else x for x in d]
+    
+    # depth[j:k] = [x if x>=0 and elevation>0 else 0 for x in d] # This is to correcto for GEMS data which assumes stage=0 onshore when dry but should = elevation
+    # for q in xrange(number_of_points):
+        # if elevation[q] >= 0 and stage[j+q]==0:
+            # depth[j+q] = 0
+    
 momentum = depth * speed
 
@@ -142,36 +154,36 @@
         assert mx > 0 and my > 0
     if t > 90.0 and t < 180.0:
-        mx = momentum[i]*math.sin(math.radians(180 - t))
-        my = momentum[i]*math.cos(math.radians(180 - t))
+        mx = momentum[i]*math.sin(math.radians(t))
+        my = momentum[i]*math.cos(math.radians(t))
         assert mx > 0 and my < 0
     if t > 180.0 and t < 270.0:
-        mx = momentum[i]*math.cos(math.radians(270 - t))
-        my = momentum[i]*math.sin(math.radians(270 - t))
+        mx = momentum[i]*math.cos(math.radians(t))
+        my = momentum[i]*math.sin(math.radians(t))
         assert mx < 0 and my < 0
     if t > 270.0 and t < 360.0:
-        mx = momentum[i]*math.sin(math.radians(360 - t))
-        my = momentum[i]*math.cos(math.radians(360 - t))
+        mx = momentum[i]*math.sin(math.radians(t))
+        my = momentum[i]*math.cos(math.radians(t))
         assert mx < 0 and my > 0
     if t == 0.0 or t == 360.0:
         mx = 0
         my = momentum[i]
-        assert my > 0
+        assert my >= 0
     if t == 90.0:
         mx = momentum[i]
         my = 0
-        assert mx > 0
+        assert mx >= 0
     if t == 180.0:
         mx = 0
-        my = momentum[i]
-        assert my < 0
+        my = -momentum[i]
+        assert my <= 0
     if t == 270.0:
-        mx = momentum[i]
+        mx = -momentum[i]
         my = 0
-        assert mx < 0
+        assert mx <= 0
         
     xmomentum[i] = mx
     ymomentum[i] = my
 
-    assert mx[i]^2 + my[i]^2 == momentum[i]
+    assert math.sqrt(mx**2 + my**2) - momentum[i] < 1.e-06
     
 x_origin_int = int(10000*x_origin)
Index: /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/project.py
===================================================================
--- /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/project.py	(revision 7679)
+++ /branches/anuga_1_1/anuga_work/production/mandurah_storm_surge_2009/project.py	(revision 7680)
@@ -104,22 +104,22 @@
 # Format for points easting,northing (no header)                    
 interior_regions_data = [['intermediate.csv', 2500],
-						['area_of_interest.csv', 100],
-                        ['canals_nth_2.csv', 100],  # Canal regions used to force mesh to fit canals
-                        ['canals_nth_3.csv', 100],   
-                        ['canals_nth_4.csv', 100], 
-                        ['canals_nth_5.csv', 100],
-                        ['canals_nth_6.csv', 100], 
-                        ['canals_nth_7.csv', 100],
-                        ['canals_nth_8.csv', 100], 
-                        ['canals_nth_9.csv', 100],
-                        ['canals_nth_10.csv', 100], 
-                        ['canals_nth_11.csv', 100],
-                        ['canals_nth_12.csv', 100], 
-                        ['canals_sth_1.csv', 100],
-                        ['canals_sth_2.csv', 100], 
-                        ['canals_sth_3.csv', 100],
-                        ['canals_sth_4.csv', 100], 
-                        ['canals_sth_5.csv', 100],
-                        ['canals_sth_6.csv', 100]]
+						['area_of_interest.csv', 200],
+                        ['canals_nth_2.csv', 200],  # Canal regions used to force mesh to fit canals
+                        ['canals_nth_3.csv', 200],   
+                        ['canals_nth_4.csv', 200], 
+                        ['canals_nth_5.csv', 200],
+                        ['canals_nth_6.csv', 200], 
+                        ['canals_nth_7.csv', 200],
+                        ['canals_nth_8.csv', 200], 
+                        ['canals_nth_9.csv', 200],
+                        ['canals_nth_10.csv', 200], 
+                        ['canals_nth_11.csv', 200],
+                        ['canals_nth_12.csv', 200], 
+                        ['canals_sth_1.csv', 200],
+                        ['canals_sth_2.csv', 200], 
+                        ['canals_sth_3.csv', 200],
+                        ['canals_sth_4.csv', 200], 
+                        ['canals_sth_5.csv', 200],
+                        ['canals_sth_6.csv', 200]]
                         
 # LAND - used to set the initial stage/water to be offcoast only
