1 | # Standard modules |
---|
2 | from os import sep |
---|
3 | import os |
---|
4 | from os.path import dirname, basename |
---|
5 | from os import mkdir, access, F_OK |
---|
6 | from shutil import copy |
---|
7 | import time |
---|
8 | import sys |
---|
9 | # Related major packages |
---|
10 | from anuga.shallow_water.data_manager import get_maximum_inundation_data |
---|
11 | |
---|
12 | # Application specific imports |
---|
13 | import project # Definition of file names and polygons |
---|
14 | import csv |
---|
15 | directory = project.output_dir |
---|
16 | |
---|
17 | time_dir1 = '20081211_154006_run_final_0.6_27255_alpha0.1_kvanputt' |
---|
18 | ##time_dir2 = '20081211_162311_run_final_0_27255_alpha0.1_kvanputt' |
---|
19 | ##time_dir3 = '20081211_162346_run_final_0_68693_alpha0.1_kvanputt' |
---|
20 | ##time_dir4 = '20081211_162433_run_final_0.6_68693_alpha0.1_kvanputt' |
---|
21 | ##time_dir5 = '20081211_162656_run_final_0.6_27283_alpha0.1_kvanputt' |
---|
22 | ##time_dir6 = '20081211_162744_run_final_0_27283_alpha0.1_kvanputt' |
---|
23 | |
---|
24 | time_dirs = [time_dir1] #4, time_dir5] #, time_dir3, time_dir4, time_dir5, time_dir6] |
---|
25 | |
---|
26 | area_dictionary = {'Busselton': project.poly_aoi1, |
---|
27 | 'Bunbury' : project.poly_aoi2} |
---|
28 | |
---|
29 | area = ['Busselton', 'Bunbury'] |
---|
30 | |
---|
31 | for time_dir in time_dirs: |
---|
32 | |
---|
33 | name = directory+time_dir+sep+project.scenario_name |
---|
34 | |
---|
35 | out_file = name+'_runup.csv' |
---|
36 | output_file = open(out_file, 'w') |
---|
37 | s = 'area,q,x,y\n' |
---|
38 | output_file.write(s) |
---|
39 | print 'name ',name |
---|
40 | |
---|
41 | for which_area in area: |
---|
42 | if which_area not in area_dictionary: |
---|
43 | print 'Unrecognized variable name: %s' % which_area |
---|
44 | break |
---|
45 | |
---|
46 | polygon = area_dictionary[which_area] |
---|
47 | |
---|
48 | print 'Which area ',which_area |
---|
49 | |
---|
50 | q, loc = get_maximum_inundation_data (name+'.sww', polygon = polygon, verbose= True) |
---|
51 | |
---|
52 | print '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1]) |
---|
53 | s = '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1]) |
---|
54 | |
---|
55 | output_file.write(s) |
---|
56 | |
---|
57 | print 'output file printed to: %s' %out_file |
---|
58 | output_file.close() |
---|