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

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

Updating scripts

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
22import project
23import csv
24
25directory = project.output_dir
26
27time_dir1 = '20081211_154006_run_final_0.6_27255_alpha0.1_kvanputt'
28##time_dir2 = '20081211_162311_run_final_0_27255_alpha0.1_kvanputt'
29##time_dir3 = '20081211_162346_run_final_0_68693_alpha0.1_kvanputt'
30##time_dir4 = '20081211_162433_run_final_0.6_68693_alpha0.1_kvanputt'
31##time_dir5 = '20081211_162656_run_final_0.6_27283_alpha0.1_kvanputt'
32##time_dir6 = '20081211_162744_run_final_0_27283_alpha0.1_kvanputt'
33
34time_dirs = [time_dir1] #4, time_dir5] #, time_dir3, time_dir4, time_dir5, time_dir6]
35
36buildings = project.building_in_dir_name
37
38for time_dir in time_dirs:
39   
40    time_dir_name = time_dir[-25:][:-18]
41       
42    building_marker = '_m_'+ time_dir_name
43    name = directory+time_dir+sep+project.scenario_name #basename for the sww files
44   
45    inundation_damage(name, buildings, building_marker)
46    #add_depth_and_momentum2csv(name, buildings, building_marker)
47   
48    building_marker_dir_name = project.gauges_dir + project.building + building_marker + '.csv'
49    out_file = directory+time_dir+ sep+'busselton_res.csv'
50    print 'out file %s' %out_file
51    print 'building_marker_dir_name %s' %building_marker_dir_name
52    csv_fd = open(building_marker_dir_name, 'r')
53    output_file = open(out_file, 'w')
54
55    reader = csv.reader(csv_fd)
56    writer = csv.writer(output_file, lineterminator='\n')
57
58    for record in reader:
59       newline = record[-8:]
60       newline.insert(0,record[0])
61       newline.insert(1,record[1])
62       newline.insert(2,record[2])
63       writer.writerow(newline)
64       
65    print 'output file printed to: %s' %out_file
66    csv_fd.close()
67    output_file.close()
68     
69
70   
Note: See TracBrowser for help on using the repository browser.