source: anuga_work/production/busselton/run_building_inundation.py @ 6019

Last change on this file since 6019 was 6019, checked in by kristy, 15 years ago

restructured and added more function to the script, now saving a new file into the time_dir folder

File size: 2.2 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
22import project
23import csv
24
25directory = project.output_dir
26
27time_dir1 = '20081009_184721_run_final_0.6_68693_alpha0.1_kvanputt'
28time_dir2 = '20081031_120515_run_final_0_27255_alpha0.1_kvanputt'
29time_dir3 = '20081031_120753_run_final_0.6_27283_alpha0.1_kvanputt'
30time_dir4 = '20081031_120642_run_final_0_27283_alpha0.1_kvanputt'
31time_dir5 = '20081031_120316_run_final_0_68693_alpha0.1_kvanputt'
32time_dir6 = '20081111_113832_run_final_0.6_27255_alpha0.1_kvanputt'
33
34time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6]
35
36buildings = project.building_in_dir_name
37
38for 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+project.scenario_name+'_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       writer.writerow(newline)
59       
60    print 'output file printed to: %s' %out_file
61    csv_fd.close()
62    output_file.close()
63     
64
65   
Note: See TracBrowser for help on using the repository browser.