source: anuga_work/production/broome_2006/run_broome.py @ 4058

Last change on this file since 4058 was 3972, checked in by sexton, 18 years ago

(i) incorporating new supply of interpolated data for Broome (ii) updating report to look at MOST versus ANUGA for Hobart scenario

File size: 9.0 KB
Line 
1"""Script for running a tsunami inundation scenario for Broome, WA, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.outputtimedir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a tsunami wave generated by MOST.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Nick Bartzis, GA - 2006
11"""
12
13#-------------------------------------------------------------------------------
14# Import necessary modules
15#-------------------------------------------------------------------------------
16
17# Standard modules
18import os
19import time
20from shutil import copy
21from os.path import dirname, basename
22from os import mkdir, access, F_OK, sep
23import sys
24
25# Related major packages
26from anuga.shallow_water import Domain, Reflective_boundary, \
27                            Dirichlet_boundary, Time_boundary, File_boundary
28from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
29from anuga.abstract_2d_finite_volumes.combine_pts import combine_rectangular_points_files
30from anuga.geospatial_data.geospatial_data import *
31from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
32
33# Application specific imports
34import project                 # Definition of file names and polygons
35
36#-------------------------------------------------------------------------------
37# Copy scripts to time stamped output directory and capture screen
38# output to file
39#-------------------------------------------------------------------------------
40
41# creates copy of code in output dir
42copy_code_files(project.outputtimedir,__file__,dirname(project.__file__)+sep+ project.__name__+'.py' )
43myid = 0
44numprocs = 1
45start_screen_catcher(project.outputtimedir, myid, numprocs)
46
47print 'USER:    ', project.user
48
49#-------------------------------------------------------------------------------
50# Preparation of topographic data
51#
52# Convert ASC 2 DEM 2 PTS using source data and store result in source data
53#-------------------------------------------------------------------------------
54
55# filenames
56onshore_dem_name = project.onshore_dem_name
57offshore_interp_dem_name = project.offshore_interp_dem_name
58coast_points = project.coast_dem_name
59meshname = project.meshname+'.msh'
60
61# creates DEM from asc data
62convert_dem_from_ascii2netcdf(onshore_dem_name, use_cache=True, verbose=True)
63
64#creates pts file for onshore DEM
65dem2pts(onshore_dem_name, use_cache=True, verbose=True)
66
67# creates DEM from asc data
68convert_dem_from_ascii2netcdf(offshore_interp_dem_name, use_cache=True, verbose=True)
69
70#creates pts file for offshore interpolated DEM
71dem2pts(offshore_interp_dem_name, use_cache=True, verbose=True)
72
73print 'create offshore'
74G1 = Geospatial_data(file_name = project.offshore_dem_name1 + '.xya')+\
75     Geospatial_data(file_name = project.offshore_dem_name2 + '.xya')+\
76     Geospatial_data(file_name = project.offshore_dem_name3 + '.xya')+\
77     Geospatial_data(file_name = project.offshore_dem_name4 + '.xya')+\
78     Geospatial_data(file_name = project.offshore_dem_name5 + '.xya')+\
79     Geospatial_data(file_name = project.offshore_dem_name6 + '.xya')+\
80     Geospatial_data(file_name = project.offshore_dem_name7 + '.xya')+\
81     Geospatial_data(file_name = project.offshore_dem_name8 + '.xya')+\
82     Geospatial_data(file_name = project.offshore_dem_name9 + '.xya')+\
83     Geospatial_data(file_name = project.offshore_dem_name10 + '.xya')+\
84     Geospatial_data(file_name = project.offshore_dem_name11 + '.xya')+\
85     Geospatial_data(file_name = project.offshore_dem_name12 + '.xya')+\
86     Geospatial_data(file_name = project.offshore_dem_name13 + '.xya')+\
87     Geospatial_data(file_name = project.offshore_dem_name14 + '.xya')+\
88     Geospatial_data(file_name = project.offshore_dem_name15 + '.xya')+\
89     Geospatial_data(file_name = project.offshore_dem_name16 + '.xya')+\
90     Geospatial_data(file_name = project.offshore_dem_name17 + '.xya')+\
91     Geospatial_data(file_name = project.offshore_dem_name18 + '.xya')+\
92     Geospatial_data(file_name = project.offshore_dem_name19 + '.xya')+\
93     Geospatial_data(file_name = project.offshore_dem_name20 + '.xya')+\
94     Geospatial_data(file_name = project.offshore_dem_name21 + '.xya')+\
95     Geospatial_data(file_name = project.offshore_dem_name22 + '.xya')+\
96     Geospatial_data(file_name = project.offshore_interp_dem_name + '.pts')
97print 'create onshore'
98G2 = Geospatial_data(file_name = project.onshore_dem_name + '.pts')
99print 'create coast'
100G3 = Geospatial_data(file_name = project.coast_dem_name + '.xya')
101print 'add'
102G = G1 + G2 + G3
103print 'export points'
104G.export_points_file(project.combined_dem_name + '.pts')
105G.export_points_file(project.combined_dem_name + '.xya')
106#----------------------------------------------------------------------------
107# Create the triangular mesh based on overall clipping polygon with a tagged
108# boundary and interior regions defined in project.py along with
109# resolutions (maximal area of per triangle) for each polygon
110#-------------------------------------------------------------------------------
111
112from anuga.pmesh.mesh_interface import create_mesh_from_regions
113remainder_res = 500000
114local_res = 25000
115broome_res = 5000
116coast_res = 500
117interior_regions = [[project.poly_broome1, local_res],
118                    [project.poly_broome2, broome_res],
119                    [project.poly_broome3, coast_res]]
120
121from project import number_mesh_triangles
122print 'estimate of number of triangles', \
123      number_mesh_triangles(interior_regions, project.polyAll, remainder_res)
124
125from caching import cache
126_ = cache(create_mesh_from_regions,
127          project.polyAll,
128           {'boundary_tags': {'e0': [0], 'e1': [1], 'e2': [2],
129                              'e3': [3], 'e4':[4], 'e5': [5],
130                              'e6': [6]},
131           'maximum_triangle_area': remainder_res,
132           'filename': meshname,
133           'interior_regions': interior_regions},
134          verbose = True, evaluate=False)
135print 'created mesh'
136
137#-------------------------------------------------------------------------------                                 
138# Setup computational domain
139#-------------------------------------------------------------------------------                                 
140domain = Domain(meshname, use_cache = True, verbose = True)
141
142print 'Number of triangles = ', len(domain)
143print 'The extent is ', domain.get_extent()
144print domain.statistics()
145
146domain.set_name(project.basename)
147domain.set_datadir(project.outputtimedir)
148domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
149domain.set_minimum_storable_height(0.01)
150
151#-------------------------------------------------------------------------------                                 
152# Setup initial conditions
153#-------------------------------------------------------------------------------
154
155tide = 0.0
156domain.set_quantity('stage', tide)
157domain.set_quantity('friction', 0.0) 
158domain.set_quantity('elevation', 
159                    filename = project.combined_dem_name + '.pts',
160                    use_cache = True,
161                    verbose = True,
162                    alpha = 0.1
163                    )
164
165#-------------------------------------------------------------------------------                                 
166# Setup boundary conditions
167#-------------------------------------------------------------------------------
168'''
169print 'start urs2sww'
170print '', project.boundary_basename
171from anuga.shallow_water.data_manager import urs2sww
172
173south = project.south
174north = project.north
175west  = project.west
176east  = project.east
177
178#note only need to do when an SWW file for the MOST boundary doesn't exist
179cache(urs2sww,
180      (source_dir + project.boundary_basename,
181       source_dir + project.boundary_basename),
182      {'verbose': True,
183       'minlat': south,
184       'maxlat': north,
185       'minlon': west,
186       'maxlon': east,
187       #'origin': domain.geo_reference.get_origin(),
188       'mean_stage': tide,
189       'zscale': 1,                 #Enhance tsunami
190       'fail_on_NaN': False,
191       'inverted_bathymetry': True},
192      #evaluate = True,
193       verbose = True,
194       dependencies = source_dir + project.boundary_basename + '.sww')
195
196'''
197print 'Available boundary tags', domain.get_boundary_tags()
198
199#Bf = File_boundary(source_dir + project.boundary_basename + '.sww',
200#                    domain, verbose = True)
201Br = Reflective_boundary(domain)
202Bd = Dirichlet_boundary([tide,0,0])
203
204# 7 min square wave starting at 1 min, 6m high
205Bw = Time_boundary(domain = domain,
206                   f=lambda t: [(60<t<480)*10, 0, 0])
207
208domain.set_boundary( {'e0': Bd,  'e1': Bd, 'e2': Bd, 'e3': Bd, 'e4': Bd,
209                      'e5': Bd,  'e6': Bd} )
210
211
212#-------------------------------------------------------------------------------                                 
213# Evolve system through time
214#-------------------------------------------------------------------------------
215import time
216t0 = time.time()
217
218for t in domain.evolve(yieldstep = 240, finaltime = 480): 
219    domain.write_time()
220    domain.write_boundary_statistics(tags = 'e14')     
221   
222print 'That took %.2f seconds' %(time.time()-t0)
223
224print 'finished'
Note: See TracBrowser for help on using the repository browser.