Changeset 5395
- Timestamp:
- Jun 6, 2008, 5:33:25 PM (16 years ago)
- Location:
- anuga_work/development/Hinwood_2008
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/development/Hinwood_2008/prepare_time_boundary.py
r5392 r5395 91 91 92 92 93 def combine_velocity_depth(velocity_file, depth_file, out_file ):93 def combine_velocity_depth(velocity_file, depth_file, out_file, metadata_dic): 94 94 """ 95 95 … … 101 101 102 102 The format for the velocity file is; 103 [time, sec], [x-velocity +ve is towards the wave generator, m/sec],103 [time, sec], [x-velocity +ve is towards the wave generator, cm/sec], 104 104 [y-velocity], [z-velocity] 105 105 106 106 The format for the pressure file is 107 107 [time, sec], [mm above SWL for sensor A], many other sensors... 108 109 The format of the output file is; 110 [time, sec], [m above SWL for sensor A], 111 [x-velocity +ve is towards the shore, m/sec], 112 [y-velocity +ve is towards the left of the tank, looking from the 113 generator to the shore, m/sec] 114 115 108 116 """ 109 117 missing = 1e+20 … … 162 170 missing=missing/1000.00 # Do to missing what is done to depths_at_vtimes 163 171 x_velocities = ensure_numeric(x_velocities) 164 x_velocities = x_velocities * -1.0 # Swap axis around 172 # Swap axis around convert cm/sec to m/sec 173 x_velocities = x_velocities * -0.01 165 174 y_velocities = ensure_numeric(y_velocities) 166 y_velocities = y_velocities * -1.0 # Swap axis around 175 # Swap axis around convert cm/sec to m/sec 176 y_velocities = y_velocities * -0.01 167 177 168 178 fid = open(out_file,'w') … … 177 187 # Make the times start at zero. 178 188 if start_time is None: 179 start_time = vtimes[i] 180 fid.write(str(vtimes[i]-start_time) \ 189 start_time = vtimes[i] 190 final_time = vtimes[i]-start_time 191 fid.write(str(final_time) \ 181 192 + ',' + str(depths_at_vtimes[i]) \ 182 193 + ',' + str(x_velocities[i]) \ … … 187 198 # Since there is a new time reference save the depth info using this 188 199 # new reference. 189 fid = open(depth_file[:-4] + '_ new_time'+depth_file[-4:],'w')200 fid = open(depth_file[:-4] + '_exp_depth.csv','w') 190 201 sensors[:,0] -= start_time 191 202 #print "depth_file", depth_file 192 203 #print "start_time", start_time 193 for i in xrange(len(dtimes)): 194 fid.write(str(sensors[i,0])) 195 for j in xrange(1,len(sensors[0])): 196 fid.write(' ' + str(sensors[i,j])) 204 205 # Write a header 206 fid.write('Time') 207 for gauge_x in metadata_dic['gauge_x']: 208 fid.write(',' + str(gauge_x)) 209 fid.write('\n') 210 for i in xrange(len(dtimes)): 211 fid.write(str(sensors[i,0])) # Time 212 # Don't write sensor A. 213 # It is the boundary condition. 214 for j, bed_elevation in map(None,xrange(2,len(sensors[0])), 215 metadata_dic['gauge_bed_elevation']): 216 # depth, m 217 gauge = sensors[i,j]/1000 - bed_elevation # Convert from mm to m 218 fid.write(',' + str(gauge)) 197 219 fid.write('\n') 198 220 fid.close() 221 return final_time 199 222 200 223 def prepare_time_boundary(metadata_dic, raw_data_dir, output_dir): … … 205 228 depth_file = join(raw_data_dir,scenario_id+'pressfilt.txt') 206 229 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' 230 #out_depth_file = join(output_dir, scenario_id+'_exp_depth.csv') 231 232 final_time = combine_velocity_depth(velocity_file, depth_file, out_file, 233 metadata_dic) 210 234 if metadata_dic['xleft'][1] >= 0.0: 211 235 # This should be a -ve value, since the still water level is the 212 236 # z origin. 213 print "Warning: The z origin seems incorrect." 214 237 print "Warning: The z origin seems incorrect." 238 tsm_file = out_file[:-4] + '.tsm' 215 239 csv2tms(tsm_file, metadata_dic['xleft'][1]) 216 240 return final_time 217 241 218 242 #------------------------------------------------------------------- -
anuga_work/development/Hinwood_2008/run_dam.py
r5392 r5395 57 57 58 58 def main(boundary_file, 59 boundary_location, 60 slope, 59 metadata_dic, 61 60 boundary_path=None, 62 61 friction=0.01, … … 65 64 66 65 67 basename = 'zz ' + str(friction)66 basename = 'zz_' + metadata_dic['scenario_id'] 68 67 if run_type == 1: 69 68 outputdir_name += '_test' … … 71 70 finaltime = 15. 72 71 maximum_triangle_area=0.01 72 73 73 elif run_type == 2: 74 outputdir_name += '_test_ good_time'75 yieldstep = 0. 176 finaltime = 50.074 outputdir_name += '_test_long_time' 75 yieldstep = 0.5 76 finaltime = None 77 77 maximum_triangle_area=0.01 78 78 79 maximum_triangle_area=0.00180 79 elif run_type == 3: 81 80 outputdir_name += '_test_good_time_mesh' 82 81 yieldstep = 0.1 83 finaltime = 50.082 finaltime = None 84 83 maximum_triangle_area=0.001 85 84 elif run_type == 4: 85 outputdir_name += '_good_A' 86 86 # this is not a test 87 87 # Output will go to a file 88 88 # The sww file will be interpolated 89 yieldstep = 0. 190 finaltime = 50.089 yieldstep = 0.01 90 finaltime = None 91 91 maximum_triangle_area=0.001 92 92 93 metadata_dic = set_z_origin_to_water_depth(metadata_dic) 93 94 94 95 pro_instance = project.Project(['data','flumes','Hinwood_2008'], … … 103 104 pro_instance.outputdir + 'create_mesh.py') 104 105 105 prepare_time_boundary(slope,pro_instance.raw_data_dir, 106 pro_instance.boundarydir) 106 boundary_final_time = prepare_time_boundary(metadata_dic, 107 pro_instance.raw_data_dir, 108 pro_instance.boundarydir) 109 if finaltime is None: 110 finaltime = boundary_final_time 107 111 108 112 # Boundary file manipulation … … 125 129 126 130 # creates copy of code in output dir 127 if run_type >= 4: 128 start_screen_catcher(pro_instance.outputdir, rank, pypar.size()) 131 if run_type >= 2: 132 #start_screen_catcher(pro_instance.outputdir, rank, pypar.size()) 133 start_screen_catcher(pro_instance.outputdir) 129 134 130 135 print 'USER: ', pro_instance.user … … 135 140 # this creates the mesh 136 141 #gate_position = 12.0 137 create_mesh.generate(mesh_filename, slope,142 create_mesh.generate(mesh_filename, metadata_dic, 138 143 maximum_triangle_area=maximum_triangle_area) 139 144 … … 162 167 #------------------------------------------------------------------------- 163 168 164 domain.set_quantity('stage', 0. 4)169 domain.set_quantity('stage', 0.) #the origin is the still water level 165 170 domain.set_quantity('friction', friction) 166 elevation_function = Elevation_function( slope)171 elevation_function = Elevation_function(metadata_dic) 167 172 domain.set_quantity('elevation', elevation_function) 168 173 … … 185 190 Bts = Time_boundary(domain, function) 186 191 domain.set_boundary( {'wall': Br, 'wave': Bts} ) 187 domain.set_boundary( {'wall': Br, 'wave': Bd} )192 #domain.set_boundary( {'wall': Br, 'wave': Bd} ) 188 193 189 194 #------------------------------------------------------------------------- … … 200 205 201 206 flume_y_middle = 0.225 202 points = [[2.8,flume_y_middle], #-1.8m from SWL 203 [5.1,flume_y_middle], #0.5m from SWL 204 [6.6,flume_y_middle], #2m from SWL 205 [6.95,flume_y_middle], #2.35m from SWL 206 [7.6,flume_y_middle], #3m from SWL 207 [8.2,flume_y_middle], #3.5m from SWL 208 [9.2,flume_y_middle] #4.5m from SWL 209 ] 207 points = [] 208 for gauge_x in metadata_dic['gauge_x']: 209 points.append([gauge_x, flume_y_middle]) 210 print "points",points 210 211 211 212 … … 214 215 #------------------------------------------------------------------------- 215 216 216 if run_type >= 4: 217 if run_type >= 2: 218 id = metadata_dic['scenario_id'] 217 219 interpolate_sww2csv(pro_instance.outputdir + basename +".sww", 218 220 points, 219 pro_instance.outputdir + "depth_ manning_"+str(friction)+".csv",220 pro_instance.outputdir + "velocity_x .csv",221 pro_instance.outputdir + "velocity_y .csv")221 pro_instance.outputdir + "depth_" + id + ".csv", 222 pro_instance.outputdir + "velocity_x_" + id + ".csv", 223 pro_instance.outputdir + "velocity_y_" + id + ".csv") 222 224 223 225 return pro_instance … … 232 234 if __name__ == "__main__": 233 235 #slopes = [[-4.5,0.0],[0.0,0.0],[1.285,0.090],[16.1,.960]] 234 run_data_T1R5 = {'xleft':[-4.5,0.0], 236 # Note, gauge A has been removed, since it is used as the 237 # boundary. 238 run_type = 2 239 240 # T1R5 241 run_data = {'xleft':[-3.106,0.0], # Av' of ADV and Gauge A 235 242 'xtoe':[0.0,0.0], 236 243 'xbeach':[1.285,0.090], 237 244 'xright':[16.1,.960], 238 245 'offshore_water_depth':.4, 239 'scenario_id':'T1R5'} 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) 243 main( 'T1R5_boundary.tsm', 8, run_data_T1R5, 244 run_type = 2, 245 outputdir_name='Hinwood_T1R5_draft') 246 'scenario_id':'T1R5', 247 'gauge_names':['B','1','2','3','4','5','6','7','8', 248 '9','10','11','12','13','14'], 249 'gauge_x':[-0.68, 1.572, 2.572, 3.572, 4.572, 5.572, 250 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 251 12.572, 13.572, 14.572], 252 'gauge_bed_elevation':[-0.400000, -0.293158, 253 -0.234473, -0.175788, -0.117104, -0.058419, 0.000266, 254 0.058950, 0.117635, 0.176320, 0.235004, 0.293689, 255 0.352374, 0.411058, 0.469743] 256 } 257 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 258 run_type = run_type, 259 outputdir_name=run_data['scenario_id']) 260 261 # T1R3 262 run_data['scenario_id'] = 'T1R3' 263 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 264 run_type = run_type, 265 outputdir_name=run_data['scenario_id']) 266 267 # #T2R7 268 # xleft is different 269 run_data = {'xleft':[-4.586,0.0], # Av' of ADV and Gauge A 270 'xtoe':[0.0,0.0], 271 'xbeach':[1.285,0.090], 272 'xright':[16.1,.960], 273 'offshore_water_depth':.4, 274 'scenario_id':'T2R7', 275 'gauge_names':['B','1','2','3','4','5','6','7','8', 276 '9','10','11','12','13','14'], 277 'gauge_x':[-0.68, 1.572, 2.572, 3.572, 4.572, 5.572, 278 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 279 12.572, 13.572, 14.572], 280 'gauge_bed_elevation':[-0.400000, -0.293158, 281 -0.234473, -0.175788, -0.117104, -0.058419, 0.000266, 282 0.058950, 0.117635, 0.176320, 0.235004, 0.293689, 283 0.352374, 0.411058, 0.469743] 284 } 285 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 286 run_type = run_type, 287 outputdir_name=run_data['scenario_id']) 288 289 # #T2R8 290 # xleft is different 291 run_data = {'xleft':[-4.586,0.0], # Av' of ADV and Gauge A 292 'xtoe':[0.0,0.0], 293 'xbeach':[1.285,0.090], 294 'xright':[16.1,.960], 295 'offshore_water_depth':.4, 296 'scenario_id':'T2R8', 297 'gauge_names':['B','1','2','3','4','5','6','7','8', 298 '9','10','11','12','13','14'], 299 'gauge_x':[-0.68, 1.572, 2.572, 3.572, 4.572, 5.572, 300 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 301 12.572, 13.572, 14.572], 302 'gauge_bed_elevation':[-0.400000, -0.293158, 303 -0.234473, -0.175788, -0.117104, -0.058419, 0.000266, 304 0.058950, 0.117635, 0.176320, 0.235004, 0.293689, 305 0.352374, 0.411058, 0.469743] 306 } 307 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 308 run_type = run_type, 309 outputdir_name=run_data['scenario_id']) 310 311 # #T3R29 312 # xleft is different 313 run_data = {'xleft':[-3.875,0.0], # Av' of ADV and Gauge A 314 'xtoe':[0.0,0.0], 315 'xbeach':[1.285,0.090], 316 'xright':[16.1,.440], 317 'offshore_water_depth':.336, 318 'scenario_id':'T3R29', 319 'gauge_names':['1','2','3','4','5','6','7','8', 320 '9','10','11','12','13','14','B'], 321 'gauge_x':[1.572, 2.572, 3.572, 4.572, 5.572, 322 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 323 12.572, 13.572, 14.572, -0.325], 324 'gauge_bed_elevation':[-0.237263, -0.213789, -0.190315, 325 -0.166841, -0.143368, -0.119894, 326 -0.096420, -0.072946, -0.049472, 327 -0.025998, -0.002524, 0.020949, 328 0.044423, 0.067897, -0.336000] 329 } 330 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 331 run_type = run_type, 332 outputdir_name=run_data['scenario_id']) 333 334 # #T3R28 335 run_data = {'xleft':[-3.875,0.0], # Av' of ADV and Gauge A 336 'xtoe':[0.0,0.0], 337 'xbeach':[1.285,0.090], 338 'xright':[16.1,.440], 339 'offshore_water_depth':.336, 340 'scenario_id':'T3R28', 341 'gauge_names':['1','2','3','4','5','6','7','8', 342 '9','10','11','12','13','14','B'], 343 'gauge_x':[1.572, 2.572, 3.572, 4.572, 5.572, 344 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 345 12.572, 13.572, 14.572, -0.325], 346 'gauge_bed_elevation':[-0.237263, -0.213789, -0.190315, 347 -0.166841, -0.143368, -0.119894, 348 -0.096420, -0.072946, -0.049472, 349 -0.025998, -0.002524, 0.020949, 350 0.044423, 0.067897, -0.336000] 351 } 352 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 353 run_type = run_type, 354 outputdir_name=run_data['scenario_id']) 355 356 # #T4R31 357 # xleft is different 358 run_data = {'xleft':[-2.43,0.0], # Av' of ADV and Gauge A 359 'xtoe':[0.0,0.0], 360 'xbeach':[1.285,0.090], 361 'xright':[16.1,.440], 362 'offshore_water_depth':.336, 363 'scenario_id':'T4R31', 364 'gauge_names':['1','2','3','4','5','6','7','8', 365 '9','10','11','12','13','14','B'], 366 'gauge_x':[1.572, 2.572, 3.572, 4.572, 5.572, 367 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 368 12.572, 13.572, 14.572, -0.325], 369 'gauge_bed_elevation':[-0.237263, -0.213789, -0.190315, 370 -0.166841, -0.143368, -0.119894, 371 -0.096420, -0.072946, -0.049472, 372 -0.025998, -0.002524, 0.020949, 373 0.044423, 0.067897, -0.336000] 374 } 375 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 376 run_type = run_type, 377 outputdir_name=run_data['scenario_id']) 378 379 # #T4R32 380 run_data = {'xleft':[-2.43,0.0], # Av' of ADV and Gauge A 381 'xtoe':[0.0,0.0], 382 'xbeach':[1.285,0.090], 383 'xright':[16.1,.440], 384 'offshore_water_depth':.336, 385 'scenario_id':'T4R32', 386 'gauge_names':['1','2','3','4','5','6','7','8', 387 '9','10','11','12','13','14','B'], 388 'gauge_x':[1.572, 2.572, 3.572, 4.572, 5.572, 389 6.572, 7.572, 8.572, 9.572, 10.572, 11.572, 390 12.572, 13.572, 14.572, -0.325], 391 'gauge_bed_elevation':[-0.237263, -0.213789, -0.190315, 392 -0.166841, -0.143368, -0.119894, 393 -0.096420, -0.072946, -0.049472, 394 -0.025998, -0.002524, 0.020949, 395 0.044423, 0.067897, -0.336000] 396 } 397 main( run_data['scenario_id'] + '_boundary.tsm' , run_data, 398 run_type = run_type, 399 outputdir_name=run_data['scenario_id'])
Note: See TracChangeset
for help on using the changeset viewer.