Index: /anuga_work/production/exmouth_2006/build_exmouth.py
===================================================================
--- /anuga_work/production/exmouth_2006/build_exmouth.py	(revision 4524)
+++ /anuga_work/production/exmouth_2006/build_exmouth.py	(revision 4525)
@@ -81,5 +81,5 @@
 dem2pts(onshore_dir_name, use_cache=True, verbose=True)
 dem2pts(onshore1_dir_name, use_cache=True, verbose=True)
-'''
+
 print'create Geospatial data1 objects from topographies',onshore_dir_name + '.pts'
 G1 = Geospatial_data(file_name = onshore_dir_name + '.pts',verbose=True)
@@ -112,5 +112,5 @@
 G_small.export_points_file(project.combined_small_dir_name + '.txt')
 #G_clipped.export_points_file(project.combined_dir_name + '.xya')
-'''
+
 
 
@@ -123,5 +123,5 @@
 print'export 2'
 G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya')
-
+'''
 
 #-------------------------------------------------------------------------
@@ -136,10 +136,10 @@
 print 'project.boundaries_dir_name',project.boundaries_dir_name
 
-urs_ungridded2sww(boundaries_in_dir_name, project.boundaries_in_dir_name,
+urs_ungridded2sww(boundaries_in_dir_name, boundaries_in_dir_name,
                   verbose=True, mint=4000, maxt=35000, zscale=1)
-
-'''
 
 
 
 
+
+
Index: /anuga_work/production/exmouth_2006/project.py
===================================================================
--- /anuga_work/production/exmouth_2006/project.py	(revision 4524)
+++ /anuga_work/production/exmouth_2006/project.py	(revision 4525)
@@ -30,6 +30,6 @@
 
 #tide = -1.4
-#tide = 0
-tide = 1.4
+tide = 0
+#tide = 1.4
 
 #Maybe will try to make project a class to allow these parameters to be passed in.
@@ -38,5 +38,6 @@
 starttime=3600
 finaltime=25000
-setup='store'
+setup='final'
+extra='exmouth'
 
 if setup =='trial':
@@ -62,5 +63,5 @@
 
 
-dir_comment='_'+setup+'_'+str(tide)+'_'+str(user)
+dir_comment='_'+setup+'_'+str(tide)+'_'+str(extra)+'_'+str(user)
 
 onshore_name = 'DLI' 
@@ -111,7 +112,11 @@
 
 #boundaries locations
-boundaries_name = 'exmouth_3854_17042007'
-
-boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'dampier'+sep+'1_10000'+sep
+#boundaries_name = 'exmouth_3854_17042007' #dampier
+#boundaries_name = 'exmouth_3103_18052007' #exmouth
+boundaries_name = 'exmouth_3859_16052007' #onslow
+
+#boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'dampier'+sep+'1_10000'+sep
+#boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'exmouth'+sep+'1_10000'+sep
+boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'onslow_hedland_broome'+sep+'1_10000'+sep
 boundaries_in_dir_name = boundaries_in_dir + boundaries_name
 boundaries_dir = anuga_dir+'boundaries'+sep
@@ -121,5 +126,6 @@
 output_dir = anuga_dir+'outputs'+sep
 output_build_time_dir = output_dir+build_time+sep
-output_run_time_dir = output_dir +run_time+dir_comment+sep
+#output_run_time_dir = output_dir +run_time+dir_comment+sep
+output_run_time_dir = output_dir +'20070528_061822_run_final_1.4_nbartzis'+sep
 output_run_time_dir_name = output_run_time_dir + scenario_name  #Used by post processing
 
@@ -132,6 +138,6 @@
 community_exmouth = gauges_dir + 'community_exmouth.csv'
 
-buildings_filename = 'Exmouth_res_Project.csv'
-buildings_filename_out = 'Exmouth_res_Project_modified.csv'
+buildings_filename = gauges_dir +'Exmouth_res_Project.csv'
+buildings_filename_out = output_run_time_dir +'Exmouth_res_Project_modified.csv'
 
 ###############################
