source: anuga_work/production/carnarvon/run_building_inundation.py @ 7272

Last change on this file since 7272 was 7117, checked in by kristy, 16 years ago
File size: 2.3 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
27##time_dir1 = '20081202_084220_run_final_1_27283_alpha0.1_kvanputt'
28##time_dir2 = '20081202_084202_run_final_1_27255_alpha0.1_kvanputt'
29##time_dir3 = '20081202_084132_run_final_1_68693_alpha0.1_kvanputt'
30##time_dir4 = '20081202_084025_run_final_0_68693_alpha0.1_kvanputt'
31time_dir5 = '20081202_083932_run_final_0_27255_alpha0.1_kvanputt'
32##time_dir6 = '20081201_103449_run_final_0_27283_alpha0.1_kvanputt'
33
34time_dirs = [time_dir5] #, 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    time_dir_name = time_dir[-25:][:-18]
40    building_marker = '_m_'+ time_dir_name
41   
42    name = directory+time_dir+sep+project.scenario_name #basename for the sww files
43   
44    inundation_damage(name, buildings, building_marker)
45    #add_depth_and_momentum2csv(name, buildings, building_marker)
46   
47    building_marker_dir_name = project.gauges_dir + project.building + building_marker + '.csv'
48    out_file = directory+time_dir+ sep+'carnarvon_res.csv'
49    print 'out file %s' %out_file
50    print 'building_marker_dir_name %s' %building_marker_dir_name
51    csv_fd = open(building_marker_dir_name, 'r')
52    output_file = open(out_file, 'w')
53
54    reader = csv.reader(csv_fd)
55    writer = csv.writer(output_file, lineterminator='\n')
56
57    for record in reader:
58       newline = record[-8:]
59       newline.insert(0,record[0])
60       newline.insert(1,record[1])
61       newline.insert(2,record[2])
62       writer.writerow(newline)
63       
64    print 'output file printed to: %s' %out_file
65    csv_fd.close()
66    output_file.close()
67     
68
69   
Note: See TracBrowser for help on using the repository browser.