Index: /branches/numpy_anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.py	(revision 6904)
+++ /branches/numpy_anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.py	(revision 6905)
@@ -18,5 +18,5 @@
 from anuga.shallow_water.shallow_water_domain import Reflective_boundary
 from anuga.shallow_water.shallow_water_domain import Dirichlet_boundary
-from anuga.shallow_water.shallow_water_domain import Transmissive_Momentum_Set_Stage_boundary
+from anuga.shallow_water.shallow_water_domain import Transmissive_momentum_set_stage_boundary
 from anuga.shallow_water.shallow_water_domain import Inflow
 from anuga.shallow_water.data_manager import get_flow_through_cross_section
@@ -46,5 +46,5 @@
 
         domain = Domain(points, vertices, boundary)   
-        domain.set_name('inflow_flowline_test')              # Output name
+        domain.set_name('inflow_flowline_test')
 
 
@@ -57,8 +57,8 @@
             return z
 
-        domain.set_quantity('elevation', topography)  # Use function for elevation
-        domain.set_quantity('friction', mannings_n)   # Constant friction of conc surface   
+        domain.set_quantity('elevation', topography)
+        domain.set_quantity('friction', mannings_n)
         domain.set_quantity('stage',
-                            expression='elevation')   # Dry initial condition
+                            expression='elevation') # Dry initial condition
 
 
@@ -93,9 +93,13 @@
         #----------------------------------------------------------------------
 
-        Br = Reflective_boundary(domain)              # Solid reflective wall
-        #Bo = Dirichlet_boundary([-(slope*length)+normal_depth, 0, 0])  # Outflow stage at normal depth
+        Br = Reflective_boundary(domain) # Solid reflective wall
+
+        # Define downstream boundary based on predicted depth
         def normal_depth_stage_downstream(t):
-            return (-slope*length) + normal_depth 
-        Bt = Transmissive_Momentum_Set_Stage_boundary(domain=domain,function=normal_depth_stage_downstream)
+            return (-slope*length) + normal_depth
+        
+        Bt = Transmissive_momentum_set_stage_boundary(domain=domain,
+                                                      function=normal_depth_stage_downstream)
+        
         domain.set_boundary({'left': Br, 'right': Bt, 'top': Br, 'bottom': Br})
 
@@ -110,4 +114,5 @@
             if verbose :
                 print domain.timestepping_statistics()
