source: anuga_work/production/bunbury_storm_surge_2009/get_runup.py @ 7613

Last change on this file since 7613 was 7613, checked in by fountain, 14 years ago

Bunbury storm surge modelling

File size: 2.5 KB
Line 
1# Standard modules
2from os import sep
3import os
4from os.path import dirname, basename
5from os import mkdir, access, F_OK
6from os.path import join
7from anuga.utilities.polygon import read_polygon
8from shutil import copy
9import time
10import sys
11# Related major packages
12from anuga.shallow_water.data_manager import get_maximum_inundation_data
13from anuga.shallow_water.data_manager import csv2polygons
14
15# Application specific imports
16from setup_model import project  # Definition of file names and polygons
17import csv
18directory = project.output_folder
19
20time_dir1 = '20090508_150215_run_final_0_51469_lfountai'
21time_dir2 = '20090511_161526_run_final_1.1_51469_kvanputt'
22time_dir3 = '20090511_165539_run_final_0_50863_lfountai'
23time_dir4 = '20090521_220101_run_final_1.1_50863_kvanputt'
24time_dir5 = '20090518_154710_run_final_0_50994_lfountai'
25time_dir6 = '20090519_160510_run_final_1.1_50994_lfountai'
26time_dir7 = '20090522_164526_run_final_0_51392_lfountai'
27time_dir8 = '20090522_164640_run_final_1.1_51392_lfountai'
28time_dir9 = '20090522_164948_run_final_0_51423_lfountai'
29time_dir10 = '20090522_165600_run_final_1.1_51423_lfountai'
30
31time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5,
32             time_dir6, time_dir7, time_dir8, time_dir9, time_dir10]
33
34
35# polygons is a dictionary of polygon data indexed by 'id'
36# values is a dictionary of polygon names indexed by 'id'
37polygons, values = csv2polygons(project.images)
38print 'Creating %d highest runup' % len(polygons)
39
40# create a dictionary {<polygon_name>: <polygon_data>, ...}
41area_dictionary = {}
42for id in polygons:
43    area_dictionary[values[id]] = polygons[id] 
44
45# for each time directory ...
46for time_dir in time_dirs:
47    print 'time_dir ',time_dir
48    basename = join(directory, time_dir, project.scenario_name)
49
50    out_file = basename+'_runup.csv'
51    output_file = open(out_file, 'w')
52    s = 'area,q,x,y\n' 
53    output_file.write(s)
54
55    # iterate over polygon names
56    for which_area in values.itervalues():
57        print 'which_area = %s' % which_area
58        polygon = area_dictionary[which_area]
59       
60        q, loc = get_maximum_inundation_data(basename+'.sww',
61                                             polygon=polygon, verbose=True)
62
63        print '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1])
64        s = '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1])
65
66        output_file.write(s)
67
68        print 'output file printed to: %s' %out_file
69    output_file.close()
Note: See TracBrowser for help on using the repository browser.