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 os.path import join |
---|
7 | from anuga.utilities.polygon import read_polygon |
---|
8 | from shutil import copy |
---|
9 | import time |
---|
10 | import sys |
---|
11 | # Related major packages |
---|
12 | from anuga.shallow_water.data_manager import get_maximum_inundation_data |
---|
13 | |
---|
14 | # Application specific imports |
---|
15 | from setup_model import project # Definition of file names and polygons |
---|
16 | import csv |
---|
17 | directory = project.output_folder |
---|
18 | |
---|
19 | time_dir1 = '20090324_135427_run_final_0.6_27255_Bt_kvanputt' |
---|
20 | time_dir2 = '20090324_154957_run_final_0.6_68693_Bt_kvanputt' |
---|
21 | time_dir3 = '20090324_155028_run_final_0.6_27283_Bt_kvanputt' |
---|
22 | time_dir4 = '20090327_155353_run_final_0_27283_Bt_kvanputt' |
---|
23 | time_dir5 = '20090327_155659_run_final_0_27255_Bt_kvanputt' |
---|
24 | time_dir6 = '20090327_155803_run_final_0_68693_Bt_kvanputt' |
---|
25 | |
---|
26 | time_dirs = [time_dir4, time_dir5, time_dir6] #[time_dir1, time_dir2, time_dir3] #, |
---|
27 | |
---|
28 | interior_region = [] |
---|
29 | for region in project.interior_regions_data[:5]: |
---|
30 | polygon = read_polygon(join(project.polygons_folder, |
---|
31 | region[0])) |
---|
32 | interior_region.append(polygon) |
---|
33 | |
---|
34 | area_dictionary = {'Fremantle' : interior_region[0], |
---|
35 | 'Rockingham' : interior_region[1], |
---|
36 | 'Geordie' : interior_region[3], |
---|
37 | 'Sorrento' : interior_region[4]} |
---|
38 | |
---|
39 | area = ['Fremantle', 'Rockingham', 'Geordie', 'Sorrento'] |
---|
40 | |
---|
41 | for time_dir in time_dirs: |
---|
42 | |
---|
43 | basename = join(directory, time_dir, project.scenario_name) |
---|
44 | |
---|
45 | out_file = basename+'_runup.csv' |
---|
46 | output_file = open(out_file, 'w') |
---|
47 | s = 'area,q,x,y\n' |
---|
48 | output_file.write(s) |
---|
49 | print 'basename ',basename |
---|
50 | |
---|
51 | for which_area in area: |
---|
52 | if which_area not in area_dictionary: |
---|
53 | print 'Unrecognized variable name: %s' % which_area |
---|
54 | break |
---|
55 | |
---|
56 | polygon = area_dictionary[which_area] |
---|
57 | |
---|
58 | print 'Which area ',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() |
---|