+                print domain.volumetric_balance_statistics()                
 
 
Index: /branches/numpy_anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.stdout
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.stdout	(revision 6904)
+++ /branches/numpy_anuga_validation/automated_validation_tests/flow_tests/test_inflow_using_flowline.stdout	(revision 6905)
@@ -2,126 +2,126 @@
 Slope: 0.00333333333333 Mannings n: 0.15 Velocity: 0.56390879505 Froude: 0.135269618248
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.04670388, 0.07995951], steps=1512 (15s)
-Time = 200.0000, delta t in [0.07127650, 0.07370136], steps=1376 (20s)
-Time = 300.0000, delta t in [0.07195764, 0.07355355], steps=1378 (23s)
-Time = 400.0000, delta t in [0.07105244, 0.07239161], steps=1396 (24s)
-Time = 500.0000, delta t in [0.07030722, 0.07140440], steps=1414 (24s)
-Time = 600.0000, delta t in [0.06989589, 0.07065760], steps=1425 (25s)
-Time = 700.0000, delta t in [0.06967450, 0.07029477], steps=1431 (25s)
-Time = 800.0000, delta t in [0.06953978, 0.07006511], steps=1435 (25s)
-Time = 900.0000, delta t in [0.06946481, 0.06991716], steps=1437 (25s)
-Time = 1000.0000, delta t in [0.06941649, 0.06986708], steps=1438 (25s)
-90 degree flowline: ANUGA = 19.852468, Ref = 20.000000
-45 degree flowline: ANUGA = 19.816033, Ref = 20.000000
-Depth at 200m: ANUGA = 1.763466, Mannings = 1.773336
+Time = 100.0000, delta t in [0.04670388, 0.07995951], steps=1512 (11s)
+Time = 200.0000, delta t in [0.07127650, 0.07370342], steps=1376 (14s)
+Time = 300.0000, delta t in [0.07195486, 0.07355360], steps=1378 (16s)
+Time = 400.0000, delta t in [0.07104521, 0.07239835], steps=1396 (16s)
+Time = 500.0000, delta t in [0.07030060, 0.07141862], steps=1414 (17s)
+Time = 600.0000, delta t in [0.06991216, 0.07067471], steps=1425 (17s)
+Time = 700.0000, delta t in [0.06967587, 0.07023568], steps=1431 (17s)
+Time = 800.0000, delta t in [0.06953975, 0.07006602], steps=1435 (17s)
+Time = 900.0000, delta t in [0.06946477, 0.06991716], steps=1437 (17s)
+Time = 1000.0000, delta t in [0.06941648, 0.06986710], steps=1438 (17s)
+90 degree flowline: ANUGA = 19.853798, Ref = 20.000000
+45 degree flowline: ANUGA = 19.815719, Ref = 20.000000
+Depth at 200m: ANUGA = 1.763524, Mannings = 1.773336
 
 Slope: 0.00666666666667 Mannings n: 0.15 Velocity: 0.694253162662 Froude: 0.184783744042
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.05343049, 0.08872063], steps=1343 (13s)
-Time = 200.0000, delta t in [0.07467386, 0.07666278], steps=1325 (18s)
-Time = 300.0000, delta t in [0.07408417, 0.07515470], steps=1343 (22s)
-Time = 400.0000, delta t in [0.07382265, 0.07458443], steps=1350 (23s)
-Time = 500.0000, delta t in [0.07368393, 0.07432979], steps=1353 (23s)
-Time = 600.0000, delta t in [0.07360722, 0.07417996], steps=1355 (23s)
-Time = 700.0000, delta t in [0.07356671, 0.07410252], steps=1356 (23s)
-Time = 800.0000, delta t in [0.07354632, 0.07407251], steps=1357 (23s)
-Time = 900.0000, delta t in [0.07353547, 0.07405410], steps=1357 (23s)
-Time = 1000.0000, delta t in [0.07353034, 0.07404268], steps=1357 (23s)
-90 degree flowline: ANUGA = 19.962845, Ref = 20.000000
-45 degree flowline: ANUGA = 19.894110, Ref = 20.000000
-Depth at 200m: ANUGA = 1.435703, Mannings = 1.440397
+Time = 100.0000, delta t in [0.05343049, 0.08872063], steps=1343 (10s)
+Time = 200.0000, delta t in [0.07466640, 0.07669264], steps=1325 (14s)
+Time = 300.0000, delta t in [0.07408680, 0.07513123], steps=1343 (16s)
+Time = 400.0000, delta t in [0.07382196, 0.07457934], steps=1350 (17s)
+Time = 500.0000, delta t in [0.07368435, 0.07432676], steps=1353 (17s)
+Time = 600.0000, delta t in [0.07360707, 0.07418822], steps=1355 (17s)
+Time = 700.0000, delta t in [0.07356677, 0.07410257], steps=1356 (17s)
+Time = 800.0000, delta t in [0.07354588, 0.07406963], steps=1357 (17s)
+Time = 900.0000, delta t in [0.07353536, 0.07404961], steps=1357 (17s)
+Time = 1000.0000, delta t in [0.07353037, 0.07404735], steps=1357 (17s)
+90 degree flowline: ANUGA = 19.941952, Ref = 20.000000
+45 degree flowline: ANUGA = 19.894587, Ref = 20.000000
+Depth at 200m: ANUGA = 1.435380, Mannings = 1.440397
 
 Slope: 0.0133333333333 Mannings n: 0.15 Velocity: 0.854725902658 Froude: 0.252422033155
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.06106513, 0.09844171], steps=1267 (12s)
-Time = 200.0000, delta t in [0.07711239, 0.07797078], steps=1292 (16s)
-Time = 300.0000, delta t in [0.07702229, 0.07739409], steps=1297 (20s)
-Time = 400.0000, delta t in [0.07700414, 0.07730267], steps=1297 (22s)
-Time = 500.0000, delta t in [0.07700041, 0.07729391], steps=1298 (22s)
-Time = 600.0000, delta t in [0.07699997, 0.07729250], steps=1298 (22s)
-Time = 700.0000, delta t in [0.07699919, 0.07729220], steps=1298 (22s)
-Time = 800.0000, delta t in [0.07699915, 0.07729199], steps=1298 (22s)
-Time = 900.0000, delta t in [0.07699922, 0.07729228], steps=1298 (22s)
-Time = 1000.0000, delta t in [0.07699912, 0.07729102], steps=1298 (22s)
-90 degree flowline: ANUGA = 19.966722, Ref = 20.000000
-45 degree flowline: ANUGA = 19.904081, Ref = 20.000000
-Depth at 200m: ANUGA = 1.160740, Mannings = 1.169966
+Time = 100.0000, delta t in [0.06106513, 0.09844171], steps=1267 (9s)
+Time = 200.0000, delta t in [0.07710981, 0.07795397], steps=1292 (12s)
+Time = 300.0000, delta t in [0.07702050, 0.07737667], steps=1297 (14s)
+Time = 400.0000, delta t in [0.07700624, 0.07730440], steps=1297 (16s)
+Time = 500.0000, delta t in [0.07700135, 0.07729531], steps=1298 (16s)
+Time = 600.0000, delta t in [0.07699943, 0.07729236], steps=1298 (15s)
+Time = 700.0000, delta t in [0.07699928, 0.07729154], steps=1298 (15s)
+Time = 800.0000, delta t in [0.07699919, 0.07729217], steps=1298 (15s)
+Time = 900.0000, delta t in [0.07699922, 0.07729310], steps=1298 (15s)
+Time = 1000.0000, delta t in [0.07699910, 0.07729218], steps=1298 (15s)
+90 degree flowline: ANUGA = 20.006814, Ref = 20.000000
+45 degree flowline: ANUGA = 19.909959, Ref = 20.000000
+Depth at 200m: ANUGA = 1.163983, Mannings = 1.169966
 
 Slope: 0.00333333333333 Mannings n: 0.07 Velocity: 0.890850441519 Froude: 0.268592673148
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.05472541, 0.10050047], steps=1319 (14s)
-Time = 200.0000, delta t in [0.07832952, 0.07950825], steps=1270 (20s)
-Time = 300.0000, delta t in [0.07789850, 0.07837491], steps=1281 (22s)
-Time = 400.0000, delta t in [0.07760546, 0.07795929], steps=1286 (22s)
-Time = 500.0000, delta t in [0.07747375, 0.07766431], steps=1290 (22s)
-Time = 600.0000, delta t in [0.07742076, 0.07753688], steps=1291 (22s)
-Time = 700.0000, delta t in [0.07739751, 0.07748699], steps=1292 (22s)
-Time = 800.0000, delta t in [0.07738720, 0.07746239], steps=1292 (22s)
-Time = 900.0000, delta t in [0.07738258, 0.07745436], steps=1292 (22s)
-Time = 1000.0000, delta t in [0.07738083, 0.07745012], steps=1292 (22s)
-90 degree flowline: ANUGA = 19.990141, Ref = 20.000000
-45 degree flowline: ANUGA = 19.971668, Ref = 20.000000
-Depth at 200m: ANUGA = 1.119491, Mannings = 1.122523
+Time = 100.0000, delta t in [0.05472541, 0.10050047], steps=1319 (10s)
+Time = 200.0000, delta t in [0.07832767, 0.07949366], steps=1270 (14s)
+Time = 300.0000, delta t in [0.07789828, 0.07837894], steps=1281 (15s)
+Time = 400.0000, delta t in [0.07760358, 0.07796360], steps=1286 (15s)
+Time = 500.0000, delta t in [0.07747343, 0.07766337], steps=1290 (15s)
+Time = 600.0000, delta t in [0.07742068, 0.07754068], steps=1291 (15s)
+Time = 700.0000, delta t in [0.07739775, 0.07748682], steps=1292 (15s)
+Time = 800.0000, delta t in [0.07738722, 0.07746348], steps=1292 (15s)
+Time = 900.0000, delta t in [0.07738279, 0.07745530], steps=1292 (15s)
+Time = 1000.0000, delta t in [0.07738087, 0.07745167], steps=1292 (15s)
+90 degree flowline: ANUGA = 19.989943, Ref = 20.000000
+45 degree flowline: ANUGA = 19.972075, Ref = 20.000000
+Depth at 200m: ANUGA = 1.119535, Mannings = 1.122523
 
 Slope: 0.00666666666667 Mannings n: 0.07 Velocity: 1.0967655442 Froude: 0.36690840419
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.06213184, 0.11151226], steps=1258 (13s)
-Time = 200.0000, delta t in [0.07925606, 0.07976601], steps=1259 (19s)
-Time = 300.0000, delta t in [0.07917385, 0.07931469], steps=1263 (22s)
-Time = 400.0000, delta t in [0.07915421, 0.07923430], steps=1263 (22s)
-Time = 500.0000, delta t in [0.07914921, 0.07921473], steps=1264 (22s)
-Time = 600.0000, delta t in [0.07914788, 0.07921076], steps=1264 (22s)
-Time = 700.0000, delta t in [0.07914750, 0.07921009], steps=1264 (22s)
-Time = 800.0000, delta t in [0.07914738, 0.07920941], steps=1264 (22s)
-Time = 900.0000, delta t in [0.07914735, 0.07920935], steps=1264 (22s)
-Time = 1000.0000, delta t in [0.07914733, 0.07920948], steps=1264 (22s)
-90 degree flowline: ANUGA = 19.957824, Ref = 20.000000
-45 degree flowline: ANUGA = 19.962348, Ref = 20.000000
-Depth at 200m: ANUGA = 0.908330, Mannings = 0.911772
+Time = 100.0000, delta t in [0.06213184, 0.11151226], steps=1258 (10s)
+Time = 200.0000, delta t in [0.07925528, 0.07976601], steps=1259 (13s)
+Time = 300.0000, delta t in [0.07917416, 0.07931069], steps=1263 (15s)
+Time = 400.0000, delta t in [0.07915438, 0.07923348], steps=1263 (15s)
+Time = 500.0000, delta t in [0.07914917, 0.07921518], steps=1264 (15s)
+Time = 600.0000, delta t in [0.07914783, 0.07921045], steps=1264 (15s)
+Time = 700.0000, delta t in [0.07914746, 0.07920966], steps=1264 (15s)
+Time = 800.0000, delta t in [0.07914737, 0.07920952], steps=1264 (15s)
+Time = 900.0000, delta t in [0.07914734, 0.07920939], steps=1264 (15s)
+Time = 1000.0000, delta t in [0.07914733, 0.07920929], steps=1264 (15s)
+90 degree flowline: ANUGA = 19.974794, Ref = 20.000000
+45 degree flowline: ANUGA = 19.960926, Ref = 20.000000
+Depth at 200m: ANUGA = 0.908708, Mannings = 0.911772
 
 Slope: 0.0133333333333 Mannings n: 0.07 Velocity: 1.35027677249 Froude: 0.501211650665
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.07125688, 0.12373060], steps=1235 (12s)
-Time = 200.0000, delta t in [0.07952350, 0.07956306], steps=1258 (18s)
-Time = 300.0000, delta t in [0.07949782, 0.07952695], steps=1258 (21s)
-Time = 400.0000, delta t in [0.07949780, 0.07952483], steps=1258 (21s)
-Time = 500.0000, delta t in [0.07949779, 0.07952433], steps=1258 (21s)
-Time = 600.0000, delta t in [0.07949780, 0.07952446], steps=1258 (21s)
-Time = 700.0000, delta t in [0.07949780, 0.07952432], steps=1258 (21s)
-Time = 800.0000, delta t in [0.07949778, 0.07952434], steps=1258 (21s)
-Time = 900.0000, delta t in [0.07949780, 0.07952466], steps=1258 (21s)
-Time = 1000.0000, delta t in [0.07949780, 0.07952430], steps=1258 (21s)
-90 degree flowline: ANUGA = 19.975988, Ref = 20.000000
-45 degree flowline: ANUGA = 19.919995, Ref = 20.000000
-Depth at 200m: ANUGA = 0.737424, Mannings = 0.740589
+Time = 100.0000, delta t in [0.07125688, 0.12373060], steps=1235 (10s)
+Time = 200.0000, delta t in [0.07952332, 0.07956306], steps=1258 (13s)
+Time = 300.0000, delta t in [0.07949784, 0.07952682], steps=1258 (16s)
+Time = 400.0000, delta t in [0.07949778, 0.07952470], steps=1258 (16s)
+Time = 500.0000, delta t in [0.07949767, 0.07952433], steps=1258 (16s)
+Time = 600.0000, delta t in [0.07949779, 0.07952430], steps=1258 (16s)
+Time = 700.0000, delta t in [0.07949779, 0.07952474], steps=1258 (16s)
+Time = 800.0000, delta t in [0.07949780, 0.07952480], steps=1258 (16s)
+Time = 900.0000, delta t in [0.07949778, 0.07952431], steps=1258 (16s)
+Time = 1000.0000, delta t in [0.07949773, 0.07952455], steps=1258 (16s)
+90 degree flowline: ANUGA = 19.975535, Ref = 20.000000
+45 degree flowline: ANUGA = 19.920764, Ref = 20.000000
+Depth at 200m: ANUGA = 0.737426, Mannings = 0.740589
 
 Slope: 0.00333333333333 Mannings n: 0.035 Velocity: 1.35027677249 Froude: 0.501211650665
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.06406596, 0.12373060], steps=1311 (15s)
-Time = 200.0000, delta t in [0.07804143, 0.07809819], steps=1281 (22s)
-Time = 300.0000, delta t in [0.07809823, 0.07810989], steps=1281 (22s)
-Time = 400.0000, delta t in [0.07810992, 0.07811652], steps=1281 (22s)
-Time = 500.0000, delta t in [0.07806106, 0.07811752], steps=1281 (22s)
-Time = 600.0000, delta t in [0.07806120, 0.07810608], steps=1281 (22s)
-Time = 700.0000, delta t in [0.07806119, 0.07810560], steps=1281 (22s)
-Time = 800.0000, delta t in [0.07806119, 0.07810528], steps=1281 (22s)
-Time = 900.0000, delta t in [0.07806119, 0.07810526], steps=1281 (22s)
-Time = 1000.0000, delta t in [0.07806119, 0.07810631], steps=1281 (22s)
-90 degree flowline: ANUGA = 19.995665, Ref = 20.000000
-45 degree flowline: ANUGA = 19.981393, Ref = 20.000000
-Depth at 200m: ANUGA = 0.739766, Mannings = 0.740589
+Time = 100.0000, delta t in [0.06406596, 0.12373060], steps=1311 (11s)
+Time = 200.0000, delta t in [0.07804143, 0.07809819], steps=1281 (15s)
+Time = 300.0000, delta t in [0.07809823, 0.07810989], steps=1281 (16s)
+Time = 400.0000, delta t in [0.07810992, 0.07811652], steps=1281 (16s)
+Time = 500.0000, delta t in [0.07806103, 0.07811751], steps=1281 (15s)
+Time = 600.0000, delta t in [0.07806119, 0.07810605], steps=1281 (15s)
+Time = 700.0000, delta t in [0.07806119, 0.07810576], steps=1281 (15s)
+Time = 800.0000, delta t in [0.07806118, 0.07810622], steps=1281 (15s)
+Time = 900.0000, delta t in [0.07806119, 0.07810551], steps=1281 (15s)
+Time = 1000.0000, delta t in [0.07806119, 0.07810586], steps=1281 (15s)
+90 degree flowline: ANUGA = 19.987676, Ref = 20.000000
+45 degree flowline: ANUGA = 19.979713, Ref = 20.000000
+Depth at 200m: ANUGA = 0.739503, Mannings = 0.740589
 
 Slope: 0.00666666666667 Mannings n: 0.035 Velocity: 1.66238570492 Froude: 0.684675291962
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.07298360, 0.13728769], steps=1296 (15s)
-Time = 200.0000, delta t in [0.07648774, 0.07652320], steps=1307 (21s)
-Time = 300.0000, delta t in [0.07652322, 0.07652483], steps=1307 (22s)
-Time = 400.0000, delta t in [0.07652485, 0.07652492], steps=1307 (22s)
-Time = 500.0000, delta t in [0.07652492, 0.07652499], steps=1307 (22s)
-Time = 600.0000, delta t in [0.07652492, 0.07652500], steps=1307 (22s)
-Time = 700.0000, delta t in [0.07652492, 0.07652500], steps=1307 (22s)
-Time = 800.0000, delta t in [0.07652492, 0.07652500], steps=1307 (22s)
-Time = 900.0000, delta t in [0.07652492, 0.07652500], steps=1307 (22s)
-Time = 1000.0000, delta t in [0.07652492, 0.07652500], steps=1307 (22s)
+Time = 100.0000, delta t in [0.07298360, 0.13728769], steps=1296 (11s)
+Time = 200.0000, delta t in [0.07648774, 0.07652320], steps=1307 (15s)
+Time = 300.0000, delta t in [0.07652322, 0.07652483], steps=1307 (15s)
+Time = 400.0000, delta t in [0.07652485, 0.07652492], steps=1307 (15s)
+Time = 500.0000, delta t in [0.07652492, 0.07652499], steps=1307 (15s)
+Time = 600.0000, delta t in [0.07652492, 0.07652500], steps=1307 (15s)
+Time = 700.0000, delta t in [0.07652492, 0.07652500], steps=1307 (15s)
+Time = 800.0000, delta t in [0.07652492, 0.07652500], steps=1307 (15s)
+Time = 900.0000, delta t in [0.07652492, 0.07652500], steps=1307 (15s)
+Time = 1000.0000, delta t in [0.07652492, 0.07652500], steps=1307 (15s)
 90 degree flowline: ANUGA = 19.980911, Ref = 20.000000
 45 degree flowline: ANUGA = 19.965897, Ref = 20.000000
