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

Last change on this file since 7385 was 6984, checked in by kristy, 16 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_dir6] #, time_dir3, time_dir4, time_dir5, time_dir6]
36
37buildings = project.building_exposure
38
39for time_dir in time_dirs:
40   
41    time_dir_name = time_dir[-20:][:-12]
42    print time_dir_name
43       
44    building_marker = '_m_'+ time_dir_name
45    basename = join(directory, time_dir, project.scenario_name) #basename for the sww files
46   
47    inundation_damage(basename, buildings, building_marker)
48    #add_depth_and_momentum2csv(name, buildings, building_marker)
49   
50    building_marker_dir_name = join(project.gauges_folder,
51                                    project.building_exposure_filename[:-4]) + building_marker + '.csv'
52    out_file = basename + '_res.csv'
53    print 'out file %s' %out_file
54    print 'building_marker_dir_name %s' %building_marker_dir_name
55    csv_fd = open(building_marker_dir_name, 'r')
56    output_file = open(out_file, 'w')
57
58    reader = csv.reader(csv_fd)
59    writer = csv.writer(output_file, lineterminator='\n')
60
61    for record in reader:
62       newline = record[-8:]
63       newline.insert(0,record[0])
64       newline.insert(1,record[1])
65       newline.insert(2,record[2])
66       writer.writerow(newline)
67       
68    print 'output file printed to: %s' %out_file
69    csv_fd.close()
70    output_file.close()
71     
72
73   
Note: See TracBrowser for help on using the repository browser.