source: anuga_work/production/hobart_2009/get_runup_v2.py @ 7268

Last change on this file since 7268 was 7268, checked in by kristy, 15 years ago
File size: 2.4 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
20##time_dir1 = '20090601_133348_run_final_0.8_58280_None_kvanputt'
21##time_dir2 = '20090601_133503_run_final_0.8_58292_None_kvanputt'
22##time_dir3 = '20090505_150711_run_final_0_58280_None_kvanputt'
23##time_dir4 = '20090505_150805_run_final_0.8_58280_None_kvanputt'
24##time_dir5 = '20090505_151322_run_final_0.8_64477_None_kvanputt'
25##time_dir6 = '20090505_151447_run_final_0_64477_None_kvanputt'
26##
27##time_dirs = [time_dir2] #, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6]
28
29time_dir1 = '20090619_165107_run_final_0_58260_None_kvanputt'
30time_dir2 = '20090619_165136_run_final_0.8_58260_None_kvanputt'
31
32time_dirs = [time_dir1, time_dir2]
33
34# polygons is a dictionary of polygon data indexed by 'id'
35# values is a dictionary of polygon names indexed by 'id'
36polygons, values = csv2polygons(project.images)
37print 'Creating %d highest runup' % len(polygons)
38
39# create a dictionary {<polygon_name>: <polygon_data>, ...}
40area_dictionary = {}
41for id in polygons:
42    area_dictionary[values[id]] = polygons[id] 
43
44# for each time directory ...
45for time_dir in time_dirs:
46    print 'time_dir ',time_dir
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
54    # iterate over polygon names
55    for which_area in values.itervalues():
56        print 'which_area = %s' % which_area
57        polygon = area_dictionary[which_area]
58       
59        q, loc = get_maximum_inundation_data(basename+'.sww',
60                                             polygon=polygon, verbose=True)
61
62        print '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1])
63        s = '%s, %.6f, %.6f, %.6f\n' %(str(which_area), q, loc[0],loc[1])
64
65        output_file.write(s)
66
67        print 'output file printed to: %s' %out_file
68    output_file.close()
Note: See TracBrowser for help on using the repository browser.