@@ -130,14 +130,14 @@
 Slope: 0.0133333333333 Mannings n: 0.035 Velocity: 2.04663687344 Froude: 0.935294011626
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.07303469, 0.15233023], steps=1326 (14s)
-Time = 200.0000, delta t in [0.07312989, 0.07313055], steps=1368 (22s)
-Time = 300.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 400.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 500.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 600.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 700.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 800.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 900.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
-Time = 1000.0000, delta t in [0.07313055, 0.07313080], steps=1368 (23s)
+Time = 100.0000, delta t in [0.07303469, 0.15233023], steps=1326 (11s)
+Time = 200.0000, delta t in [0.07312989, 0.07313055], steps=1368 (15s)
+Time = 300.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 400.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 500.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 600.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 700.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 800.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 900.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
+Time = 1000.0000, delta t in [0.07313055, 0.07313080], steps=1368 (16s)
 90 degree flowline: ANUGA = 19.969930, Ref = 20.000000
 45 degree flowline: ANUGA = 19.967616, Ref = 20.000000
@@ -146,14 +146,14 @@
 Slope: 0.00333333333333 Mannings n: 0.012 Velocity: 2.5665804151 Froude: 1.31346733326
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.07007266, 0.17058591], steps=1370 (18s)
-Time = 200.0000, delta t in [0.06530360, 0.07029554], steps=1472 (26s)
-Time = 300.0000, delta t in [0.06767159, 0.07029537], steps=1432 (25s)
-Time = 400.0000, delta t in [0.07029485, 0.07029537], steps=1423 (25s)
-Time = 500.0000, delta t in [0.07029485, 0.07029537], steps=1423 (25s)
-Time = 600.0000, delta t in [0.07029485, 0.07029538], steps=1423 (25s)
-Time = 700.0000, delta t in [0.07029485, 0.07029537], steps=1423 (25s)
-Time = 800.0000, delta t in [0.07029485, 0.07029537], steps=1423 (25s)
-Time = 900.0000, delta t in [0.07029485, 0.07029538], steps=1423 (25s)
-Time = 1000.0000, delta t in [0.07029485, 0.07029537], steps=1423 (25s)
+Time = 100.0000, delta t in [0.07007266, 0.17058591], steps=1370 (13s)
+Time = 200.0000, delta t in [0.06530360, 0.07029554], steps=1472 (18s)
+Time = 300.0000, delta t in [0.06767159, 0.07029537], steps=1432 (17s)
+Time = 400.0000, delta t in [0.07029485, 0.07029537], steps=1423 (17s)
+Time = 500.0000, delta t in [0.07029485, 0.07029537], steps=1423 (17s)
+Time = 600.0000, delta t in [0.07029485, 0.07029538], steps=1423 (17s)
+Time = 700.0000, delta t in [0.07029485, 0.07029537], steps=1423 (17s)
+Time = 800.0000, delta t in [0.07029485, 0.07029537], steps=1423 (17s)
+Time = 900.0000, delta t in [0.07029485, 0.07029538], steps=1423 (17s)
+Time = 1000.0000, delta t in [0.07029485, 0.07029537], steps=1423 (18s)
 90 degree flowline: ANUGA = 19.992891, Ref = 20.000000
 45 degree flowline: ANUGA = 20.001657, Ref = 20.000000
@@ -162,14 +162,14 @@
 Slope: 0.00666666666667 Mannings n: 0.012 Velocity: 3.15983113945 Froude: 1.79424925317
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.06751910, 0.18927691], steps=1410 (18s)
-Time = 200.0000, delta t in [0.06369027, 0.06759849], steps=1496 (26s)
-Time = 300.0000, delta t in [0.06753158, 0.06759767], steps=1480 (26s)
-Time = 400.0000, delta t in [0.06753134, 0.06759800], steps=1480 (26s)
-Time = 500.0000, delta t in [0.06753197, 0.06759766], steps=1480 (26s)
-Time = 600.0000, delta t in [0.06753148, 0.06759728], steps=1480 (26s)
-Time = 700.0000, delta t in [0.06753153, 0.06759775], steps=1480 (26s)
-Time = 800.0000, delta t in [0.06753152, 0.06759801], steps=1480 (26s)
-Time = 900.0000, delta t in [0.06753132, 0.06759788], steps=1480 (25s)
-Time = 1000.0000, delta t in [0.06753140, 0.06759801], steps=1480 (26s)
+Time = 100.0000, delta t in [0.06751910, 0.18927691], steps=1410 (13s)
+Time = 200.0000, delta t in [0.06369027, 0.06759849], steps=1496 (18s)
+Time = 300.0000, delta t in [0.06753158, 0.06759767], steps=1480 (18s)
+Time = 400.0000, delta t in [0.06753134, 0.06759800], steps=1480 (18s)
+Time = 500.0000, delta t in [0.06753197, 0.06759766], steps=1480 (18s)
+Time = 600.0000, delta t in [0.06753148, 0.06759728], steps=1480 (18s)
+Time = 700.0000, delta t in [0.06753153, 0.06759775], steps=1480 (18s)
+Time = 800.0000, delta t in [0.06753152, 0.06759801], steps=1480 (18s)
+Time = 900.0000, delta t in [0.06753132, 0.06759788], steps=1480 (18s)
+Time = 1000.0000, delta t in [0.06753140, 0.06759801], steps=1480 (18s)
 90 degree flowline: ANUGA = 19.997099, Ref = 20.000000
 45 degree flowline: ANUGA = 20.026867, Ref = 20.000000
@@ -178,15 +178,15 @@
 Slope: 0.0133333333333 Mannings n: 0.012 Velocity: 3.89020845445 Froude: 2.45101671048
 Time = 0.0000, steps=0 (0s)
-Time = 100.0000, delta t in [0.06083936, 0.21001588], steps=1534 (19s)
-Time = 200.0000, delta t in [0.05060426, 0.06088284], steps=1667 (29s)
-Time = 300.0000, delta t in [0.06014772, 0.06083528], steps=1649 (29s)
-Time = 400.0000, delta t in [0.06002239, 0.06083472], steps=1649 (29s)
-Time = 500.0000, delta t in [0.06029467, 0.06081015], steps=1649 (29s)
-Time = 600.0000, delta t in [0.06019411, 0.06079852], steps=1649 (29s)
-Time = 700.0000, delta t in [0.06012329, 0.06076357], steps=1650 (29s)
-Time = 800.0000, delta t in [0.06018782, 0.06076638], steps=1650 (29s)
-Time = 900.0000, delta t in [0.06016674, 0.06078747], steps=1650 (29s)
-Time = 1000.0000, delta t in [0.06023750, 0.06077108], steps=1650 (29s)
-90 degree flowline: ANUGA = 20.138526, Ref = 20.000000
-45 degree flowline: ANUGA = 20.053061, Ref = 20.000000
-Depth at 200m: ANUGA = 0.258089, Mannings = 0.257056
+Time = 100.0000, delta t in [0.06083936, 0.21001588], steps=1534 (14s)
+Time = 200.0000, delta t in [0.05060426, 0.06088284], steps=1667 (20s)
+Time = 300.0000, delta t in [0.06014772, 0.06083528], steps=1649 (20s)
+Time = 400.0000, delta t in [0.06002230, 0.06083472], steps=1649 (20s)
+Time = 500.0000, delta t in [0.06028106, 0.06081459], steps=1649 (20s)
+Time = 600.0000, delta t in [0.06020233, 0.06079963], steps=1649 (20s)
+Time = 700.0000, delta t in [0.06005735, 0.06079762], steps=1650 (20s)
+Time = 800.0000, delta t in [0.06026735, 0.06076164], steps=1650 (20s)
+Time = 900.0000, delta t in [0.06021111, 0.06076745], steps=1650 (20s)
+Time = 1000.0000, delta t in [0.06027006, 0.06076701], steps=1650 (20s)
+90 degree flowline: ANUGA = 20.128291, Ref = 20.000000
+45 degree flowline: ANUGA = 20.048036, Ref = 20.000000
+Depth at 200m: ANUGA = 0.258052, Mannings = 0.257056
Index: /branches/numpy_anuga_validation/automated_validation_tests/okushiri_tank_validation/validate_okushiri.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/okushiri_tank_validation/validate_okushiri.py	(revision 6904)
+++ /branches/numpy_anuga_validation/automated_validation_tests/okushiri_tank_validation/validate_okushiri.py	(revision 6905)
@@ -13,14 +13,16 @@
         for file in os.listdir('.'):
             if file.endswith('.stdout') or\
