Index: /anuga_work/development/Hinwood_2008/boundary.csv
===================================================================
--- /anuga_work/development/Hinwood_2008/boundary.csv	(revision 5349)
+++ /anuga_work/development/Hinwood_2008/boundary.csv	(revision 5350)
@@ -1,152 +1,152 @@
-time sec,stage m,X velocity m/s,Y velocity m/s
-0,0.4,0,0.01
-0.1,0.401996668,0.005990005,0.01
-0.2,0.403973387,0.01192016,0.01
-0.3,0.405910404,0.017731212,0.01
-0.4,0.407788367,0.023365101,0.01
-0.5,0.409588511,0.028765532,0.01
-0.6,0.411292849,0.033878548,0.01
-0.7,0.412884354,0.038653061,0.01
-0.8,0.414347122,0.043041365,0.01
-0.9,0.415666538,0.046999615,0.01
-1,0.41682942,0.050488259,0.01
-1.1,0.417824147,0.053472442,0.01
-1.2,0.418640782,0.055922345,0.01
-1.3,0.419271164,0.057813491,0.01
-1.4,0.419708995,0.059126984,0.01
-1.5,0.4199499,0.059849699,0.01
-1.6,0.419991472,0.059974416,0.01
-1.7,0.419833296,0.059499889,0.01
-1.8,0.419476953,0.058430858,0.01
-1.9,0.418926002,0.056778005,0.01
-2,0.418185949,0.054557846,0.01
-2.1,0.417264187,0.051792562,0.01
-2.2,0.416169928,0.048509784,0.01
-2.3,0.414914104,0.044742313,0.01
-2.4,0.413509264,0.040527791,0.01
-2.5,0.411969443,0.035908329,0.01
-2.6,0.410310027,0.030930082,0.01
-2.7,0.408547598,0.025642793,0.01
-2.8,0.406699763,0.020099289,0.01
-2.9,0.404784987,0.01435496,0.01
-3,0.4028224,0.0084672,0.01
-3.1,0.400831613,0.00249484,0.01
-3.2,0.398832517,-0.003502449,0.01
-3.3,0.396845086,-0.009464742,0.01
-3.4,0.394889178,-0.015332466,0.01
-3.5,0.392984335,-0.021046994,0.01
-3.6,0.391149591,-0.026551227,0.01
-3.7,0.389403277,-0.031790168,0.01
-3.8,0.387762842,-0.036711473,0.01
-3.9,0.386244677,-0.04126597,0.01
-4,0.38486395,-0.04540815,0.01
-4.1,0.383634458,-0.049096627,0.01
-4.2,0.382568485,-0.052294546,0.01
-4.3,0.381676681,-0.054969956,0.01
-4.4,0.380967959,-0.057096124,0.01
-4.5,0.380449398,-0.058651807,0.01
-4.6,0.38012618,-0.05962146,0.01
-4.7,0.380001535,-0.059995395,0.01
-4.8,0.380076708,-0.059769877,0.01
-4.9,0.380350948,-0.058947157,0.01
-5,0.380821515,-0.057535456,0.01
-5.1,0.381483706,-0.055548881,0.01
-5.2,0.382330907,-0.053007279,0.01
-5.3,0.383354651,-0.049936047,0.01
-5.4,0.38454471,-0.046365869,0.01
-5.5,0.385889193,-0.04233242,0.01
-5.6,0.387374667,-0.037875998,0.01
-5.7,0.388986289,-0.033041133,0.01
-5.8,0.390707956,-0.027876131,0.01
-5.9,0.392522467,-0.0224326,0.01
-6,0.39441169,-0.01676493,0.01
-6.1,0.39635675,-0.01092975,0.01
-6.2,0.398338212,-0.004985364,0.01
-6.3,0.400336278,0.001008834,0.01
-6.4,0.402330984,0.006992952,0.01
-6.5,0.4043024,0.012907199,0.01
-6.6,0.406230827,0.018692482,0.01
-6.7,0.408096998,0.024290995,0.01
-6.8,0.409882267,0.029646801,0.01
-6.9,0.411568795,0.034706386,0.01
-7,0.413139732,0.039419196,0.01
-7.1,0.414579381,0.043738142,0.01
-7.2,0.415873357,0.047620072,0.01
-7.3,0.417008732,0.051026197,0.01
-7.4,0.417974162,0.053922486,0.01
-7.5,0.41876,0.056279999,0.01
-7.6,0.419358393,0.05807518,0.01
-7.7,0.419763365,0.059290094,0.01
-7.8,0.419970867,0.059912601,0.01
-7.9,0.419978827,0.059936481,0.01
-8,0.419787165,0.059361495,0.01
-8.1,0.419397796,0.058193389,0.01
-8.2,0.418814611,0.056443833,0.01
-8.3,0.418043437,0.05413031,0.01
-8.4,0.417091978,0.051275934,0.01
-8.5,0.415969742,0.047909227,0.01
-8.6,0.414687942,0.044063826,0.01
-8.7,0.413259385,0.039778154,0.01
-8.8,0.411698344,0.035095032,0.01
-8.9,0.410020417,0.030061251,0.01
-9,0.40824237,0.024727109,0.01
-9.1,0.406381967,0.019145902,0.01
-9.2,0.404457798,0.013373395,0.01
-9.3,0.402489088,0.007467265,0.01
-9.4,0.400495509,0.001486526,0.01
-9.5,0.398496978,-0.004509067,0.01
-9.6,0.396513464,-0.010459607,0.01
-9.7,0.394564787,-0.016305638,0.01
-9.8,0.392670417,-0.021988748,0.01
-9.9,0.390849282,-0.027452154,0.01
-10,0.389119578,-0.032641267,0.01
-10.1,0.387498587,-0.037504239,0.01
-10.2,0.386002506,-0.041992481,0.01
-10.3,0.384646284,-0.046061149,0.01
-10.4,0.383443471,-0.049669588,0.01
-10.5,0.382406085,-0.052781746,0.01
-10.6,0.381544492,-0.055366525,0.01
-10.7,0.3808673,-0.057398101,0.01
-10.8,0.380381275,-0.058856174,0.01
-10.9,0.380091275,-0.059726175,0.01
-11,0.380000196,-0.059999412,0.01
-11.1,0.380108948,-0.059673155,0.01
-11.2,0.380416445,-0.058750664,0.01
-11.3,0.380919615,-0.057241155,0.01
-11.4,0.381613429,-0.055159712,0.01
-11.5,0.382490957,-0.05252713,0.01
-11.6,0.383543428,-0.049369716,0.01
-11.7,0.384760328,-0.045719015,0.01
-11.8,0.386129498,-0.041611505,0.01
-11.9,0.387637258,-0.037088227,0.01
-12,0.389268542,-0.032194375,0.01
-12.1,0.391007051,-0.026978848,0.01
-12.2,0.392835414,-0.021493757,0.01
-12.3,0.394735364,-0.015793907,0.01
-12.4,0.396687916,-0.009936251,0.01
-12.5,0.398673562,-0.003979314,0.01
-12.6,0.400672461,0.002017383,0.01
-12.7,0.402664641,0.007993922,0.01
-12.8,0.404630197,0.01389059,0.01
-12.9,0.406549489,0.019648466,0.01
-13,0.408403341,0.025210022,0.01
-13.1,0.410173229,0.030519688,0.01
-13.2,0.41184147,0.035524411,0.01
-13.3,0.413391395,0.040174186,0.01
-13.4,0.414807518,0.044422553,0.01
-13.5,0.416075689,0.048227066,0.01
-13.6,0.417183236,0.051549709,0.01
-13.7,0.418119095,0.054357285,0.01
-13.8,0.418873913,0.05662174,0.01
-13.9,0.41944015,0.05832045,0.01
-14,0.419812147,0.059436441,0.01
-14.1,0.419986188,0.059958563,0.01
-14.2,0.419960533,0.059881599,0.01
-14.3,0.419735439,0.059206318,0.01
-14.4,0.419313156,0.057939467,0.01
-14.5,0.418697901,0.056093703,0.01
-14.6,0.417895823,0.05368747,0.01
-14.7,0.416914937,0.05074481,0.01
-14.8,0.415765041,0.047295124,0.01
-14.9,0.414457627,0.043372881,0.01
-15,0.413005757,0.03901727,0.01
+time sec,stage m,X velocity m/s
+0,0.4,0
+0.1,0.401996668,0.005990005
+0.2,0.403973387,0.01192016
+0.3,0.405910404,0.017731212
+0.4,0.407788367,0.023365101
+0.5,0.409588511,0.028765532
+0.6,0.411292849,0.033878548
+0.7,0.412884354,0.038653061
+0.8,0.414347122,0.043041365
+0.9,0.415666538,0.046999615
+1,0.41682942,0.050488259
+1.1,0.417824147,0.053472442
+1.2,0.418640782,0.055922345
+1.3,0.419271164,0.057813491
+1.4,0.419708995,0.059126984
+1.5,0.4199499,0.059849699
+1.6,0.419991472,0.059974416
+1.7,0.419833296,0.059499889
+1.8,0.419476953,0.058430858
+1.9,0.418926002,0.056778005
+2,0.418185949,0.054557846
+2.1,0.417264187,0.051792562
+2.2,0.416169928,0.048509784
+2.3,0.414914104,0.044742313
+2.4,0.413509264,0.040527791
+2.5,0.411969443,0.035908329
+2.6,0.410310027,0.030930082
+2.7,0.408547598,0.025642793
+2.8,0.406699763,0.020099289
+2.9,0.404784987,0.01435496
+3,0.4028224,0.0084672
+3.1,0.400831613,0.00249484
+3.2,0.398832517,-0.003502449
+3.3,0.396845086,-0.009464742
+3.4,0.394889178,-0.015332466
+3.5,0.392984335,-0.021046994
+3.6,0.391149591,-0.026551227
+3.7,0.389403277,-0.031790168
+3.8,0.387762842,-0.036711473
+3.9,0.386244677,-0.04126597
+4,0.38486395,-0.04540815
+4.1,0.383634458,-0.049096627
+4.2,0.382568485,-0.052294546
+4.3,0.381676681,-0.054969956
+4.4,0.380967959,-0.057096124
+4.5,0.380449398,-0.058651807
+4.6,0.38012618,-0.05962146
+4.7,0.380001535,-0.059995395
+4.8,0.380076708,-0.059769877
+4.9,0.380350948,-0.058947157
+5,0.380821515,-0.057535456
+5.1,0.381483706,-0.055548881
+5.2,0.382330907,-0.053007279
+5.3,0.383354651,-0.049936047
+5.4,0.38454471,-0.046365869
+5.5,0.385889193,-0.04233242
+5.6,0.387374667,-0.037875998
+5.7,0.388986289,-0.033041133
+5.8,0.390707956,-0.027876131
+5.9,0.392522467,-0.0224326
+6,0.39441169,-0.01676493
+6.1,0.39635675,-0.01092975
+6.2,0.398338212,-0.004985364
+6.3,0.400336278,0.001008834
+6.4,0.402330984,0.006992952
+6.5,0.4043024,0.012907199
+6.6,0.406230827,0.018692482
+6.7,0.408096998,0.024290995
+6.8,0.409882267,0.029646801
+6.9,0.411568795,0.034706386
+7,0.413139732,0.039419196
+7.1,0.414579381,0.043738142
+7.2,0.415873357,0.047620072
+7.3,0.417008732,0.051026197
+7.4,0.417974162,0.053922486
+7.5,0.41876,0.056279999
+7.6,0.419358393,0.05807518
+7.7,0.419763365,0.059290094
+7.8,0.419970867,0.059912601
+7.9,0.419978827,0.059936481
+8,0.419787165,0.059361495
+8.1,0.419397796,0.058193389
+8.2,0.418814611,0.056443833
+8.3,0.418043437,0.05413031
+8.4,0.417091978,0.051275934
+8.5,0.415969742,0.047909227
+8.6,0.414687942,0.044063826
+8.7,0.413259385,0.039778154
+8.8,0.411698344,0.035095032
+8.9,0.410020417,0.030061251
+9,0.40824237,0.024727109
+9.1,0.406381967,0.019145902
+9.2,0.404457798,0.013373395
+9.3,0.402489088,0.007467265
+9.4,0.400495509,0.001486526
+9.5,0.398496978,-0.004509067
+9.6,0.396513464,-0.010459607
+9.7,0.394564787,-0.016305638
+9.8,0.392670417,-0.021988748
+9.9,0.390849282,-0.027452154
+10,0.389119578,-0.032641267
+10.1,0.387498587,-0.037504239
+10.2,0.386002506,-0.041992481
+10.3,0.384646284,-0.046061149
+10.4,0.383443471,-0.049669588
+10.5,0.382406085,-0.052781746
+10.6,0.381544492,-0.055366525
+10.7,0.3808673,-0.057398101
+10.8,0.380381275,-0.058856174
+10.9,0.380091275,-0.059726175
+11,0.380000196,-0.059999412
+11.1,0.380108948,-0.059673155
+11.2,0.380416445,-0.058750664
+11.3,0.380919615,-0.057241155
+11.4,0.381613429,-0.055159712
+11.5,0.382490957,-0.05252713
+11.6,0.383543428,-0.049369716
+11.7,0.384760328,-0.045719015
+11.8,0.386129498,-0.041611505
+11.9,0.387637258,-0.037088227
+12,0.389268542,-0.032194375
+12.1,0.391007051,-0.026978848
+12.2,0.392835414,-0.021493757
+12.3,0.394735364,-0.015793907
+12.4,0.396687916,-0.009936251
+12.5,0.398673562,-0.003979314
+12.6,0.400672461,0.002017383
+12.7,0.402664641,0.007993922
+12.8,0.404630197,0.01389059
+12.9,0.406549489,0.019648466
+13,0.408403341,0.025210022
+13.1,0.410173229,0.030519688
+13.2,0.41184147,0.035524411
+13.3,0.413391395,0.040174186
+13.4,0.414807518,0.044422553
+13.5,0.416075689,0.048227066
+13.6,0.417183236,0.051549709
+13.7,0.418119095,0.054357285
+13.8,0.418873913,0.05662174
+13.9,0.41944015,0.05832045
+14,0.419812147,0.059436441
+14.1,0.419986188,0.059958563
+14.2,0.419960533,0.059881599
+14.3,0.419735439,0.059206318
+14.4,0.419313156,0.057939467
+14.5,0.418697901,0.056093703
+14.6,0.417895823,0.05368747
+14.7,0.416914937,0.05074481
+14.8,0.415765041,0.047295124
+14.9,0.414457627,0.043372881
+15,0.413005757,0.03901727
Index: /anuga_work/development/Hinwood_2008/prepare_time_boundary.py
===================================================================
--- /anuga_work/development/Hinwood_2008/prepare_time_boundary.py	(revision 5349)
+++ /anuga_work/development/Hinwood_2008/prepare_time_boundary.py	(revision 5350)
@@ -18,8 +18,10 @@
 from Scientific.IO.NetCDF import NetCDFFile
 from Numeric import array, zeros, Float
