Changeset 3456
- Timestamp:
- Aug 4, 2006, 5:04:14 PM (19 years ago)
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
development/dam_2006/project.py
r3423 r3456 39 39 #gaugetimeseries = gaugedir + 'onslow' 40 40 depth_filename = outputtimedir + "depth.csv" 41 velocity_filename = outputtimedir + "velocity.csv" 41 velocity_x_filename = outputtimedir + "velocity_x.csv" 42 velocity_y_filename = outputtimedir + "velocity_y.csv" 42 43 43 44 -
development/dam_2006/run_dam.py
r3447 r3456 126 126 points, 127 127 project.depth_filename, 128 project.velocity_filename) 128 project.velocity_x_filename, 129 project.velocity_y_filename) 129 130 130 131 #------------------------------------------------------------- -
inundation/fit_interpolate/interpolate.py
r3452 r3456 281 281 points, 282 282 depth_file, 283 velocity_file, 283 velocity_x_file, 284 velocity_y_file, 284 285 #quantities = ['depth', 'velocity'], 285 286 verbose=True, … … 309 310 310 311 depth_writer = writer(file(depth_file, "wb")) 311 velocity_writer = writer(file(velocity_file, "wb")) 312 velocity_x_writer = writer(file(velocity_x_file, "wb")) 313 velocity_y_writer = writer(file(velocity_y_file, "wb")) 312 314 # Write heading 313 315 heading = [str(x[0])+ ':' + str(x[1]) for x in points] 314 316 heading.insert(0, "time") 315 317 depth_writer.writerow(heading) 316 velocity_ writer.writerow(heading)317 #for row in someiterable:318 #csvwriter.writerow(row)318 velocity_x_writer.writerow(heading) 319 velocity_y_writer.writerow(heading) 320 319 321 for time in callable_sww.get_time(): 320 322 depths = [time] 321 velocitys = [time] 323 velocity_xs = [time] 324 velocity_ys = [time] 322 325 for point_i, point in enumerate(points): 323 326 quantities = callable_sww(time,point_i) … … 326 329 w = quantities[0] 327 330 z = quantities[1] 328 uh= quantities[2]329 vh= quantities[3]331 momentum_x = quantities[2] 332 momentum_y = quantities[3] 330 333 depth = w - z 331 334 332 if w == NAN or z == NAN or uh == NAN or vh== NAN:333 velocity = NAN335 if w == NAN or z == NAN or momentum_x == NAN: 336 velocity_x = NAN 334 337 else: 335 momentum = sqrt(uh*uh + vh*vh)336 338 if depth > 1.e-30: # use epsilon 337 velocity = momentum/ depth #Absolute velocity339 velocity_x = momentum_x / depth #Absolute velocity 338 340 else: 339 velocity = 0 341 velocity_x = 0 342 if w == NAN or z == NAN or momentum_y == NAN: 343 velocity_y = NAN 344 else: 345 if depth > 1.e-30: # use epsilon 346 velocity_y = momentum_y / depth #Absolute velocity 347 else: 348 velocity_y = 0 340 349 depths.append(depth) 341 velocitys.append(velocity) 350 velocity_xs.append(velocity_x) 351 velocity_ys.append(velocity_y) 342 352 depth_writer.writerow(depths) 343 velocity_writer.writerow(velocitys) 353 velocity_x_writer.writerow(velocity_xs) 354 velocity_y_writer.writerow(velocity_ys) 344 355 345 356 class Interpolation_function: -
inundation/fit_interpolate/test_interpolate.py
r3452 r3456 1409 1409 points = [[5.0,1.],[0.5,2.]] 1410 1410 depth_file = tempfile.mktemp(".csv") 1411 velocity_file = tempfile.mktemp(".csv") 1412 interpolate_sww2csv(sww.filename, points, depth_file, velocity_file, 1411 velocity_x_file = tempfile.mktemp(".csv") 1412 velocity_y_file = tempfile.mktemp(".csv") 1413 interpolate_sww2csv(sww.filename, points, depth_file, 1414 velocity_x_file, 1415 velocity_y_file, 1413 1416 verbose=False) 1414 1417 1415 1418 depth_answers_array = [[0.0, 6.0, 1.5], [2.0, 15., 10.5]] 1416 velocity_answers_array = [[0.0, 5./6.0, 5./1.5], [2.0, 5./15.,5./10.5]] 1419 velocity_x_answers_array = [[0.0, 3./6.0, 3./1.5], 1420 [2.0, 3./15., 3/10.5]] 1421 velocity_y_answers_array = [[0.0, 4./6.0, 4./1.5], 1422 [2.0, 4./15., 4./10.5]] 1417 1423 depth_file_handle = file(depth_file) 1418 1424 depth_reader = csv.reader(depth_file_handle) 1419 1425 depth_reader.next() 1420 velocity_ file_handle = file(velocity_file)1421 velocity_ reader = csv.reader(velocity_file_handle)1422 velocity_ reader.next()1426 velocity_x_file_handle = file(velocity_x_file) 1427 velocity_x_reader = csv.reader(velocity_x_file_handle) 1428 velocity_x_reader.next() 1423 1429 for depths, velocitys, depth_answers, velocity_answers in map(None, 1424 1430 depth_reader, 1425 velocity_ reader,1431 velocity_x_reader, 1426 1432 depth_answers_array, 1427 velocity_ answers_array):1433 velocity_x_answers_array): 1428 1434 for i in range(len(depths)): 1429 1435 #print "depths",depths[i] … … 1435 1441 assert allclose(float(velocitys[i]), velocity_answers[i]), msg 1436 1442 1443 velocity_y_file_handle = file(velocity_y_file) 1444 velocity_y_reader = csv.reader(velocity_y_file_handle) 1445 velocity_y_reader.next() 1446 for velocitys, velocity_answers in map(None, 1447 velocity_y_reader, 1448 velocity_y_answers_array): 1449 for i in range(len(depths)): 1450 #print "depths",depths[i] 1451 #print "depth_answers",depth_answers[i] 1452 #print "velocitys",velocitys[i] 1453 #print "velocity_answers_array", velocity_answers[i] 1454 msg = 'Interpolation failed' 1455 assert allclose(float(depths[i]), depth_answers[i]), msg 1456 assert allclose(float(velocitys[i]), velocity_answers[i]), msg 1457 1437 1458 # clean up 1438 1459 depth_file_handle.close() 1439 velocity_file_handle.close() 1460 velocity_y_file_handle.close() 1461 velocity_x_file_handle.close() 1440 1462 #print "sww.filename",sww.filename 1441 1463 os.remove(sww.filename) 1442 1464 os.remove(depth_file) 1443 os.remove(velocity_file) 1465 os.remove(velocity_x_file) 1466 os.remove(velocity_y_file) 1444 1467 #------------------------------------------------------------- 1445 1468 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.