Index: /anuga_work/development/Hinwood_2008/prepare_time_boundary.py
===================================================================
--- /anuga_work/development/Hinwood_2008/prepare_time_boundary.py	(revision 5391)
+++ /anuga_work/development/Hinwood_2008/prepare_time_boundary.py	(revision 5392)
@@ -23,6 +23,16 @@
 from interp import interp
 
-def prepare_time_boundary(filename):
+from os.path import join
+
+# from os import getenv
+# from os.path import join
+# home = getenv('INUNDATIONHOME')
+# Hinwood_dir = join(home,'data','flumes','Hinwood_2008')
+# raw_data_dir = join(Hinwood_dir, 'raw_data')
+    
+def csv2tms(filename, offshore_bed_elevation):
     """Convert benchmark 2 time series to NetCDF tms file.
+    the filename is the name of the output tms file, eg 'hi.tsm'.
+    There must be an equivalent .csv file, eg 'hi.csv'.
    
     """
@@ -50,5 +60,6 @@
 
         T[i] = float(fields[0])
-        Q[i] = depth = float(fields[1])
+        Q[i] = float(fields[1])
+        depth = Q[i] - offshore_bed_elevation
         X[i] = float(fields[2]) * depth
         try:
@@ -187,25 +198,23 @@
     fid.close()
 
+def prepare_time_boundary(metadata_dic, raw_data_dir, output_dir):
+    """
+    """
+    scenario_id = metadata_dic['scenario_id']
+    velocity_file = join(raw_data_dir,scenario_id+'velfilt.txt')
+    depth_file = join(raw_data_dir,scenario_id+'pressfilt.txt')
+    out_file = join(output_dir, scenario_id+'_boundary.csv')
+    
+    combine_velocity_depth(velocity_file, depth_file, out_file)  
+    tsm_file = out_file[:-4] + '.tsm'
+    if metadata_dic['xleft'][1] >= 0.0:
+        # This should be a -ve value, since the still water level is the
+        # z origin.
+        print "Warning: The z origin seems incorrect."
+        
+    csv2tms(tsm_file, metadata_dic['xleft'][1])
     
     
 #-------------------------------------------------------------------
 if __name__ == "__main__":