-               file.endswith('.sww') or\
-               file.endswith('.msh'):
+                    file.endswith('.sww') or\
+                    file.endswith('.msh'):
                 os.remove(file)
                 
-        
+                
     def tearDown(self):
         pass
 
     def test_that_output_is_as_expected(self):
-
+        """Test that ANUGA replicates physics of the Okushiri Island
+        wave tank experiment
+        """
         
         #print
@@ -41,4 +43,20 @@
                         %s)
         assert res == 0
+
+
+    def test_caching_of_set_quantity(self):
+        """Test that caching of set_quantity works
+        """
+        
+        s = 'create_okushiri.py'
+        res = os.system('python %s > create_okushiri_for_caching.stdout' %s)
+        assert res == 0
+
+
+        s = 'test_caching_of_set_quantity.py'
+        res = os.system('python %s > test_caching_of_set_quantity.stdout' %s)
+        assert res == 0
+
+        
 
     def manual_test_that_output_is_as_expected(self):
@@ -65,5 +83,5 @@
 #-------------------------------------------------------------
 if __name__ == "__main__":
-    suite = unittest.makeSuite(Test_Okushiri,'test')
+    suite = unittest.makeSuite(Test_Okushiri, 'test')
     runner = unittest.TextTestRunner(verbosity=2)
     runner.run(suite)