Index: /anuga_work/production/exmouth_2006/run_exmouth.py
===================================================================
--- /anuga_work/production/exmouth_2006/run_exmouth.py	(revision 4524)
+++ /anuga_work/production/exmouth_2006/run_exmouth.py	(revision 4525)
@@ -37,4 +37,6 @@
 from anuga_parallel.parallel_abstraction import get_processor_name
 from anuga.caching import myhash
+from anuga.damage_modelling.inundation_damage import add_depth_and_momentum2csv, inundation_damage
+
 # Application specific imports
 import project                 # Definition of file names and polygons
@@ -42,8 +44,4 @@
 def run_model(**kwargs):
     
-#    tide = kwargs['tide']
-#    alpha = kwargs['alpha']
-#    friction = kwargs['friction']
-#    time_thinning = kwargs['time_thinning']
     scenario_name = kwargs['aa_scenario_name']
     
@@ -67,5 +65,7 @@
 #    kwargs['bathy_file']=project.combined_small_dir_name + '.txt'
     kwargs['boundary_file']=project.boundaries_in_dir_name + '.sww'
-
+    
+    
+    '''
     print 'output_dir',kwargs['output_dir']
     if myid == 0:
@@ -166,8 +166,9 @@
     domain.set_store_vertices_uniquely(False)
     domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
-    domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
-    print 'domain id', id(domain)
-    domain.beta_h = 0
-    #domain.limit2007 = 1
+    #domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
+    #print 'domain id', id(domain)
+    domain.beta_h = 0 #sets the surface of the triangle to follow the bathy
+    #domain.H0=0.01 #controls the flux limiter (limiter2007)
+    #domain.limit2007 = 1 #minimises creep
 
     #-------------------------------------------------------------------------
@@ -229,6 +230,10 @@
     barrier()
 
-    export_grid(kwargs['aa_scenario_name'], extra_name_out = 'town',
-                quantities = ['elevation','stage'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
+
+    '''
+    print'hello'
+    swwfile = kwargs['output_dir']+kwargs['aa_scenario_name']
+    export_grid(swwfile, extra_name_out = 'town',
+                quantities = ['elevation','stage','speed'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
                 timestep = None,
                 reduction = max,
@@ -244,11 +249,9 @@
                 format = 'asc')
     
-    swwfile = kwargs['output_dir']+kwargs['aa_scenario_name']+'.sww'
     buildings_filename = project.buildings_filename
     buildings_filename_out = project.buildings_filename_out
                 
-    inundation_damage(swwfile, buildings_filename, buildings_filename_out)
-    print '\n Augmented building file written to %s \n' \
-           %buildings_filename_out
+    inundation_damage(swwfile+'.sww', buildings_filename, buildings_filename_out)
+    print '\n Augmented building file written to %s \n' %buildings_filename_out
 
 
Index: /anuga_work/production/onslow_2006/build_onslow.py
===================================================================
--- /anuga_work/production/onslow_2006/build_onslow.py	(revision 4524)
+++ /anuga_work/production/onslow_2006/build_onslow.py	(revision 4525)
@@ -151,7 +151,7 @@
 
 print 'boundaries_in_dir_name',project_urs.boundaries_in_dir_name
-print 'project.boundaries_dir_name',project_urs.boundaries_dir_name
+#print 'project.boundaries_dir_name',project_urs.boundaries_dir_name
 
-urs_ungridded2sww(project_urs.boundaries_in_dir_name, project_urs.boundaries_dir_name,
+urs_ungridded2sww(project_urs.boundaries_in_dir_name, project_urs.boundaries_in_dir_name,
                   verbose=True, mint=5000, maxt=34000, zscale=1)
 
Index: /anuga_work/production/onslow_2006/project_urs.py
===================================================================
--- /anuga_work/production/onslow_2006/project_urs.py	(revision 4524)
+++ /anuga_work/production/onslow_2006/project_urs.py	(revision 4525)
@@ -18,5 +18,5 @@
 host = get_host_name()
 #needed when running using mpirun, mpirun doesn't inherit umask from .bashrc
-umask(002)
+#umask(002)
 
 
@@ -30,17 +30,38 @@
 
 #tide = -1.5
-#tide = 0.0
-tide = 1.5
+tide = 0.0
+#tide = 1.5
 
 #Maybe will try to make project a class to allow these parameters to be passed in.
-res_factor=1
 alpha = 0.1
 friction=0.01
-time_thinning=4
-dir_comment='_final_'+str(tide)+'_'+str(user)
 starttime=3600
-yieldstep=60
 finaltime=25000
- 
+setup='final'
+extra='onslow'
+
+if setup =='trial':
+    print'trial'
+    res_factor=10
+    time_thinning=48
+    yieldstep=240
+if setup =='basic': 
+    print'basic'
+    res_factor=4
+    time_thinning=12
+    yieldstep=120
+if setup =='final': 
+    print'final'
+    res_factor=1
+    time_thinning=1
+    yieldstep=60
+if setup =='store':
+    print'store'
+    res_factor=10
+    time_thinning=48
+    yieldstep=240    
+
+dir_comment='_'+setup+'_'+str(tide)+'_'+str(extra)+'_'+str(user)
+
 #Making assumptions about the location of scenario data
 state = 'western_australia'
@@ -99,10 +120,15 @@
 
 boundaries_source = ''
-boundaries_name = 'onslow_3854_17042007'
+#boundaries_name = 'onslow_3854_17042007' #Dampier gun
+boundaries_name = 'onslow_3859_16052007' #onslow_hedland_broome gun
+#boundaries_name = 'onslow_3103_18052007' #exmouth gun
 
 #boundaries locations
 #boundaries_in_dir = anuga_dir+'boundaries'+sep
-boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'1_10000'+sep
+#boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'1_10000'+sep
+boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'onslow_hedland_broome'+sep+'1_10000'+sep
+#boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'exmouth'+sep+'1_10000'+sep
 boundaries_in_dir_name = boundaries_in_dir + boundaries_name
+
 boundaries_dir = anuga_dir+'boundaries'+sep
 boundaries_dir_name = boundaries_dir + boundaries_name
@@ -111,5 +137,6 @@
 output_dir = anuga_dir+'outputs'+sep
 output_build_time_dir = output_dir+build_time+sep
-output_run_time_dir = output_dir +run_time+dir_comment+sep
+#output_run_time_dir = output_dir +run_time+dir_comment+sep
+output_run_time_dir = output_dir +'20070530_082920_run_final_1.5_nbartzis'+sep
 output_run_time_dir_name = output_run_time_dir + scenario_name  #Used by post processing
 
@@ -126,5 +153,5 @@
 community_scenario = gauges_dir + 'community_onslow.csv'
 buildings_filename = gauges_dir + 'Onslow_res_Project.csv'
-buildings_filename_out = 'Onslow_res_Project_modified.csv'
+buildings_filename_out =output_run_time_dir + 'Onslow_res_Project_modified.csv'
 ###############################
 # Domain definitions
@@ -215,7 +242,7 @@
 
 # region to export
-e_min_area = 300000
-e_max_area = 310000
-n_min_area = 7600000
-n_max_area = 7610000
-
+eastingmin = 300000
+eastingmax = 310000
+northingmin = 7600000
+northingmax = 7610000
+
Index: /anuga_work/production/onslow_2006/run_onslow_urs.py
===================================================================
--- /anuga_work/production/onslow_2006/run_onslow_urs.py	(revision 4524)
+++ /anuga_work/production/onslow_2006/run_onslow_urs.py	(revision 4525)
@@ -30,10 +30,14 @@
 from anuga.shallow_water import Field_boundary
 from Numeric import allclose
+from anuga.shallow_water.data_manager import export_grid
+
 
 from anuga.pmesh.mesh_interface import create_mesh_from_regions
-from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files,store_parameters
+from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files,store_parameters
 from anuga_parallel.parallel_api import distribute, numprocs, myid, barrier
 from anuga_parallel.parallel_abstraction import get_processor_name
 from anuga.caching import myhash
+from anuga.damage_modelling.inundation_damage import add_depth_and_momentum2csv, inundation_damage
+
 # Application specific imports
 import project_urs                 # Definition of file names and polygons
@@ -41,11 +45,5 @@
 def run_model(**kwargs):
     
-    tide = kwargs['tide']
-    alpha = kwargs['alpha']
-    friction = kwargs['friction']
-    time_thinning = kwargs['time_thinning']
     scenario_name = kwargs['aa_scenario_name']
-    
-    
     
     #------------------------------------------------------------------------------
@@ -55,10 +53,10 @@
 
     #copy script must be before screen_catcher
-    print 'tide',tide
+    print 'tide',kwargs['tide']
     kwargs['est_num_trigs']=project_urs.trigs_min
     kwargs['num_cpu']=numprocs
     kwargs['host']=project_urs.host
     kwargs['res_factor']=project_urs.res_factor
-    kwargs['starttime']=project_urs.starttime    
+    kwargs['starttime']=project_urs.starttime
     kwargs['yieldstep']=project_urs.yieldstep
     kwargs['finaltime']=project_urs.finaltime
@@ -66,10 +64,8 @@
     kwargs['output_dir']=project_urs.output_run_time_dir
     kwargs['bathy_file']=project_urs.combined_dir_name + '.pts'
-    kwargs['boundary_file']=project_urs.boundaries_dir_name + '.sww'
-#    kwargs['Completed']=''
-
+#    kwargs['bathy_file']=project_urs.combined_small_dir_name + '.txt'
+    kwargs['boundary_file']=project_urs.boundaries_in_dir_name + '.sww'
+    '''
     print 'output_dir',kwargs['output_dir']
-    
-    print 'myid',myid
     if myid == 0:
         copy_code_files(kwargs['output_dir'],__file__, 
@@ -83,16 +79,9 @@
 
     print "Processor Name:",get_processor_name()
-#    barrier()
-
-    # filenames
-    #boundaries_name = project_urs.boundaries_name
-    meshes_dir_name = project_urs.meshes_dir_name+'.msh'
-    #boundaries_dir_name = project_urs.boundaries_dir_name
-
-#    tide = project_urs.tide
 
     # creates copy of code in output dir
     print 'min triangles', project_urs.trigs_min,
     print 'Note: This is generally about 20% less than the final amount'
+
 
     #--------------------------------------------------------------------------
@@ -102,4 +91,6 @@
     # resolutions (maximal area of per triangle) for each polygon
     #--------------------------------------------------------------------------
+    #IMPORTANT don't cache create_mesh_from_region and Domain(mesh....) as it
+    # causes problems with the ability to cache set quantity which takes alot of times
 
     if myid == 0:
@@ -112,5 +103,5 @@
                              maximum_triangle_area=project_urs.res_poly_all,
                              interior_regions=project_urs.interior_regions,
-                             filename=meshes_dir_name,
+                             filename=project_urs.meshes_dir_name+'.msh',
                              use_cache=False,
                              verbose=True)
@@ -126,15 +117,10 @@
     #domain = cache(Domain, (meshes_dir_name), {'use_cache':True, 'verbose':True}, verbose=True)
     #above don't work
-    domain = Domain(meshes_dir_name, use_cache=False, verbose=True)
-#    print 'domain id', id(domain) 
-#    print 'myhash', myhash(domain)      
+    domain = Domain(project_urs.meshes_dir_name+'.msh', use_cache=False, verbose=True)
        
     print domain.statistics()
-#    domain.
     print 'triangles',len(domain)
     
     kwargs['act_num_trigs']=len(domain)
-#    print len(domain.mesh)
-
 
     #-------------------------------------------------------------------------
@@ -147,8 +133,8 @@
         from polygon import Polygon_function
         #following sets the stage/water to be offcoast only
-        IC = Polygon_function( [(project_urs.poly_mainland, -1.0)], default = tide,
+        IC = Polygon_function( [(project_urs.poly_mainland, -1.0)], default = kwargs['tide'],
                                  geo_reference = domain.geo_reference)
         domain.set_quantity('stage', IC)
-        domain.set_quantity('friction', friction) 
+        domain.set_quantity('friction', kwargs['friction']) 
         
         print 'Start Set quantity'
@@ -158,5 +144,5 @@
                             use_cache = True,
                             verbose = True,
-                            alpha = alpha)
+                            alpha = kwargs['alpha'])
         print 'Finished Set quantity'
     barrier()
@@ -174,5 +160,5 @@
     #------------------------------------------------------
     print 'domain id', id(domain)
-    domain.set_name(scenario_name)
+    domain.set_name(kwargs['aa_scenario_name'])
     domain.set_datadir(kwargs['output_dir'])
     domain.set_default_order(2) # Apply second order scheme
@@ -180,8 +166,8 @@
     domain.set_store_vertices_uniquely(False)
     domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
-    domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
-    domain.beta_h = 0
-    domain.limit2007 = 1
-    domain.H0=0.01
+#    domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
+    domain.beta_h = 0 #sets the surface of the triangle to follow the bathy
+    #domain.H0=0.01 #controls the flux limiter (limiter2007)
+    #domain.limit2007 = 1 #minimises creep
 
     #-------------------------------------------------------------------------
@@ -193,5 +179,5 @@
 
     Bf = Field_boundary(kwargs['boundary_file'],
-                    domain, time_thinning=time_thinning, mean_stage=tide, 
+                    domain, time_thinning=kwargs['time_thinning'], mean_stage=kwargs['tide'], 
                     use_cache=True, verbose=True)
                     
@@ -201,5 +187,5 @@
 
     Br = Reflective_boundary(domain)
-    Bd = Dirichlet_boundary([tide,0,0])
+    Bd = Dirichlet_boundary([kwargs['tide'],0,0])
 
     print'set_boundary'
@@ -218,10 +204,15 @@
     for t in domain.evolve(yieldstep = 240, finaltime = kwargs['starttime']): 
         domain.write_time()
-        domain.write_boundary_statistics(tags = 'ocean')
-
-    for t in domain.evolve(yieldstep = kwargs['yieldstep'], finaltime = kwargs['finaltime']
+        domain.write_boundary_statistics(tags = 'ocean')     
+
+    for t in domain.evolve(yieldstep = kwargs['yieldstep'], finaltime = 21600
                        ,skip_initial_step = True): 
         domain.write_time()
-        domain.write_boundary_statistics(tags = 'ocean')
+        domain.write_boundary_statistics(tags = 'ocean')     
+    
+    for t in domain.evolve(yieldstep = 240, finaltime = kwargs['finaltime']
+                       ,skip_initial_step = True): 
+        domain.write_time()
+        domain.write_boundary_statistics(tags = 'ocean') 
 
     x, y = domain.get_maximum_inundation_location()
@@ -237,4 +228,29 @@
         store_parameters(**kwargs)
     barrier()
+    '''
+    swwfile = kwargs['output_dir']+kwargs['aa_scenario_name']
+    print 'swwfile',swwfile
+    export_grid(swwfile, extra_name_out = 'town',
+                quantities = ['elevation','stage','speed'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
+                timestep = None,
+                reduction = max,
+                cellsize = 25,
+                NODATA_value = -9999,
+                easting_min = project_urs.eastingmin,
+                easting_max = project_urs.eastingmax,
+                northing_min = project_urs.northingmin,
+                northing_max = project_urs.northingmax,
+                verbose = True,
+                origin = None,
+                datum = 'WGS84',
+                format = 'asc')
+    
+    swwfile = kwargs['output_dir']+kwargs['aa_scenario_name']+'.sww'
+    buildings_filename = project_urs.buildings_filename
+    buildings_filename_out = project_urs.buildings_filename_out
+                
+    inundation_damage(swwfile+'.sww', buildings_filename, buildings_filename_out)
+    print '\n Augmented building file written to %s \n' \
+           %buildings_filename_out
 
 
Index: /anuga_work/production/test_dampier_2006/test.py
===================================================================
--- /anuga_work/production/test_dampier_2006/test.py	(revision 4524)
+++ /anuga_work/production/test_dampier_2006/test.py	(revision 4525)
@@ -3,8 +3,10 @@
 import os
 
-import project
+#import project
+#from Numeric import allclose
 from anuga.pmesh.mesh_interface import create_mesh_from_regions
 from anuga.shallow_water import Domain
 from anuga.shallow_water import File_boundary
+from time import localtime, strftime, gmtime
 
 home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
@@ -13,20 +15,37 @@
 state = 'western_australia'
 scenario_name = 'dampier'
-scenario = 'dampier_tsunami_scenario_2006'
+scenario = 'test_dampier'
 an = 'anuga'
 bo = 'boundaries'
+topo = 'topographies'
+out = 'outputs'
 urs = 'urs'
 gridded = '1_10000'
-best_boundary_sww_file = 'o_test_8500_12000.sww'
+#best_boundary_sww_file = 'o_test_8500_12000.sww'
+best_boundary_sww_file = 'o_8500_12000_no_zone.sww'
+
+time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir
+gtime = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir
+run_time = time+'_run'
+print 'gtime: ', gtime
+print 'time: ', time
+
 
 mesh_filename = 'small.tsh' # this will be local
-best_boundary_sww = os.path.join(data,state,scenario_name,
-                                 scenario,an,bo,best_boundary_sww_file)
+best_boundary_sww = os.path.join(home,data,state,scenario,an,bo,best_boundary_sww_file)
+#J:\inundation\data\western_australia\dampier_tsunami_scenario_2006\anuga\topographies
+                                 
+elevation_file = 'dampier_combined_elevation_smallest.txt'
+smallest_elevation= os.path.join(home,data,state,scenario,an,topo,elevation_file)
+
+output= os.path.join(home,data,state,scenario,an,out,run_time)
 
 #pro_instance = project.Project([data,state,scenario_name],
 #                                       outputdir_name=outputdir_name)
 
-poly_all = [[250000,7660000],[280000,7660000],
-                             [280000,7630000]]
+#poly_all = [[250000,7660000],[280000,7660000], [280000,7630000]]
+poly_all = [[469000,7760000],[470000,7758000],[468000,7758000]]
+
+print 'create mesh'
 create_mesh_from_regions(poly_all,
                              boundary_tags={'back': [0,1,2]},
@@ -38,14 +57,35 @@
 print domain.statistics()
 
-domain.set_quantity('stage', 0.0)
+domain.set_quantity('stage', 2.4)
 domain.set_quantity('friction', 0.01)
+domain.set_name(scenario_name)
+domain.set_datadir(output)
+
+print 'set elevation',smallest_elevation
+
 domain.set_quantity('elevation', 
-#                    filename = project.combined_dir_name + '.pts',
-# MUST USE TXT FILES FOR CACHING TO WORK!
-                    filename = project.combined_smaller_dir_name + '.txt',
+                    filename = smallest_elevation,
                     use_cache = True,
                     verbose = True,
                     alpha = 0.1)
-    
+                    
+
+print 'best_boundary_sww',best_boundary_sww
+
+print 'get file boundary'
 Bf = File_boundary(best_boundary_sww,
-                  domain,  use_cache=False, verbose=True)
+                  domain,  time_thinning=24, use_cache=False, verbose=True)
+                  
+domain.set_boundary({'back': Bf})
+                     
+                     
+#t0 = time.time()
+
+print 'evolve'
+for t in domain.evolve(yieldstep = 120, finaltime = 3400):
+    domain.write_time()
+    domain.write_boundary_statistics(tags = 'back')
+
+
+
+
