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_134504_run_final_0.6_27255_Bt_kvanputt' |
---|
20 | time_dir2 = '20090324_140411_run_final_0.6_27283_Bt_kvanputt' |
---|
21 | time_dir3 = '20090324_140741_run_final_0.6_68693_Bt_kvanputt' |
---|
22 | time_dir4 = '20090327_155230_run_final_0_68693_Bt_kvanputt' |
---|
23 | time_dir5 = '20090327_160022_run_final_0_27283_Bt_kvanputt' |
---|
24 | time_dir6 = '20090327_160043_run_final_0_27255_Bt_kvanputt' |
---|
25 | |
---|
26 | time_dirs = [time_dir6] #, time_dir3] |
---|
27 | |
---|
28 | interior_region = [] |
---|
29 | for region in project.interior_regions_data[:1]: |
---|
30 | polygon = read_polygon(join(project.polygons_folder, |
---|
31 | region[0])) |
---|
32 | interior_region.append(polygon) |
---|
33 | |
---|
34 | area_dictionary = {'Geraldton': interior_region[0]} |
---|
35 | |
---|
36 | area = ['Geraldton'] |
---|
37 | |
---|
38 | for time_dir in time_dirs: |
---|
39 | |
---|
40 | basename = join(directory, time_dir, project.scenario_name) |
---|
41 | |
---|
42 | out_file = basename+'_runup.csv' |
---|
43 | output_file = open(out_file, 'w') |
---|
44 | s = 'area,q,x,y\n' |
---|
45 | output_file.write(s) |
---|
46 | print 'basename ',basename |
---|
47 | |
---|
48 | for which_area in area: |
---|
49 | if which_area not in area_dictionary: |
---|
50 | print 'Unrecognized variable name: %s' % which_area |
---|
51 | break |
---|
52 | |
---|
53 | polygon = area_dictionary[which_area] |
---|
54 | |
---|
55 | print 'Which area ',which_area |
---|
56 | |
---|
57 | q, loc = get_maximum_inundation_data(basename+'.sww', |
---|
58 | polygon=polygon, verbose=True) |
---|
59 | |
---|
60 | print '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1]) |
---|
61 | s = '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1]) |
---|
62 | |
---|
63 | output_file.write(s) |
---|
64 | |
---|
65 | print 'output file printed to: %s' %out_file |
---|
66 | output_file.close() |
---|