Index: anches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/project.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/project.py	(revision 6904)
+++ 	(revision )
@@ -1,255 +1,0 @@
-"""
-This file contains all your file and directory definitions 
-for elevation, meshes and outputs.
-"""
-
-import os
-from anuga.utilities.system_tools import get_user_name, get_host_name
-from time import localtime, strftime, gmtime
-from os.path import join, exists
-
-
-#-------------------------------------------------------------------------------
-# Directory setup
-#-------------------------------------------------------------------------------
-
-# this section needs to be updated to reflect the modelled community.
-# Note, the user needs to set up the directory system accordingly
-state = 'thailand'
-scenario_name = 'patong'
-scenario_folder = 'patong_tsunami_scenario'
-
-#-------------------------------------------------------------------------------
-# Initial Conditions
-#-------------------------------------------------------------------------------
-
-# Model specific parameters.
-# One or all can be changed each time the run_model script is executed
-tide = 0.8              # difference between MSL and HAT
-zone = 47               # specify zone of model
-model = 'small'         # different size model 'small' or 'large'
-event_number = 'mux_' + model    # the event number or the mux file name
-alpha = 0.1             # smoothing parameter for mesh
-friction=0.01           # manning's friction coefficient
-starttime=0             # start time for simulation
-finaltime=15000         # final time for simulation
-
-use_buildings = True
-setup = 'trial'         # This can be one of three values
-                        #    trial - coarsest mesh, fast
-                        #    basic - coarse mesh
-                        #    final - fine mesh, slowest
-
-#-------------------------------------------------------------------------------
-# Output filename
-#
-# Your output filename should be unique between different runs on different data.
-# The list of items below will be used to create a file in your output directory.
-# Your user name and time+date will be automatically added.  For example,
-#     [setup, tide, event_number]
-# will result in a filename like
-#     20090212_091046_run_final_0_27283_rwilson
-#-------------------------------------------------------------------------------
-
-output_comment = [setup, tide, event_number, 'validation']
-
-#-------------------------------------------------------------------------------
-# Input Data
-#-------------------------------------------------------------------------------
-
-# ELEVATION DATA
-# Used in build_elevation.py
-# Format for ascii grids, as produced in ArcGIS + a projection file
-ascii_grid_filenames = []
-
-# Format for point is x,y,elevation (with header)
-point_filenames = ['patong_10m_grid_msl_Project.txt',    # 10m main grid
-                   'patong_10m_small_grid_for_anuga_sub_Project.txt', # 10m saddle
-                   'patong_bay_1s_grid_Project.txt',   # 1s grid
-                   'andaman_3s_grid_Clip2_Project.txt'] #3s grid
-
-### Add csv header list to all files in point_filenames
-##headerlist = ['x', 'y', 'elevation'] 
-##for f in point_filenames:
-##    add_csv_header(join(topographies_folder, f), headerlist)
-
-extent_polygon_filenames = ['patong_10m.txt',
-                            'saddle_10m.txt',
-                            'patong_1s.txt']
-
-
-# BOUNDING POLYGON - for data clipping and estimate of triangles in mesh
-# Used in build_elevation.py
-# Format for points easting,northing (no header)
-bounding_polygon_filename = 'bounding_polygon_'+ model + '.csv'
-bounding_polygon_maxarea = 100000
-
-# INTERIOR REGIONS -  for designing the mesh
-# Used in run_model.py
-# Format for points easting,northing (no header)                    
-interior_regions_data = [['inundation_area.csv', 75],
-                         ['aoi.csv', 200],
-                         ['aos.csv', 900],
-                         ['sw_coast_original.csv', 7000],
-                         ['building_main.csv', 20],
-                         ['building_main_small.csv', 20],
-                         ['building_main_south.csv', 20],
-                         ['building_saddle.csv', 20]]
-
-
-# LAND - used to set the initial stage/water to be offcoast only
-# Used in run_model.py.  Format for points easting,northing (no header)
-land_initial_conditions_filename = [['initial_conditions_' + model +'.csv', 0]]
-
-# GAUGES - for creating timeseries at a specific point
-# Used in get_timeseries.py.  
-# Format easting,northing,name,elevation (with header)
-gauges_filename = 'gauges.csv'
-
-# BUILDINGS POLYOGN - for elevation of buildings
-# Used in run_model.py
-# Format easting,northing,id,floor (with header)
-building_polygon_filename = 'buildings.csv' 
-
-
-# BUILDINGS EXPOSURE - for identifying inundated houses
-# Used in run_building_inundation.py
-# Format latitude,longitude etc (geographic)
-building_exposure_filename = 'busselton_res_clip.csv' # from NEXIS
-
-# BOUNDING POLYGON - used in build_boundary.py and run_model.py respectively
-# NOTE: when files are put together the points must be in sequence
-# For ease go clockwise!
-# Check the run_model.py for boundary_tags
-
-# Thinned ordering file from Hazard Map (geographic)
-# Format is index,latitude,longitude (with header)
-urs_order_filename = 'urs_order_'+ model +'.csv'
-
-# Landward bounding points
-# Format easting,northing (no header)
-landward_boundary_filename = 'landward_boundary_'+ model +'.csv'
-
-# MUX input filename.
-# If a meta-file from EventSelection is used, set 'multi-mux' to True.
-# If a single MUX stem filename (*.grd) is used, set 'multi-mux' to False.
-mux_input_filename = event_number # to be found in event_folder
-                                    # (ie boundaries/event_number/)
-multi_mux = False
-##mux_input_filename = 'event.list'
-##multi_mux = True
-
-#-------------------------------------------------------------------------------
-# Clipping regions for export to asc and regions for clipping data
-# Final inundation maps should only be created in regions of the finest mesh
-#-------------------------------------------------------------------------------
-
-#CBD extract ascii grid - coordinates from patong_1s extent
-xminCBD = 417445.1119
-xmaxCBD = 425601.7881
-yminCBD = 870663.4547
-ymaxCBD = 876965.3856
-
-
-################################################################################
-################################################################################
-####         NOTE: NOTHING WOULD NORMALLY CHANGE BELOW THIS POINT.          ####
-################################################################################
-################################################################################
-
-# Get system user and host names.
-# These values can be used to distinguish between two similar runs by two
-# different users or runs by the same user on two different machines.
-user = get_user_name()
-host = get_host_name()
-
-# Environment variable names.
-# The inundation directory, not the data directory.
-ENV_INUNDATIONHOME = 'INUNDATIONHOME'
-
-# Path to MUX data
-ENV_MUXHOME = 'MUXHOME'
-
-#-------------------------------------------------------------------------------
-# Output Elevation Data
-#-------------------------------------------------------------------------------
-
-# Output filename for elevation
-# this is a combination of all the data generated in build_elevation.py
-combined_elevation_basename = scenario_name + '_combined_elevation_' + model
-
-#-------------------------------------------------------------------------------
-# Directory Structure
-#-------------------------------------------------------------------------------
-
-# determines time for setting up output directories
-time = strftime('%Y%m%d_%H%M%S', localtime()) 
-gtime = strftime('%Y%m%d_%H%M%S', gmtime()) 
-build_time = time + '_build_' + model
-run_time = time + '_run_'
-
-# create paths generated from environment variables.
-home = join(os.getenv(ENV_INUNDATIONHOME), 'data') # Absolute path for data folder
-muxhome = os.getenv(ENV_MUXHOME)
-    
-# check various directories/files that must exist
-anuga_folder = join(home, state, scenario_folder, 'anuga')
-topographies_folder = join(anuga_folder, 'topographies')
-polygons_folder = join(anuga_folder, 'polygons')
-boundaries_folder = join(anuga_folder, 'boundaries')
-output_folder = join(anuga_folder, 'outputs')
-gauges_folder = join(anuga_folder, 'gauges')
-meshes_folder = join(anuga_folder, 'meshes')
-event_folder = join(boundaries_folder, str(event_number))
-
-# MUX data files
-# Directory containing the MUX data files to be used with EventSelection.
-mux_data_folder = join(muxhome, 'mux')
-
-#-------------------------------------------------------------------------------
-# Location of input and output data
-#-------------------------------------------------------------------------------
-
-# Convert the user output_comment to a string for run_model.py
-output_comment = ('_'.join([str(x) for x in output_comment if x != user])
-                  + '_' + user)
-
-# The absolute pathname of the all elevation, generated in build_elevation.py
-combined_elevation = join(topographies_folder, combined_elevation_basename)
-
-# The absolute pathname of the mesh, generated in run_model.py
-meshes = join(meshes_folder, scenario_name) + model +'.msh'
-
-# The pathname for the urs order points, used within build_urs_boundary.py
-urs_order = join(boundaries_folder, urs_order_filename)
-
-# The absolute pathname for the landward points of the bounding polygon,
-# Used within run_model.py)
-landward_boundary = join(boundaries_folder, landward_boundary_filename)
-
-# The absolute pathname for the .sts file, generated in build_boundary.py
-event_sts = join(event_folder, scenario_name)
-
-# The absolute pathname for the output folder names
-# Used for build_elevation.py
-output_build = join(output_folder, build_time) + '_' + str(user) 
-# Used for run_model.py
-output_run = join(output_folder, run_time) + output_comment 
-# Used by post processing
-output_run_time = join(output_run, scenario_name) 
-
-# The absolute pathname for the gauges file
-# Used for get_timeseries.py
-gauges = join(gauges_folder, gauges_filename)
-
-# The absolute pathname for the gauges file
-# Used for run_model.py
-building_polygon = join(polygons_folder, building_polygon_filename)
-
-# The absolute pathname for the building file
-# Used for run_building_inundation.py
-building_exposure = join(gauges_folder, building_exposure_filename)
-
-# full path to where MUX files (or meta-files) live
-mux_input = join(event_folder, mux_input_filename)
-
Index: /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/project.py.template
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/project.py.template	(revision 6905)
+++ /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/project.py.template	(revision 6905)
@@ -0,0 +1,257 @@
+"""
+This file contains all your file and directory definitions 
+for elevation, meshes and outputs.
+"""
+
+import os
+from anuga.utilities.system_tools import get_user_name, get_host_name
+from time import localtime, strftime, gmtime
+from os.path import join, exists
+
+
+#------------------------------------------------------------------------------
+# Directory setup
+#------------------------------------------------------------------------------
+
+# this section needs to be updated to reflect the modelled community.
+# Note, the user needs to set up the directory system accordingly
+state = 'thailand'
+scenario_name = 'patong'
+scenario_folder = 'patong_tsunami_scenario'
+
+#------------------------------------------------------------------------------
+# Initial Conditions
+#------------------------------------------------------------------------------
+
+# Model specific parameters.
+# One or all can be changed each time the run_model script is executed
+tide = 0.8              # difference between MSL and HAT
+zone = 47               # specify zone of model
+model = 'small'         # different size model 'small' or 'large'
+event_number = 'mux_' + model    # the event number or the mux file name
+alpha = 0.1             # smoothing parameter for mesh
+friction = 0.01         # manning's friction coefficient
+starttime = 0           # start time for simulation
+finaltime = 15000       # final time for simulation
+
+use_buildings = True
+setup = '#!SETUP!#'         # This can be one of three values
+                        #    trial - coarsest mesh, fast
+                        #    basic - coarse mesh
+                        #    final - fine mesh, slowest
+
+#------------------------------------------------------------------------------
+# Output filename
+#
+# Your output filename should be unique between different runs on different
+# data.
+# The list of items below will be used to create a file in your output
+# directory.
+# Your user name and time+date will be automatically added.  For example,
+#     [setup, tide, event_number]
+# will result in a filename like
+#     20090212_091046_run_final_0_27283_rwilson
+#------------------------------------------------------------------------------
+
+output_comment = [setup, tide, event_number, 'final']
+
+#------------------------------------------------------------------------------
+# Input Data
+#------------------------------------------------------------------------------
+
+# ELEVATION DATA
+# Used in build_elevation.py
+# Format for ascii grids, as produced in ArcGIS + a projection file
+ascii_grid_filenames = []
+
+# Format for point is x,y,elevation (with header)
+point_filenames = ['patong_10m_grid_msl_Project.txt',    # 10m main grid
+                   'patong_10m_small_grid_for_anuga_sub_Project.txt', # 10m saddle
+                   'patong_bay_1s_grid_Project.txt',   # 1s grid
+                   'andaman_3s_grid_Clip2_Project.txt'] #3s grid
+
+### Add csv header list to all files in point_filenames
+##headerlist = ['x', 'y', 'elevation'] 
+##for f in point_filenames:
+##    add_csv_header(join(topographies_folder, f), headerlist)
+
+extent_polygon_filenames = ['patong_10m.txt',
+                            'saddle_10m.txt',
+                            'patong_1s.txt']
+
+
+# BOUNDING POLYGON - for data clipping and estimate of triangles in mesh
+# Used in build_elevation.py
+# Format for points easting,northing (no header)
+bounding_polygon_filename = 'bounding_polygon_'+ model + '.csv'
+bounding_polygon_maxarea = 100000
+
+# INTERIOR REGIONS -  for designing the mesh
+# Used in run_model.py
+# Format for points easting,northing (no header)                    
+interior_regions_data = [['inundation_area.csv', 75],
+                         ['aoi.csv', 200],
+                         ['aos.csv', 900],
+                         ['sw_coast_original.csv', 7000],
+                         ['building_main.csv', 20],
+                         ['building_main_small.csv', 20],
+                         ['building_main_south.csv', 20],
+                         ['building_saddle.csv', 20]]
+
+
+# LAND - used to set the initial stage/water to be offcoast only
+# Used in run_model.py.  Format for points easting,northing (no header)
+land_initial_conditions_filename = [['initial_conditions_' + model +'.csv', 0]]
+
+# GAUGES - for creating timeseries at a specific point
+# Used in get_timeseries.py.  
+# Format easting,northing,name,elevation (with header)
+gauges_filename = 'gauges.csv'
+
+# BUILDINGS POLYOGN - for elevation of buildings
+# Used in run_model.py
+# Format easting,northing,id,floor (with header)
+building_polygon_filename = 'buildings.csv' 
+
+
+# BUILDINGS EXPOSURE - for identifying inundated houses
+# Used in run_building_inundation.py
+# Format latitude,longitude etc (geographic)
+building_exposure_filename = 'busselton_res_clip.csv' # from NEXIS
+
+# BOUNDING POLYGON - used in build_boundary.py and run_model.py respectively
+# NOTE: when files are put together the points must be in sequence
+# For ease go clockwise!
+# Check the run_model.py for boundary_tags
+
+# Thinned ordering file from Hazard Map (geographic)
+# Format is index,latitude,longitude (with header)
+urs_order_filename = 'urs_order_'+ model +'.csv'
+
+# Landward bounding points
+# Format easting,northing (no header)
+landward_boundary_filename = 'landward_boundary_'+ model +'.csv'
+
+# MUX input filename.
+# If a meta-file from EventSelection is used, set 'multi-mux' to True.
+# If a single MUX stem filename (*.grd) is used, set 'multi-mux' to False.
+mux_input_filename = event_number # to be found in event_folder
+                                    # (ie boundaries/event_number/)
+multi_mux = False
+##mux_input_filename = 'event.list'
+##multi_mux = True
+
+#------------------------------------------------------------------------------
+# Clipping regions for export to asc and regions for clipping data
+# Final inundation maps should only be created in regions of the finest mesh
+#------------------------------------------------------------------------------
+
+#CBD extract ascii grid - coordinates from patong_1s extent
+xminCBD = 417445.1119
+xmaxCBD = 425601.7881
+yminCBD = 870663.4547
+ymaxCBD = 876965.3856
+
+
+################################################################################
+################################################################################
+####         NOTE: NOTHING WOULD NORMALLY CHANGE BELOW THIS POINT.          ####
+################################################################################
+################################################################################
+
+# Get system user and host names.
+# These values can be used to distinguish between two similar runs by two
+# different users or runs by the same user on two different machines.
+user = get_user_name()
+host = get_host_name()
+
+# Environment variable names.
+# The inundation directory, not the data directory.
+ENV_INUNDATIONHOME = 'INUNDATIONHOME'
+
+# Path to MUX data
+ENV_MUXHOME = 'MUXHOME'
+
+#-------------------------------------------------------------------------------
+# Output Elevation Data
+#-------------------------------------------------------------------------------
+
+# Output filename for elevation
+# this is a combination of all the data generated in build_elevation.py
+combined_elevation_basename = scenario_name + '_combined_elevation_' + model
+
+#-------------------------------------------------------------------------------
+# Directory Structure
+#-------------------------------------------------------------------------------
+
+# determines time for setting up output directories
+time = strftime('%Y%m%d_%H%M%S', localtime()) 
+gtime = strftime('%Y%m%d_%H%M%S', gmtime()) 
+build_time = time + '_build_' + model
+run_time = time + '_run_'
+
+# create paths generated from environment variables.
+home = join(os.getenv(ENV_INUNDATIONHOME), 'data') # Absolute path for data folder
+muxhome = os.getenv(ENV_MUXHOME)
+    
+# check various directories/files that must exist
+anuga_folder = join(home, state, scenario_folder, 'anuga')
+topographies_folder = join(anuga_folder, 'topographies')
+polygons_folder = join(anuga_folder, 'polygons')
+boundaries_folder = join(anuga_folder, 'boundaries')
+output_folder = join(anuga_folder, 'outputs')
+gauges_folder = join(anuga_folder, 'gauges')
+meshes_folder = join(anuga_folder, 'meshes')
+event_folder = join(boundaries_folder, str(event_number))
+
+# MUX data files
+# Directory containing the MUX data files to be used with EventSelection.
+mux_data_folder = join(muxhome, 'mux')
+
+#------------------------------------------------------------------------------
+# Location of input and output data
+#------------------------------------------------------------------------------
+
+# Convert the user output_comment to a string for run_model.py
+output_comment = ('_'.join([str(x) for x in output_comment if x != user])
+                  + '_' + user)
+
+# The absolute pathname of the all elevation, generated in build_elevation.py
+combined_elevation = join(topographies_folder, combined_elevation_basename)
+
+# The absolute pathname of the mesh, generated in run_model.py
+meshes = join(meshes_folder, scenario_name) + model +'.msh'
+
+# The pathname for the urs order points, used within build_urs_boundary.py
+urs_order = join(boundaries_folder, urs_order_filename)
+
+# The absolute pathname for the landward points of the bounding polygon,
+# Used within run_model.py)
+landward_boundary = join(boundaries_folder, landward_boundary_filename)
+
+# The absolute pathname for the .sts file, generated in build_boundary.py
+event_sts = join(event_folder, scenario_name)
+
+# The absolute pathname for the output folder names
+# Used for build_elevation.py
+output_build = join(output_folder, build_time) + '_' + str(user) 
+# Used for run_model.py
+output_run = join(output_folder, run_time) + output_comment 
+# Used by post processing
+output_run_time = join(output_run, scenario_name) 
+
+# The absolute pathname for the gauges file
+# Used for get_timeseries.py
+gauges = join(gauges_folder, gauges_filename)
+
+# The absolute pathname for the gauges file
+# Used for run_model.py
+building_polygon = join(polygons_folder, building_polygon_filename)
+
+# The absolute pathname for the building file
+# Used for run_building_inundation.py
+building_exposure = join(gauges_folder, building_exposure_filename)
+
+# full path to where MUX files (or meta-files) live
+mux_input = join(event_folder, mux_input_filename)
+
Index: /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/run_model.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/run_model.py	(revision 6904)
+++ /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/run_model.py	(revision 6905)
@@ -37,5 +37,5 @@
 from anuga.interface import create_sts_boundary
 from anuga.interface import csv2building_polygons
