[7545] | 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 | |
---|
[7689] | 19 | time_dir1 = '20100122_164958_run_final_0.0_27255_mosuchow' |
---|
| 20 | time_dir2 = '20100122_165026_run_final_0.6_27255_mosuchow' |
---|
| 21 | time_dir3 = '20100122_165106_run_final_0.0_27283_mosuchow' |
---|
| 22 | time_dir4 = '20100122_165125_run_final_0.6_27283_mosuchow' |
---|
| 23 | time_dir5 = '20100122_165210_run_final_0.0_68693_mosuchow' |
---|
| 24 | time_dir6 = '20100122_165236_run_final_0.6_68693_mosuchow' |
---|
| 25 | time_dir7 = '20100122_165331_run_final_0.0_68486_mosuchow' |
---|
| 26 | time_dir8 = '20100122_165725_run_final_0.6_68486_mosuchow' |
---|
[7545] | 27 | |
---|
[7689] | 28 | time_dirs = [time_dir8] #3, time_dir4, time_dir5] |
---|
[7545] | 29 | |
---|
| 30 | interior_region = [] |
---|
[7689] | 31 | for region in project.interior_regions_data[2:6]: |
---|
[7545] | 32 | polygon = read_polygon(join(project.polygons_folder, |
---|
| 33 | region[0])) |
---|
| 34 | interior_region.append(polygon) |
---|
[7689] | 35 | print region |
---|
[7545] | 36 | |
---|
[7689] | 37 | area_dictionary = {'Aoi3': interior_region[0], |
---|
| 38 | 'Aoi4' : interior_region[1], |
---|
| 39 | 'Area2' : interior_region[2], |
---|
| 40 | 'Area3' : interior_region[3]} |
---|
| 41 | |
---|
| 42 | |
---|
| 43 | area = ['Aoi3', 'Aoi4', 'Area2', 'Area3'] |
---|
[7545] | 44 | |
---|
| 45 | for time_dir in time_dirs: |
---|
| 46 | |
---|
| 47 | basename = join(directory, time_dir, project.scenario_name) |
---|
| 48 | |
---|
| 49 | out_file = basename+'_runup.csv' |
---|
| 50 | output_file = open(out_file, 'w') |
---|
| 51 | s = 'area,q,x,y\n' |
---|
| 52 | output_file.write(s) |
---|
| 53 | print 'basename ',basename |
---|
| 54 | |
---|
| 55 | for which_area in area: |
---|
| 56 | if which_area not in area_dictionary: |
---|
| 57 | print 'Unrecognized variable name: %s' % which_area |
---|
| 58 | break |
---|
| 59 | |
---|
| 60 | polygon = area_dictionary[which_area] |
---|
| 61 | |
---|
| 62 | print 'Which area ',which_area |
---|
| 63 | |
---|
| 64 | q, loc = get_maximum_inundation_data(basename+'.sww', |
---|
| 65 | polygon=polygon, verbose=True) |
---|
| 66 | |
---|
| 67 | print '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1]) |
---|
| 68 | s = '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1]) |
---|
| 69 | |
---|
| 70 | output_file.write(s) |
---|
| 71 | |
---|
| 72 | print 'output file printed to: %s' %out_file |
---|
| 73 | output_file.close() |
---|