source: anuga_work/production/busselton/busselton_rerun/run_building_inundation.py @ 6678

Last change on this file since 6678 was 6678, checked in by kristy, 15 years ago
File size: 2.4 KB
Line 
1""" Script for calculating maximum inundation at building locations
2
3    Inputs:
4
5    swwfile             - name of sww file
6                        - assume that all conserved quantities have been stored
7                   
8    buildings_filename  - name of file containing building data, sourced
9                          from NBED
10
11    Output:
12   
13    - building_filename (.csv) augmented to include maximum depth, momentum and
14      velocity and stored in same location as swwfile
15      Name = augmented_buildings.csv
16     
17    """
18
19from os import sep
20
21from anuga.damage_modelling.inundation_damage import add_depth_and_momentum2csv, inundation_damage
22from os.path import join
23from setup_model import project
24import csv
25
26directory = project.output_folder + sep
27
28time_dir1 = '20090324_134328_run_final_0.6_27255_Bt_kvanputt'
29time_dir2 = '20090324_140747_run_final_0.6_68693_Bt_kvanputt'
30time_dir3 = '20090327_152717_run_final_0.6_27283_Bt_kvanputt'
31time_dir4 = '20090327_160646_run_final_0_27255_Bt_kvanputt'
32time_dir5 = '20090327_161520_run_final_0_68693_Bt_kvanputt'
33time_dir6 = '20090330_120458_run_final_0_27283_Bt_kvanputt'
34
35time_dirs = [time_dir3, time_dir4, time_dir5]
36
37buildings = project.building_exposure
38
39for time_dir in time_dirs:
40   
41    time_dir_name = time_dir[-25:][:-18]
42       
43    building_marker = '_m_'+ time_dir_name
44    basename = join(directory, time_dir, project.scenario_name) #basename for the sww files
45   
46    inundation_damage(basename, buildings, building_marker)
47    #add_depth_and_momentum2csv(name, buildings, building_marker)
48   
49    building_marker_dir_name = join(project.gauges_folder,
50                                    project.building_exposure_filename[:-4]) + building_marker + '.csv'
51    out_file = basename + '_res.csv'
52    print 'out file %s' %out_file
53    print 'building_marker_dir_name %s' %building_marker_dir_name
54    csv_fd = open(building_marker_dir_name, 'r')
55    output_file = open(out_file, 'w')
56
57    reader = csv.reader(csv_fd)
58    writer = csv.writer(output_file, lineterminator='\n')
59
60    for record in reader:
61       newline = record[-8:]
62       newline.insert(0,record[0])
63       newline.insert(1,record[1])
64       newline.insert(2,record[2])
65       writer.writerow(newline)
66       
67    print 'output file printed to: %s' %out_file
68    csv_fd.close()
69    output_file.close()
70     
71
72   
Note: See TracBrowser for help on using the repository browser.