Changeset 6272
- Timestamp:
- Feb 4, 2009, 2:14:51 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_core/source/anuga/abstract_2d_finite_volumes/util.py
r6194 r6272 2489 2489 base_name=base, 2490 2490 verbose=verbose) 2491 2492 print 'sww files', sww_files 2491 2493 2492 2494 #to make all the quantities lower case for file_function … … 2497 2499 2498 2500 core_quantities = ['stage', 'elevation', 'xmomentum', 'ymomentum'] 2499 2501 2502 gauge_file = out_name 2503 2504 heading = [quantity for quantity in quantities] 2505 heading.insert(0,'time') 2506 2507 #create a list of csv writers for all the points and write header 2508 points_writer = [] 2509 for i,point in enumerate(points): 2510 points_writer.append(writer(file(dir_name + sep + gauge_file 2511 + point_name[i] + '.csv', "wb"))) 2512 points_writer[i].writerow(heading) 2513 2514 if verbose: print 'Writing csv files' 2515 2500 2516 for sww_file in sww_files: 2501 2517 sww_file = join(dir_name, sww_file+'.sww') … … 2505 2521 verbose=verbose, 2506 2522 use_cache=use_cache) 2507 gauge_file = out_name 2508 2509 heading = [quantity for quantity in quantities] 2510 heading.insert(0,'time') 2511 2512 #create a list of csv writers for all the points and write header 2513 points_writer = [] 2514 for i,point in enumerate(points): 2515 points_writer.append(writer(file(dir_name + sep + gauge_file 2516 + point_name[i] + '.csv', "wb"))) 2517 points_writer[i].writerow(heading) 2518 2519 if verbose: print 'Writing csv files' 2520 2521 for time in callable_sww.get_time(): 2522 for point_i, point in enumerate(points_array): 2523 #add domain starttime to relative time. 2524 points_list = [time + callable_sww.starttime] 2525 point_quantities = callable_sww(time,point_i) 2523 2524 2525 for time in callable_sww.get_time(): 2526 for point_i, point in enumerate(points_array): 2527 #add domain starttime to relative time. 2528 points_list = [time + callable_sww.starttime] 2529 point_quantities = callable_sww(time,point_i) 2530 2531 for quantity in quantities: 2532 if quantity == NAN: 2533 print 'quantity does not exist in' % callable_sww.get_name 2534 else: 2535 if quantity == 'stage': 2536 points_list.append(point_quantities[0]) 2537 2538 if quantity == 'elevation': 2539 points_list.append(point_quantities[1]) 2540 2541 if quantity == 'xmomentum': 2542 points_list.append(point_quantities[2]) 2543 2544 if quantity == 'ymomentum': 2545 points_list.append(point_quantities[3]) 2546 2547 if quantity == 'depth': 2548 points_list.append(point_quantities[0] 2549 - point_quantities[1]) 2550 2551 if quantity == 'momentum': 2552 momentum = sqrt(point_quantities[2]**2 2553 + point_quantities[3]**2) 2554 points_list.append(momentum) 2555 2556 if quantity == 'speed': 2557 #if depth is less than 0.001 then speed = 0.0 2558 if point_quantities[0] - point_quantities[1] < 0.001: 2559 vel = 0.0 2560 else: 2561 if point_quantities[2] < 1.0e6: 2562 momentum = sqrt(point_quantities[2]**2 2563 + point_quantities[3]**2) 2564 # vel = momentum/depth 2565 vel = momentum / (point_quantities[0] 2566 - point_quantities[1]) 2567 # vel = momentum/(depth + 1.e-6/depth) 2568 else: 2569 momentum = 0 2570 vel = 0 2571 2572 points_list.append(vel) 2573 2574 if quantity == 'bearing': 2575 points_list.append(calc_bearing(point_quantities[2], 2576 point_quantities[3])) 2577 2578 points_writer[point_i].writerow(points_list) 2526 2579 2527 for quantity in quantities:2528 if quantity == NAN:2529 print 'quantity does not exist in' % callable_sww.get_name2530 else:2531 if quantity == 'stage':2532 points_list.append(point_quantities[0])2533 2534 if quantity == 'elevation':2535 points_list.append(point_quantities[1])2536 2537 if quantity == 'xmomentum':2538 points_list.append(point_quantities[2])2539 2540 if quantity == 'ymomentum':2541 points_list.append(point_quantities[3])2542 2543 if quantity == 'depth':2544 points_list.append(point_quantities[0]2545 - point_quantities[1])2546 2547 if quantity == 'momentum':2548 momentum = sqrt(point_quantities[2]**22549 + point_quantities[3]**2)2550 points_list.append(momentum)2551 2552 if quantity == 'speed':2553 #if depth is less than 0.001 then speed = 0.02554 if point_quantities[0] - point_quantities[1] < 0.001:2555 vel = 0.02556 else:2557 if point_quantities[2] < 1.0e6:2558 momentum = sqrt(point_quantities[2]**22559 + point_quantities[3]**2)2560 # vel = momentum/depth2561 vel = momentum / (point_quantities[0]2562 - point_quantities[1])2563 # vel = momentum/(depth + 1.e-6/depth)2564 else:2565 momentum = 02566 vel = 02567 2568 points_list.append(vel)2569 2570 if quantity == 'bearing':2571 points_list.append(calc_bearing(point_quantities[2],2572 point_quantities[3]))2573 2574 points_writer[point_i].writerow(points_list)2575 2576 2580 2577 2581 ##
Note: See TracChangeset
for help on using the changeset viewer.