-    from os import getenv
-    from os.path import join
-    home = getenv('INUNDATIONHOME')
-    Hinwood_dir = join(home,'data','flumes','Hinwood_2008')
-    raw_data_dir = join(Hinwood_dir, 'raw_data')
-
-    # Test 1 Run 5
-    combine_velocity_depth(join(raw_data_dir,'T1R5velfilt.txt'),
-                           join(raw_data_dir,'T1R5pressfilt.txt'),
-                           join(Hinwood_dir, 'T1R5_boundary.csv'))    
-    # Create the tsm file
-    prepare_time_boundary(join(Hinwood_dir, 'T1R5_boundary.tsm'))
-    
-    # Test 2 Run 7
-    combine_velocity_depth(join(raw_data_dir,'T2R7velfilt.txt'),
-                           join(raw_data_dir,'T2R7pressfilt.txt'),
-                           join(Hinwood_dir, 'T2R7_boundary.csv'))
-    # Create the tsm file
-    prepare_time_boundary(join(Hinwood_dir, 'T2R7_boundary.tsm'))
+    pass
Index: /anuga_work/development/Hinwood_2008/project.py
===================================================================
--- /anuga_work/development/Hinwood_2008/project.py	(revision 5391)
+++ /anuga_work/development/Hinwood_2008/project.py	(revision 5392)
@@ -3,10 +3,10 @@
 """
 
-from os import sep, environ, getenv, getcwd
+from os import sep, getenv, getcwd, mkdir, access, F_OK
 import sys
 from time import localtime, strftime
-from os import mkdir, access, F_OK
-from anuga.abstract_2d_finite_volumes.util import add_directories, \
-     copy_code_files
+from os.path import join
+from anuga.shallow_water.data_manager import copy_code_files
+from anuga.abstract_2d_finite_volumes.util import add_directories
 
 from anuga.utilities.system_tools import get_user_name
@@ -38,5 +38,6 @@
         self.meshdir = scenariodir+sep+'meshes'+sep
         self.scenariodir = scenariodir+sep
-        self.boundarydir = self.scenariodir
+        self.boundarydir = self.outputdir
+        self.raw_data_dir = join(scenariodir, 'raw_data')
 
         # creates copy of output dir structure, if it doesn't exist
Index: /anuga_work/development/Hinwood_2008/run_dam.py
===================================================================
--- /anuga_work/development/Hinwood_2008/run_dam.py	(revision 5391)
+++ /anuga_work/development/Hinwood_2008/run_dam.py	(revision 5392)
@@ -32,5 +32,6 @@
 from anuga.fit_interpolate.interpolate import interpolate_sww2csv
 from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \
-     copy_code_files, file_function
+      file_function
+from anuga.shallow_water.data_manager import copy_code_files
 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\
      import File_boundary_time
@@ -61,19 +62,33 @@
          friction=0.01,
          outputdir_name=None,
-         is_trial_run=False):
+         run_type=0):
 
     
     basename = 'zz' + str(friction)
-    if is_trial_run is True:
+    if run_type == 1:
         outputdir_name += '_test'
         yieldstep = 0.1
         finaltime = 15.
         maximum_triangle_area=0.01
-    else:
-        yieldstep = 0.02
-        finaltime = 15.1
-        maximum_triangle_area=0.0001
+    elif run_type == 2:
+        outputdir_name += '_test_good_time'
+        yieldstep = 0.1
+        finaltime = 50.0
+        maximum_triangle_area=0.01
         
         maximum_triangle_area=0.001
+    elif run_type == 3:
+        outputdir_name += '_test_good_time_mesh'
+        yieldstep = 0.1
+        finaltime = 50.0        
+        maximum_triangle_area=0.001
+    elif run_type == 4:
+        # this is not a test
+        # Output will go to a file
+        # The sww file will be interpolated
+        yieldstep = 0.1
+        finaltime = 50.0        
+        maximum_triangle_area=0.001
+         
         
     pro_instance = project.Project(['data','flumes','Hinwood_2008'],
@@ -88,14 +103,17 @@
           pro_instance.outputdir + 'create_mesh.py')
 
+    prepare_time_boundary(slope,pro_instance.raw_data_dir,
+                          pro_instance.boundarydir)
+    
     # Boundary file manipulation
     if boundary_path is None:
         boundary_path = pro_instance.boundarydir
     boundary_file_path = join(boundary_path, boundary_file)
-    # Convert the boundary file, .csv to .tsm
-    try:
-        temp = open(boundary_file_path)
-        temp.close()
-    except IOError:
-        prepare_time_boundary(boundary_file_path)
+   #  # Convert the boundary file, .csv to .tsm
+#     try:
+#         temp = open(boundary_file_path)
+#         temp.close()
+#     except IOError:
+#         prepare_time_boundary(boundary_file_path)
     
     mesh_filename = pro_instance.meshdir + basename + '.msh'
@@ -107,5 +125,5 @@
 
     # creates copy of code in output dir
-    if is_trial_run is False:
+    if run_type >= 4:
         start_screen_catcher(pro_instance.outputdir, rank, pypar.size())
 
@@ -196,5 +214,5 @@
     #-------------------------------------------------------------------------
 
-    if True:
+    if run_type >= 4:
         interpolate_sww2csv(pro_instance.outputdir + basename +".sww",
                             points,
@@ -207,6 +225,6 @@
 def set_z_origin_to_water_depth(seabed_coords):
     offset = seabed_coords['offshore_water_depth']
-    for x in seabed_coords.keys():
-        if not x == 'offshore_water_depth':
+    keys = ['xleft', 'xtoe', 'xbeach', 'xright']
+    for x in keys:
             seabed_coords[x][1] -= offset
     return seabed_coords
@@ -218,7 +236,10 @@
                      'xbeach':[1.285,0.090],
                      'xright':[16.1,.960],
-                     'offshore_water_depth':.4}
+                     'offshore_water_depth':.4,
+                     'scenario_id':'T1R5'}
     run_data_T1R5 = set_z_origin_to_water_depth(run_data_T1R5)
+    #print "run_data_T1R5", run_data_T1R5
+    #prepare_time_boundary(run_data_T1R5)
     main( 'T1R5_boundary.tsm', 8, run_data_T1R5,
-          is_trial_run = True,
-         outputdir_name='Hinwood_low_stage_low_velocity_draft')
+          run_type = 2,
+         outputdir_name='Hinwood_T1R5_draft')
