Changeset 5392 for anuga_work/development/Hinwood_2008
- Timestamp:
- Jun 4, 2008, 2:44:28 PM (17 years ago)
- Location:
- anuga_work/development/Hinwood_2008
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/Hinwood_2008/prepare_time_boundary.py
r5370 r5392 23 23 from interp import interp 24 24 25 def prepare_time_boundary(filename): 25 from os.path import join 26 27 # from os import getenv 28 # from os.path import join 29 # home = getenv('INUNDATIONHOME') 30 # Hinwood_dir = join(home,'data','flumes','Hinwood_2008') 31 # raw_data_dir = join(Hinwood_dir, 'raw_data') 32 33 def csv2tms(filename, offshore_bed_elevation): 26 34 """Convert benchmark 2 time series to NetCDF tms file. 35 the filename is the name of the output tms file, eg 'hi.tsm'. 36 There must be an equivalent .csv file, eg 'hi.csv'. 27 37 28 38 """ … … 50 60 51 61 T[i] = float(fields[0]) 52 Q[i] = depth = float(fields[1]) 62 Q[i] = float(fields[1]) 63 depth = Q[i] - offshore_bed_elevation 53 64 X[i] = float(fields[2]) * depth 54 65 try: … … 187 198 fid.close() 188 199 200 def prepare_time_boundary(metadata_dic, raw_data_dir, output_dir): 201 """ 202 """ 203 scenario_id = metadata_dic['scenario_id'] 204 velocity_file = join(raw_data_dir,scenario_id+'velfilt.txt') 205 depth_file = join(raw_data_dir,scenario_id+'pressfilt.txt') 206 out_file = join(output_dir, scenario_id+'_boundary.csv') 207 208 combine_velocity_depth(velocity_file, depth_file, out_file) 209 tsm_file = out_file[:-4] + '.tsm' 210 if metadata_dic['xleft'][1] >= 0.0: 211 # This should be a -ve value, since the still water level is the 212 # z origin. 213 print "Warning: The z origin seems incorrect." 214 215 csv2tms(tsm_file, metadata_dic['xleft'][1]) 189 216 190 217 191 218 #------------------------------------------------------------------- 192 219 if __name__ == "__main__": 193 from os import getenv 194 from os.path import join 195 home = getenv('INUNDATIONHOME') 196 Hinwood_dir = join(home,'data','flumes','Hinwood_2008') 197 raw_data_dir = join(Hinwood_dir, 'raw_data') 198 199 # Test 1 Run 5 200 combine_velocity_depth(join(raw_data_dir,'T1R5velfilt.txt'), 201 join(raw_data_dir,'T1R5pressfilt.txt'), 202 join(Hinwood_dir, 'T1R5_boundary.csv')) 203 # Create the tsm file 204 prepare_time_boundary(join(Hinwood_dir, 'T1R5_boundary.tsm')) 205 206 # Test 2 Run 7 207 combine_velocity_depth(join(raw_data_dir,'T2R7velfilt.txt'), 208 join(raw_data_dir,'T2R7pressfilt.txt'), 209 join(Hinwood_dir, 'T2R7_boundary.csv')) 210 # Create the tsm file 211 prepare_time_boundary(join(Hinwood_dir, 'T2R7_boundary.tsm')) 220 pass -
anuga_work/development/Hinwood_2008/project.py
r5370 r5392 3 3 """ 4 4 5 from os import sep, environ, getenv, getcwd5 from os import sep, getenv, getcwd, mkdir, access, F_OK 6 6 import sys 7 7 from time import localtime, strftime 8 from os import mkdir, access, F_OK9 from anuga. abstract_2d_finite_volumes.util import add_directories, \10 copy_code_files8 from os.path import join 9 from anuga.shallow_water.data_manager import copy_code_files 10 from anuga.abstract_2d_finite_volumes.util import add_directories 11 11 12 12 from anuga.utilities.system_tools import get_user_name … … 38 38 self.meshdir = scenariodir+sep+'meshes'+sep 39 39 self.scenariodir = scenariodir+sep 40 self.boundarydir = self.scenariodir 40 self.boundarydir = self.outputdir 41 self.raw_data_dir = join(scenariodir, 'raw_data') 41 42 42 43 # creates copy of output dir structure, if it doesn't exist -
anuga_work/development/Hinwood_2008/run_dam.py
r5390 r5392 32 32 from anuga.fit_interpolate.interpolate import interpolate_sww2csv 33 33 from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \ 34 copy_code_files, file_function 34 file_function 35 from anuga.shallow_water.data_manager import copy_code_files 35 36 from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\ 36 37 import File_boundary_time … … 61 62 friction=0.01, 62 63 outputdir_name=None, 63 is_trial_run=False):64 run_type=0): 64 65 65 66 66 67 basename = 'zz' + str(friction) 67 if is_trial_run is True:68 if run_type == 1: 68 69 outputdir_name += '_test' 69 70 yieldstep = 0.1 70 71 finaltime = 15. 71 72 maximum_triangle_area=0.01 72 else: 73 yieldstep = 0.02 74 finaltime = 15.1 75 maximum_triangle_area=0.0001 73 elif run_type == 2: 74 outputdir_name += '_test_good_time' 75 yieldstep = 0.1 76 finaltime = 50.0 77 maximum_triangle_area=0.01 76 78 77 79 maximum_triangle_area=0.001 80 elif run_type == 3: 81 outputdir_name += '_test_good_time_mesh' 82 yieldstep = 0.1 83 finaltime = 50.0 84 maximum_triangle_area=0.001 85 elif run_type == 4: 86 # this is not a test 87 # Output will go to a file 88 # The sww file will be interpolated 89 yieldstep = 0.1 90 finaltime = 50.0 91 maximum_triangle_area=0.001 92 78 93 79 94 pro_instance = project.Project(['data','flumes','Hinwood_2008'], … … 88 103 pro_instance.outputdir + 'create_mesh.py') 89 104 105 prepare_time_boundary(slope,pro_instance.raw_data_dir, 106 pro_instance.boundarydir) 107 90 108 # Boundary file manipulation 91 109 if boundary_path is None: 92 110 boundary_path = pro_instance.boundarydir 93 111 boundary_file_path = join(boundary_path, boundary_file) 94 # Convert the boundary file, .csv to .tsm95 try:96 temp = open(boundary_file_path)97 temp.close()98 except IOError:99 prepare_time_boundary(boundary_file_path)112 # # Convert the boundary file, .csv to .tsm 113 # try: 114 # temp = open(boundary_file_path) 115 # temp.close() 116 # except IOError: 117 # prepare_time_boundary(boundary_file_path) 100 118 101 119 mesh_filename = pro_instance.meshdir + basename + '.msh' … … 107 125 108 126 # creates copy of code in output dir 109 if is_trial_run is False:127 if run_type >= 4: 110 128 start_screen_catcher(pro_instance.outputdir, rank, pypar.size()) 111 129 … … 196 214 #------------------------------------------------------------------------- 197 215 198 if True:216 if run_type >= 4: 199 217 interpolate_sww2csv(pro_instance.outputdir + basename +".sww", 200 218 points, … … 207 225 def set_z_origin_to_water_depth(seabed_coords): 208 226 offset = seabed_coords['offshore_water_depth'] 209 for x in seabed_coords.keys():210 if not x == 'offshore_water_depth':227 keys = ['xleft', 'xtoe', 'xbeach', 'xright'] 228 for x in keys: 211 229 seabed_coords[x][1] -= offset 212 230 return seabed_coords … … 218 236 'xbeach':[1.285,0.090], 219 237 'xright':[16.1,.960], 220 'offshore_water_depth':.4} 238 'offshore_water_depth':.4, 239 'scenario_id':'T1R5'} 221 240 run_data_T1R5 = set_z_origin_to_water_depth(run_data_T1R5) 241 #print "run_data_T1R5", run_data_T1R5 242 #prepare_time_boundary(run_data_T1R5) 222 243 main( 'T1R5_boundary.tsm', 8, run_data_T1R5, 223 is_trial_run = True,224 outputdir_name='Hinwood_ low_stage_low_velocity_draft')244 run_type = 2, 245 outputdir_name='Hinwood_T1R5_draft')
Note: See TracChangeset
for help on using the changeset viewer.