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 | |
---|
19 | from os import sep |
---|
20 | |
---|
21 | from anuga.damage_modelling.inundation_damage import add_depth_and_momentum2csv, inundation_damage |
---|
22 | import project |
---|
23 | import csv |
---|
24 | |
---|
25 | directory = project.output_dir |
---|
26 | |
---|
27 | time_dir1 = '20081031_133353_run_final_0.6_68693_alpha0.1_kvanputt' |
---|
28 | time_dir2 = '20081031_133511_run_final_0_68693_alpha0.1_kvanputt' |
---|
29 | time_dir3 = '20081031_133624_run_final_0_27255_alpha0.1_kvanputt' |
---|
30 | time_dir4 = '20081031_133735_run_final_0.6_27255_alpha0.1_kvanputt' |
---|
31 | time_dir5 = '20081031_133841_run_final_0_27283_alpha0.1_kvanputt' |
---|
32 | time_dir6 = '20081031_133925_run_final_0.6_27283_alpha0.1_kvanputt' |
---|
33 | |
---|
34 | time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6] |
---|
35 | |
---|
36 | buildings = project.building_in_dir_name |
---|
37 | |
---|
38 | for time_dir in time_dirs: |
---|
39 | building_marker = '_modified' |
---|
40 | name = directory+time_dir+sep+project.scenario_name #basename for the sww files |
---|
41 | |
---|
42 | inundation_damage(name, buildings, building_marker) |
---|
43 | #add_depth_and_momentum2csv(name, buildings, building_marker) |
---|
44 | |
---|
45 | building_marker_dir_name = project.gauges_dir + project.building + building_marker + '.csv' |
---|
46 | out_file = directory+time_dir+ sep+'perth_res.csv' |
---|
47 | print 'out file %s' %out_file |
---|
48 | print 'building_marker_dir_name %s' %building_marker_dir_name |
---|
49 | csv_fd = open(building_marker_dir_name, 'r') |
---|
50 | output_file = open(out_file, 'w') |
---|
51 | |
---|
52 | reader = csv.reader(csv_fd) |
---|
53 | writer = csv.writer(output_file, lineterminator='\n') |
---|
54 | |
---|
55 | for record in reader: |
---|
56 | newline = record[-8:] |
---|
57 | newline.insert(0,record[0]) |
---|
58 | newline.insert(1,record[1]) |
---|
59 | newline.insert(2,record[2]) |
---|
60 | writer.writerow(newline) |
---|
61 | |
---|
62 | print 'output file printed to: %s' %out_file |
---|
63 | csv_fd.close() |
---|
64 | output_file.close() |
---|
65 | |
---|
66 | |
---|
67 | |
---|