-from anuga.lib.file_length.file_length import file_length
+from anuga.utilities.system_tools import file_length
 
 from anuga.shallow_water.data_manager import start_screen_catcher
@@ -56,8 +56,13 @@
 #-------------------------------------------------------------------------------
 
-copy_code_files(project.output_run, __file__, 
-                os.path.join(os.path.dirname(project.__file__),
-                             project.__name__+'.py'))
-start_screen_catcher(project.output_run, 0, 1)
+copy_code_files(project.output_run,
+                [__file__, 
+                 os.path.join(os.path.dirname(project.__file__),
+                              project.__name__+'.py'),
+                 os.path.join(os.path.dirname(project.__file__),
+                              'setup_model.py')],
+                verbose=True
+               )
+#start_screen_catcher(project.output_run, 0, 1)
 
 #-------------------------------------------------------------------------------
@@ -138,5 +143,5 @@
 if project.use_buildings:
     # Add buildings from file
-    log.critical('Reading building polygons'    )
+    log.critical('Reading building polygons')
     building_polygons, building_heights = csv2building_polygons(project.building_polygon)
     #clipping_polygons=project.building_area_polygons)
@@ -155,4 +160,5 @@
         return buildings
 
+    log.critical('Creating %d building polygons' % len(building_polygons))
     buildings = cache(create_polygon_function,
                       building_polygons,
@@ -175,5 +181,4 @@
 Br = Reflective_boundary(domain)
 Bs = Transmissive_stage_zero_momentum_boundary(domain)
-#Bs = Dirichlet_boundary([project.tide, 0, 0])
 Bf = Field_boundary(project.event_sts+'.sts',
                     domain,
Index: /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate.py	(revision 6905)
+++ /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate.py	(revision 6905)
@@ -0,0 +1,433 @@
+'''
+Automatic verification that the ANUGA code runs the Patong simulation
+and produces the expected output.
+
+Required files are downloaded from the ANUGA servers if they are
+out of date or missing.
+'''
+
+import sys
+import os
+import glob
+import unittest
+import time
+import shutil
+
+from anuga.utilities.system_tools import get_web_file, untar_file, file_length
+import anuga.utilities.log as log
+
+
+# sourceforge download mirror hosts (must end with '/')
+# try these in turn for each file
+## NOTE: It would be more reliable if we could somehow 'poll' Sourceforge
+##       for a list of mirrors instead of hard-coding a list here.  That may
+##       be too difficult, as we only get the chance to select a mirror when
+##       actually downloading a file.
+MIRRORS = ['http://transact.dl.sourceforge.net/sourceforge/anuga/',       # au
+           'http://voxel.dl.sourceforge.net/sourceforge/anuga/',          # us
+           'http://superb-west.dl.sourceforge.net/sourceforge/anuga/',    # us
+           'http://jaist.dl.sourceforge.net/sourceforge/anuga/',          # jp
+           'http://dfn.dl.sourceforge.net/sourceforge/anuga/'             # de
+          ]
+##MIRRORS = ['http://10.7.64.243/patong_validation_data/']       # local linux box
+
+# URL to hand-get data files, if required
+DATA_FILES_URL = 'http://sourceforge.net/project/showfiles.php?group_id=172848'
+
+# sequence of mandatory local data objects
+Mandatory_Data_Objects = ('data.tgz',)
+
+# sequence of optional local data objects.
+# these names must be of the form <scene>.sww.<type>.tgz
+# as code below depends upon it.
+Optional_Data_Objects = ('patong.sww.TRIAL.tgz',
+                         'patong.sww.BASIC.tgz',
+                         'patong.sww.FINAL.tgz'
+                        )
+
+# path to the local data directory
+Local_Data_Directory = 'local_data'
+
+# path to the remote data directory
+Remote_Data_Directory = 'remote_data'
+
+# name of stdout catch file for runmodel.py
+RUNMODEL_STDOUT = 'runmodel.stdout'
+
+# text at start of 'output dir' line in RUNMODEL_STDOUT file
+OUTDIR_PREFIX = 'Make directory '
+
+# Name of SWW file produced by simulation
+OUTPUT_SWW = 'patong.sww'
+
+
+def setup():
+    '''Prepare for the validation run.
+
+    Check we have required data set in project.py.
+    '''
+   
+    pass
+
+
+def refresh_local_data(data_objects, target_dir, mirrors):
+    '''Update local data objects from the server.
+
+    data_objects:   list of files to refresh
+    target_dir:     directory in which to put files
+    mirrors:        list of mirror sites to use
+    
+    Each file has an associated *.digest file used to decide
+    if the local file needs refreshing.
+    
+    Return True if all went well, else False.
+    '''
+
+    # decision function to decide if a file contains HTML
+    def is_html(filename):
+        '''Decide if given file contains HTML.'''
+        
+        fd = open(filename)
+        data = fd.read(1024)
+        fd.close()
+
+        if 'DOCTYPE' in data:
+            return False
+        
+        return True
+
+    
+    # local function to get remote file from one of mirrors
+    def get_remote_from_mirrors(remote, local, auth, mirrors):
+        '''Get 'remote' from one of 'mirrors', put in 'local'.'''
+
+        # Get a unique date+time string to defeat caching.  The idea is to add
+        # this to the end of any URL so proxy sees a different request.
+        cache_defeat = '?' + time.strftime('%Y%m%d%H%M%S')
+
+        # try each mirror when getting file
+        for mirror in mirrors:
+            log.debug('Fetching remote file %s from mirror %s'
+                      % (remote, mirror))
+
+            remote_url = mirror + remote + cache_defeat
+            (result, auth) = get_web_file(remote_url, local, auth=auth)
+            if result and is_html(local)==False:
+                log.debug('Success fetching file %s' % remote_url)
+                return (True, auth)
+
+        return (False, auth)            
+                
+
+    # local function to compare contents of two files
+    def files_same(file_a, file_b):
+        '''Compare two files to see if contents are the same.'''
+        
+        fd = open(file_a, 'r')
+        data_a = fd.read()
+        fd.close()
+
+        fd = open(file_b, 'r')
+        data_b = fd.read()
+        fd.close()
+
+        return data_a == data_b
+
+        
+    # local function to update one data object
+    def refresh_object(obj, auth, mirrors):
+        '''Update object 'obj' using authentication tuple 'auth'.
+        
+        Return (True, <updated_auth>) if all went well,
+        else (False, <updated_auth>).
+        '''
+
+        # create local and remote file paths.
+        obj_digest = obj + '.digest'
+        
+        remote_file = os.path.join(Remote_Data_Directory, obj)
+        remote_digest = remote_file + '.digest'
+        
+        local_file = os.path.join(Local_Data_Directory, obj)
+        local_digest = local_file + '.digest'
+        
+        # see if missing either digest or object .tgz
+        if not os.path.exists(local_digest) or not os.path.exists(local_file):
+            # no digest or no object, download both digest and object
+            (res, auth) = get_remote_from_mirrors(obj_digest, local_digest, auth, mirrors)
+            if res:
+                (res, auth) = get_remote_from_mirrors(obj, local_file, auth, mirrors)
+        else:
+            # download object digest to remote data directory
+            (res, auth) = get_remote_from_mirrors(obj_digest, remote_digest, auth, mirrors)
+            if res:
+                if not files_same(local_data_digest, remote_data_digest):
+                    # digests differ, refresh object
+                    log.info('Local file %s is out of date, refreshing ...' % obj)
+                    shutil.move(remote_digest, local_digest)
+                    (res, auth) = get_remote_from_mirrors(obj, local_file, auth, mirrors)
+
+        return (res, auth)
+
+    # create local data directory if required
+    log.debug('Creating local directory: %s' % Local_Data_Directory)
+    if not os.path.exists(Local_Data_Directory):
+        os.mkdir(Local_Data_Directory)
+
+    # clean out remote data copy directory
+    log.debug('Cleaning remote directory: %s' % Remote_Data_Directory)
+    shutil.rmtree(Remote_Data_Directory, ignore_errors=True)
+    os.mkdir(Remote_Data_Directory)
+
+    # success, refresh local files
+    auth = None
+    result = True
+    for data_object in data_objects:
+        log.info("Refreshing file '%s'" % data_object)
+        log.debug('refresh_local_data: getting %s from mirrors, auth=%s'
+                  % (data_object, str(auth)))
+        (res, auth) = refresh_object(data_object, auth, mirrors)
+        log.debug('refresh_local_data: returned (res,auth)=%s,%s'
+                  % (str(res), str(auth)))
+        if res == False:
+            log.info('Refresh of file %s failed.' % data_object)
+            result = False
+
+    if result:
+        log.info('Local data has been refreshed.')
+    else:
+        log.info('Local data has been refreshed, with one or more errors.')
+    return result
+
+
+def can_we_run():
+    '''Decide if we can run with the files we have.
+    
+    Return True if we *can* run, else False.
+
+    Tell user what is happening first, then untar files.
+    '''
+
+    log.critical('Checking if you have the required files to run:')
+
+    # get max width of object name string
+    max_width = 0
+    for obj in Mandatory_Data_Objects:
+        max_width = max(len(obj), max_width)
+    for obj in Optional_Data_Objects:
+        max_width = max(len(obj), max_width)
+
+    # if we don't have *all* mandatory object, can't run
+    have_mandatory_files = True
+    for obj in Mandatory_Data_Objects:
+        obj_path = os.path.join(Local_Data_Directory, obj)
+        if os.path.exists(obj_path):
+            log.info('\t%s  found' % obj.ljust(max_width))
+        else:
+            log.info('\t%s  MISSING AND REQUIRED!' % obj.ljust(max_width))
+            have_mandatory_files = False
+
+    # at least *one* of these must exist
+    have_optional_files = False
+    for obj in Optional_Data_Objects:
+        obj_path = os.path.join(Local_Data_Directory, obj)
+        if os.path.exists(obj_path):
+            have_optional_files = True
+            log.info('\t%s  found' % obj.ljust(max_width))
+        else:
+            log.info('\t%s  MISSING!' % obj.ljust(max_width))
+
+    if not have_mandatory_files or not have_optional_files:
+        log.critical('You must obtain the missing files before you can run '
+                     'this validation.')
+        return False
+
+    log.critical('You have the required files.')
+
+    return True
+
+
+def set_environment():
+    # modify environment so we use the local data
+    new_inundationhome = os.path.join(Local_Data_Directory, '')
+    os.environ['INUNDATIONHOME'] = new_inundationhome
+    new_muxhome = os.path.join(Local_Data_Directory, 'data')
+    os.environ['MUXHOME'] = new_muxhome
+
+
+def run_simulation(vtype, sim_obj):
+    '''Run a simulation.
+
+    Returns True if all went well, else False.
+    '''
+    
+    # untar the object
+    tar_path = os.path.join(Local_Data_Directory, sim_obj)
+    log.info('Untarring %s in directory %s ...'
+             % (tar_path, Local_Data_Directory))
+    untar_file(tar_path, target_dir=Local_Data_Directory)
+
+    # modify project.py template
+    fd = open('project.py.template', 'r')
+    project = fd.readlines()
+    fd.close()
+
+    new_project = []
+    for line in project:
+        new_project.append(line.replace('#!SETUP!#', vtype.lower()))
+            
+    fd = open('project.py', 'w')
+    fd.write(''.join(new_project))
+    fd.close()
+    
+    # import new project.py
+    import project
+
+    # run the simulation, produce SWW file
+    cmd = 'python run_model.py > %s' % RUNMODEL_STDOUT
+    log.debug("run_simulation: doing '%s'" % cmd)
+    res = os.system(cmd)
+    log.debug("run_simulation: res=%d" % res)
+
+    # 'unimport' project.py
+    del project
+
+    # check result
+    if res != 0:
+        log.critical('Simulation failed, check log')
+
+    return res == 0
+
+def check_that_output_is_as_expected(expected_sww, valid_sww):
+    '''Check that validation output is as required.'''
+
+    # get path to expected SWW file
+    log.critical('Checking that simulation results are as expected ...')
+    local_sww = os.path.join(Local_Data_Directory, valid_sww)
+
+    # get output directory from stdout capture file
+    try:
+        fd = open(RUNMODEL_STDOUT, 'r')
+    except IOError, e:
+        log.critical("Can't open catch file '%s': %s"
+                     % (RUNMODEL_STDOUT, str(e)))
+        return 1
+    lines = fd.readlines()
+    fd.close
+
+    output_directory = None
+    for line in lines:
+        if line.startswith(OUTDIR_PREFIX):
+            output_directory = line.replace(OUTDIR_PREFIX, '', 1)
+            output_directory = output_directory.strip('\n')
+            break
+    if output_directory is None:
+        log.critical("Couldn't find line starting with '%s' in file '%s'"
+                     % (OUTDIR_PREFIX, RUNMODEL_STDOUT))
+        return 1
+
+    log.debug('check_that_output_is_as_expected: output_directory=%s'
+              % output_directory)
+    
+    # compare SWW files here and there
+    new_output_sww = os.path.join(output_directory, expected_sww)
+    cmd = 'python cmpsww.py %s %s > cmpsww.stdout' % (local_sww, new_output_sww)
+    log.debug("check_that_output_is_as_expected: doing '%s'" % cmd)
+    res = os.system(cmd)
+    log.debug("check_that_output_is_as_expected: res=%d" % res)
+    if res == 0:
+        log.info('Simulation results are as expected.')
+    else:
+        log.critical('Simulation results are NOT as expected.')
+        fd = open('cmpsww.stdout', 'r')
+        cmp_error = fd.readlines()
+        fd.close()
+        log.critical('\n' + ''.join(cmp_error))
+
+
+def teardown():
+    '''Clean up after validation run.'''
+
+    log.debug('teardown: called')
+    
+##    # clear all data objects from local data directory
+##    for data_object in Local_Data_Objects:
+##        obj_path = os.path.join(Local_Data_Directory, data_object)
+##        if os.path.isfile(obj_path):
+##            os.remove(obj_path)
+##        else:
+##            shutil.rmtree(obj_path, ignore_errors=True)
+
+    # remove remote directory and stdout capture file
+    shutil.rmtree(Remote_Data_Directory, ignore_errors=True)
+    try:
+        os.remove(RUNMODEL_STDOUT)
+    except OSError:
+        pass
+            
+
+################################################################################
+# Mainline - run the simulation, check output.
+################################################################################
+
+# set logging levels
+log.console_logging_level = log.INFO
+log.log_logging_level = log.DEBUG
+setup()
+
+# prepare user for what is about to happen
+
+msg = '''
+This validation requires a working internet connection to refresh it's files.
+You may still run this validation without an internet connection if you have the
+required files.
+
+If you are behind a proxy server you will need to supply your proxy details
+such as the proxy server address and your proxy username and password.  These
+can be defined in one or more of the environment variables:
+    HTTP_PROXY
+    PROXY_USERNAME
+    PROXY_PASSWORD
+if you wish.  If not supplied in environment variables you will be prompted for
+the information.
+'''
+
+log.critical(msg)
+
+# make sure local data is up to date
+all_objects = Mandatory_Data_Objects + Optional_Data_Objects
+if not refresh_local_data(all_objects, Local_Data_Directory, MIRRORS):
+    if not can_we_run():
+        log.critical("Can't refresh via the internet and you don't have the "
+                     "required files.")
+        log.critical('Terminating the validation.')
+        log.critical('')
+        log.critical('If you get the missing files from %s' % DATA_FILES_URL)
+        log.critical('then you can try to run the validation again.  Put the '
+                     'files into the directory')
+        log.critical("%s." % Local_Data_Directory)
+        sys.exit(10)
+
+# now untar mandatory objects
+for obj in Mandatory_Data_Objects:
+    tar_path = os.path.join(Local_Data_Directory, obj)
+    log.info('Untarring %s in directory %s ...'
+             % (tar_path, Local_Data_Directory))
+    untar_file(tar_path, target_dir=Local_Data_Directory)
+
+# set required environment variables
+set_environment()
+
+# now run what simulations we can and check output is as expected
+for odo in Optional_Data_Objects:
+    (_, vtype, _) = odo.rsplit('.', 2)
+    vtype = vtype.lower()
+    log.critical("Running Patong '%s' validation ..." % vtype)
+    if run_simulation(vtype, odo):
+        # get SWW names expected and valid, check 'equal'
+        (valid_sww, _) = odo.rsplit('.', 1)
+        (expected_sww, _) = valid_sww.rsplit('.', 1)
+        check_that_output_is_as_expected(expected_sww, valid_sww)
+
+# clean up
+teardown()
Index: anches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate_patong.py
===================================================================
--- /branches/numpy_anuga_validation/automated_validation_tests/patong_beach_validation/validate_patong.py	(revision 6904)
+++ 	(revision )
@@ -1,320 +1,0 @@
-'''
-Automatic verification that the ANUGA code runs the Patong simulation
-and produces the expected output.
-
-Required files are downloaded from the ANUGA servers if they are
-out of date or missing.
-'''
-
-import sys
-import os
-import glob
-import unittest
-import time
-import shutil
-
-from anuga.utilities.system_tools import get_web_file, untar_file
-import anuga.utilities.log as log
-
-
-# base URL for the remote ANUGA data
-PATONG_HOST = 'http://10.7.64.243/'
-PATONG_DATA_URL = PATONG_HOST + 'patong_validation_data/'
-
-# path to the local data directory
-Local_Data_Directory = os.path.join('.', 'local_data')
-
-# path to the remote data directory
-Remote_Data_Directory = os.path.join('.', 'remote_data')
-
-# sequence of required local data objects
-# first is always the SWW file to be compared
-Local_Data_Objects = ('patong.sww', 'data')
-
-# name of stdout catch file for runmodel.py
-RUNMODEL_STDOUT = 'runmodel.stdout'
-
-# text at start of 'output dir' line in RUNMODEL_STDOUT file
-OUTDIR_PREFIX = 'Make directory '
-
-# Name of SWW file produced by simulationvalidate_patong.py
-OUTPUT_SWW = 'patong.sww'
-
-
-def setup():
-    '''Prepare for the validation run.
-
-    Check we have required data set in project.py.
-    '''
-   
-    pass
-
-
-def update_local_data():
-    '''Update local data objects from the server.
-
-    These are expected to be *.tgz files/directories.
-    Return True if all went well, else False.
-    '''
-    
-    # local function to update one data object
-    def update_object(obj, auth):
-        '''Update object 'obj' using authentication tuple 'auth'.
-        
-        Return updated auth object (success) or False (failure).
-        '''
-
-        log.info("Refreshing local object '%s'" % obj)
-
-        # Get a unique date+time string to defeat caching.  The idea is to add
-        # this to the end of any URL so proxy sees a different request.
-        cache_defeat = '?' + time.strftime('%Y%m%d%H%M%S')
-
-        # create local and remote paths, URLs, etc.
-        remote_path = os.path.join(Remote_Data_Directory, obj)
-        remote_digest = remote_path + '.tgz.digest'
-        
-        local_path = os.path.join(Local_Data_Directory, obj)
-        local_file = local_path + '.tgz'
-        local_digest = local_file + '.digest'
-        
-        object_url = PATONG_DATA_URL + obj + '.tgz'
-        digest_url = object_url + '.digest'
-
-        # see if missing either digest or object .tgz
-        if not os.path.exists(local_digest) or not os.path.exists(local_file):
-            # no digest or no object, download both digest and object
-            log.info('Fetching remote file %s' % digest_url)
-            auth = get_web_file(digest_url+cache_defeat,
-                                local_digest, auth=auth)
-            if auth == False:
-                log.info("Couldn't fetch file: %s" % digest_url)
-                return False
-            log.info('Fetching remote file %s' % object_url)
-            auth = get_web_file(object_url+cache_defeat, local_file, auth=auth)
-            if auth == False:
-                return False
-        else:
-            # download object digest to remote data directory
-            log.info('Fetching remote file %s' % digest_url)
-            auth = get_web_file(digest_url+cache_defeat,
-                                remote_digest, auth=auth)
-            if auth == False:
-                return False
-            
-            # compare remote with local digest
-            fd = open(local_digest, 'r')
-            local_data_digest = fd.read()
-            fd.close()
-
-            fd = open(remote_digest, 'r')
-            remote_data_digest = fd.read()
-            fd.close()
-
-            # if digests differ, refresh object
-            if local_data_digest != remote_data_digest:
-                log.info('Local file %s is out of date' % obj)
-                fd = open(local_digest, 'w')
-                fd.write(remote_data_digest)
-                fd.close()
-
-                log.info('Fetching remote file %s' % object_url)
-                auth = get_web_file(object_url+cache_defeat,
-                                    local_file, auth=auth)
-        return auth
-
-    # create local data directory if required
-    log.debug('Creating local directory: %s' % Local_Data_Directory)
-    if not os.path.exists(Local_Data_Directory):
-        os.mkdir(Local_Data_Directory)
-
-    # clean out remote data copy directory
-    log.debug('Cleaning remote directory: %s' % Remote_Data_Directory)
-    shutil.rmtree(Remote_Data_Directory, ignore_errors=True)
-    os.mkdir(Remote_Data_Directory)
-
-    # refresh local files
-    auth = None
-    for data_object in Local_Data_Objects:
-        log.debug('Trying to update: %s' % data_object)
-        auth = update_object(data_object, auth)
-        if auth == False:
-            log.debug('Failed fetching %s, returning False' % data_object)
-            return False
-
-    log.info('Local data has been refreshed.')
-    return True
-
-
-def can_we_run():
-    '''Decide if we can run with the files we have.
-    
-    Return True if we *can* run, else False.
-
-    Tell user what is happening first, then untar files.
-    '''
-
-    log.critical('Checking if you have the required files to run locally ...')
-
-    have_files = True
-    max_width = 0
-    for obj in Local_Data_Objects:
-        max_width = max(len(obj), max_width)
-
-    for obj in Local_Data_Objects:
-        # if we don't have required object, can't run
-        obj_path = os.path.join(Local_Data_Directory, obj+'.tgz')
-        if os.path.exists(obj_path):
-            log.info('%s  found' % obj.ljust(max_width))
-        else:
-            log.info('%s  MISSING!' % obj.ljust(max_width))
-            have_files = False
-
-    if not have_files:
-        log.critical('You must obtain the missing files before you can run '
-                     'this validation.')
-        return False
-
-    log.critical('You have the required files.')
-
-    return True
-
-
-def run_simulation():
-    '''Run the Patong simulation.'''
-    
-##    # now untar file/directory objects
-##    for data_object in Local_Data_Objects:
-##        tar_path = os.path.join(Local_Data_Directory, data_object+'.tgz')
-##        log.info('Untarring %s in directory %s ...'
-##                 % (tar_path, Local_Data_Directory))
-##        untar_file(tar_path, target_dir=Local_Data_Directory)
-
-    # modify environment so we use the local data
-    new_inundationhome = os.path.join(Local_Data_Directory, '')
-    os.environ['INUNDATIONHOME'] = new_inundationhome
-    new_muxhome = os.path.join(Local_Data_Directory, 'data')
-    os.environ['MUXHOME'] = new_muxhome
-
-    # We import here, _after_ environment variables are set
-    import project
-
-    # run the simulation, produce SWW file
-    log.critical('Running Patong simulation ...')
-    cmd = 'python run_model.py > %s' % RUNMODEL_STDOUT
-    res = os.system(cmd)
-    assert res == 0
-
-def check_that_output_is_as_expected():
-    '''Check that validation output is as required.'''
-
-    # get path to expected SWW file
-    log.critical('Checking that simulation results are as expected ...')
-    local_sww = os.path.join(Local_Data_Directory, Local_Data_Objects[0])
-
-    # get output directory from stdout capture file
-    try:
-        fd = open(RUNMODEL_STDOUT, 'r')
-    except IOError, e:
-        log.critical("Can't open catch file '%s': %s"
-                     % (RUNMODEL_STDOUT, str(e)))
-        return 1
-    lines = fd.readlines()
-    fd.close
-
-    output_directory = None
-    for line in lines:
-        if line.startswith(OUTDIR_PREFIX):
-            output_directory = line.replace(OUTDIR_PREFIX, '', 1)
-            output_directory = output_directory.strip('\n')
-            break
-    if output_directory is None:
-        log.critical("Couldn't find line starting with '%s' in file '%s'"
-                     % (OUTDIR_PREFIX, RUNMODEL_STDOUT))
-        return 1
-
-    # compare SWW files here and there
-    new_output_sww = os.path.join(output_directory, OUTPUT_SWW)
-    cmd = 'python cmpsww.py %s %s > cmpsww.stdout' % (local_sww, new_output_sww)
-    res = os.system(cmd)
-    if res == 0:
-        log.info('Simulation results are as expected.')
-    else:
-        log.critical('Simulation results are NOT as expected.')
-        fd = open('cmpsww.stdout', 'r')
-        cmp_error = fd.readlines()
-        fd.close()
-        log.critical('\n' + ''.join(cmp_error))
-
-
-def teardown():
-    '''Clean up after validation run.'''
-    
-    # clear all data objects from local data directory
-    for data_object in Local_Data_Objects:
-        obj_path = os.path.join(Local_Data_Directory, data_object)
-        if os.path.isfile(obj_path):
-            os.remove(obj_path)
-        else:
-            shutil.rmtree(obj_path, ignore_errors=True)
-
-    # remove remote directory and stdout capture file
-    shutil.rmtree(Remote_Data_Directory, ignore_errors=True)
-    try:
-        os.remove(RUNMODEL_STDOUT)
-    except OSError:
-        pass
-            
-
-################################################################################
-# Mainline - run the simulation, check output.
-################################################################################
-
-# set logging levels
-log.console_logging_level = log.INFO
-setup()
-
-# prepare user for what is about to happen
-log.critical('')
-log.critical('This validation requires a working internet connection to run.')
-log.critical('')
-log.critical('If you are behind a proxy server you will need to supply your '
-             'proxy details')
-log.critical('such as the proxy server address and your proxy username and '
-             'password.  These')
-log.critical('can be defined in one or more of the environment variables:')
-log.critical('\tHTTP_PROXY')
-log.critical('\tPROXY_USERNAME')
-log.critical('\tPROXY_PASSWORD')
-log.critical('if you wish.  If not supplied in environment variables, you '
-             'will be prompted for')
-log.critical('the details.')
-log.critical('')
-log.critical('You may still run this validation without an internet '
-             'connection if you have the')
-log.critical('required files.')
-log.critical('*'*80)
-log.critical('')
-
-# make sure local data is up to date
-if not update_local_data():
-    log.info("Can't update local files over the internet (for some reason).")
-    if not can_we_run():
-        log.critical('')
-        log.critical('*'*80)
-        log.critical("Can't connect via the internet and you don't have the "
-                     "required files.")
-        log.critical('Terminating the validation.')
-        log.critical('')
-        log.critical('If you get the missing files from %s' % PATONG_DATA_URL)
-        log.critical('then you can try to run the validation again.')
-        sys.exit(10)
-
-# run the simulation
-run_simulation()
-
-# check output is as expected
-check_that_output_is_as_expected()
-
-# clean up
-#teardown()
Index: /branches/numpy_anuga_validation/performance_tests/okushiri/run_okushiri_profile.py
===================================================================
--- /branches/numpy_anuga_validation/performance_tests/okushiri/run_okushiri_profile.py	(revision 6904)
+++ /branches/numpy_anuga_validation/performance_tests/okushiri/run_okushiri_profile.py	(revision 6905)
@@ -83,5 +83,5 @@
 t0 = time.time()
 
-s = 'for t in domain.evolve(yieldstep = 0.05, finaltime = 2): domain.write_time()'
+s = 'for t in domain.evolve(yieldstep = 0.05, finaltime = 22.5): domain.write_time()'
 
 import profile, pstats
@@ -93,8 +93,8 @@
 
 S = pstats.Stats(FN)
-s = S.sort_stats('time').print_stats(50)
+s = S.sort_stats('time').print_stats(20)
 #s = S.sort_stats('cumulative').print_stats(30)
 
-s.print_callers()
+#s.print_callers()
 print s
 
Index: /branches/numpy_anuga_validation/performance_tests/okushiri/run_okushiri_profile_fitting.py
===================================================================
--- /branches/numpy_anuga_validation/performance_tests/okushiri/run_okushiri_profile_fitting.py	(revision 6904)
+++ /branches/numpy_anuga_validation/performance_tests/okushiri/run_okushiri_profile_fitting.py	(revision 6905)
@@ -62,2 +62,5 @@
 print s
 
+s.print_callers()
+print s
+