+  
+from anuga.utilities.numerical_tools import ensure_numeric
 
-from project import boundary_file
+from interp import interp
 
-def prepare_timeboundary(filename):
+def prepare_time_boundary(filename):
     """Convert benchmark 2 time series to NetCDF tms file.
     This is a 'throw-away' code taylor made for files like
@@ -54,5 +56,8 @@
         Q[i] = depth = float(fields[1])
         X[i] = float(fields[2]) * depth
-        Y[i] = float(fields[3]) * depth
+        try:
+            Y[i] = float(fields[3]) * depth
+        except:
+            pass
 
 
@@ -78,5 +83,73 @@
     fid.close()
 
-#-------------------------------------------------------------
+
+def combine_velocity_depth(velocity_file, depth_file, out_file):
+    """
+    
+    Convert the rawish velocity and depth values, which have values at
+    different times to a csv file, with values at the same time, with
+    SI units.
+
+    The format for the velocity file is;
+    [time, sec], [x-velocity +ve is towards the wave generator, m/sec],
+    [y-velocity], [z-velocity]
+
+    The format for the pressure file is
+    [time, sec], [mm above SWL for sensor A], many other sensors...
+    """
+
+    # Read velocity file
+    vfid = open(velocity_file)
+    lines = vfid.readlines()
+    vfid.close()
+
+    
+    n_velocity = len(lines)
+    vtimes = zeros(n_velocity, Float)  #Time
+    velocities = zeros(n_velocity, Float)  #
+
+    for i, line in enumerate(lines):
+        fields = line.split(',')
+
+        vtimes[i] = float(fields[0])
+        velocities[i] = float(fields[1])
+
+    # Read the depth file
+    dfid = open(depth_file)
+    lines = dfid.readlines()
+    dfid.close()
+
+
+    n_depth = len(lines)
+    dtimes = zeros(n_depth, Float)  #Time
+    depths = zeros(n_depth, Float)  #
+    
+    for i, line in enumerate(lines):
+        fields = line.split(',')
+
+        dtimes[i] = float(fields[0])
+        depths[i] = float(fields[1])
+
+    depths_at_vtimes = interp(dtimes, depths, vtimes, missing=1e+20)
+    depths_at_vtimes = ensure_numeric(depths_at_vtimes)
+    depths_at_vtimes = depths_at_vtimes/1000.00 # convert from mm to m
+    velocities = ensure_numeric(velocities)
+    velocities = velocities * -1.0 # Swap axis around
+    
+    fid = open(out_file,'w')
+
+    assert len(depths_at_vtimes) == len(vtimes)
+    
+    #for vtime, depth_at_vtime, velocity in map(vtimes, depths_at_vtimes,
+    #                                           velocities):
+    for i in xrange(len(vtimes)):
+        fid.write(str(vtimes[i]) + ',' + str(depths_at_vtimes[i]) \
+                  + ',' + str(velocities[i])+'\n')
+
+    fid.close()
+    
+    
+#-------------------------------------------------------------------
 if __name__ == "__main__":
-    prepare_timeboundary(boundary_file)
+    combine_velocity_depth('T2R7velfilt.csv','T2R7pressfilt.csv', 'cyeah.csv')
+
Index: /anuga_work/development/Hinwood_2008/project.py
===================================================================
--- /anuga_work/development/Hinwood_2008/project.py	(revision 5349)
+++ /anuga_work/development/Hinwood_2008/project.py	(revision 5350)
@@ -12,5 +12,4 @@
 from anuga.utilities.system_tools import get_user_name
 
-boundary_file = 'boundary.tsm'
 
 class Project:    
@@ -22,5 +21,8 @@
         self.user = get_user_name()
         if home is None:
-            home = getenv('INUNDATIONHOME') #Sandpit's parent dir   
+            try:
+                home = getenv('INUNDATIONHOME') #Sandpit's parent dir
+            except:
+                home = '.'
         self.home = home
         # Create the structure of where the output directories will go
@@ -30,8 +32,11 @@
         if outputdir_name is None:
             #gets time for dir
-            outputdir_name = strftime('%Y%m%d_%H%M%S',localtime()) 
+            outputdir_name = strftime('%Y%m%d_%H%M%S',localtime())
+        
         general_outputdir = scenariodir+sep+'output'+sep
         self.outputdir = general_outputdir+outputdir_name+sep
         self.meshdir = scenariodir+sep+'meshes'+sep
+        self.scenariodir = scenariodir+sep
+        self.boundary_file = self.scenariodir + 'boundary.tsm'
 
         # 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 5349)
+++ /anuga_work/development/Hinwood_2008/run_dam.py	(revision 5350)
@@ -39,4 +39,7 @@
 import project                 # Definition of file names and polygons
 import create_mesh
+from prepare_time_boundary import prepare_time_boundary
+
+
 
 def elevation_function(x,y):
@@ -55,4 +58,6 @@
 
 def main(friction=0.01, outputdir_name=None, is_trial_run=False):
+
+    
     basename = 'zz' + str(friction)
     if is_trial_run is True:
@@ -69,6 +74,5 @@
         
     pro_instance = project.Project(['data','flumes','Hinwood_2008'],
-                                   outputdir_name=outputdir_name,
-                                   home='.')
+                                   outputdir_name=outputdir_name)
     print "The output dir is", pro_instance.outputdir
     copy_code_files(pro_instance.outputdir,__file__,
@@ -79,4 +83,12 @@
     copy (pro_instance.codedir + 'create_mesh.py',
           pro_instance.outputdir + 'create_mesh.py')
+
+    
+    # Convert the boundary file, .csv to .tsm
+    try:
+        temp = open(pro_instance.boundary_file)
+        temp.close()
+    except IOError:
+        prepare_time_boundary(pro_instance.boundary_file)
     
     mesh_filename = pro_instance.meshdir + basename + '.msh'
@@ -135,6 +147,12 @@
     #function = file_function(project.boundary_file, domain, verbose=True)
     #Bts = Transmissive_Momentum_Set_Stage_boundary(domain, function)
-
-    function = file_function(project.boundary_file, domain, verbose=True)
+    try:
+        function = file_function(pro_instance.boundary_file, domain,
+                                 verbose=True)
+    except IOError:
+        msg = 'Run prepare_time_boundary.py. File "%s" could not be opened.'\
+                  %(pro_instance.boundary_file)
+        raise msg
+        
     Br = Reflective_boundary(domain)
     #Bd = Dirichlet_boundary([0.3,0,0]) 
