source: anuga_work/production/dampier_2006/build_dampier.py @ 4058

Last change on this file since 4058 was 4049, checked in by nick, 18 years ago

updates to dampier

File size: 9.5 KB
Line 
1"""Script for running tsunami inundation scenario for Dampier, 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.output_time_dir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated submarine landslide.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
11"""
12
13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17# Standard modules
18from os import sep
19from os.path import dirname, basename
20from os import mkdir, access, F_OK
21from shutil import copy
22import time
23import sys
24
25
26# Related major packages
27from anuga.shallow_water import Domain
28from anuga.shallow_water import Dirichlet_boundary
29from anuga.shallow_water import File_boundary
30from anuga.shallow_water import Reflective_boundary
31from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
32from anuga.pmesh.mesh_interface import create_mesh_from_regions
33from anuga.geospatial_data.geospatial_data import *
34from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
35
36# Application specific imports
37import project   # Definition of file names and polygons
38
39#------------------------------------------------------------------------------
40# Copy scripts to time stamped output directory and capture screen
41# output to file
42#------------------------------------------------------------------------------
43
44copy_code_files(project.output_build_time_dir,__file__, 
45               dirname(project.__file__)+sep+ project.__name__+'.py' )
46
47start_screen_catcher(project.output_build_time_dir)
48
49print 'USER:    ', project.user
50
51#-------------------------------------------------------------------------------
52# Preparation of topographic data
53#
54# Convert ASC 2 DEM 2 PTS using source data and store result in source data
55# Do for coarse and fine data
56# Fine pts file to be clipped to area of interest
57#-------------------------------------------------------------------------------
58
59'''
60# topography directory filenames
61onshore_dir_name = project.onshore_dir_name
62coast_dir_name = project.coast_dir_name
63islands_dir_name = project.islands_dir_name
64offshore_dir_name = project.offshore_dir_name
65offshore_dir_name1 = project.offshore_dir_name1
66offshore_dir_name2 = project.offshore_dir_name2
67offshore_dir_name3 = project.offshore_dir_name3
68offshore_dir_name4 = project.offshore_dir_name4
69offshore_dir_name5 = project.offshore_dir_name5
70offshore_dir_name6 = project.offshore_dir_name6
71offshore_dir_name7 = project.offshore_dir_name7
72offshore_dir_name8 = project.offshore_dir_name8
73offshore_dir_name9 = project.offshore_dir_name9
74offshore_dir_name10 = project.offshore_dir_name10
75offshore_dir_name11 = project.offshore_dir_name11
76offshore_dir_name12 = project.offshore_dir_name12
77offshore_dir_name13 = project.offshore_dir_name13
78offshore_dir_name14 = project.offshore_dir_name14
79
80# creates DEM from asc data
81convert_dem_from_ascii2netcdf(onshore_dir_name, use_cache=True, verbose=True)
82convert_dem_from_ascii2netcdf(islands_dir_name, use_cache=True, verbose=True)
83
84#creates pts file for onshore DEM
85dem2pts(onshore_dir_name,
86#        easting_min=project.eastingmin,
87#        easting_max=project.eastingmax,
88#        northing_min=project.northingmin,
89#        northing_max= project.northingmax,
90        use_cache=True,
91        verbose=True)
92
93#creates pts file for islands DEM
94dem2pts(islands_dir_name, use_cache=True, verbose=True)
95
96print'create Geospatial data objects from topographies'
97G1 = Geospatial_data(file_name = project.onshore_dir_name + '.pts')
98G2 = Geospatial_data(file_name = project.coast_dir_name + '.xya')
99G3 = Geospatial_data(file_name = project.islands_dir_name + '.pts')
100G_off = Geospatial_data(file_name = project.offshore_dir_name + '.xya')
101G_off1 = Geospatial_data(file_name = project.offshore_dir_name1 + '.xya')
102G_off2 = Geospatial_data(file_name = project.offshore_dir_name2 + '.xya')
103G_off3 = Geospatial_data(file_name = project.offshore_dir_name3 + '.xya')
104G_off4 = Geospatial_data(file_name = project.offshore_dir_name4 + '.xya')
105G_off5 = Geospatial_data(file_name = project.offshore_dir_name5 + '.xya')
106G_off6 = Geospatial_data(file_name = project.offshore_dir_name6 + '.xya')
107G_off7 = Geospatial_data(file_name = project.offshore_dir_name7 + '.xya')
108G_off8 = Geospatial_data(file_name = project.offshore_dir_name8 + '.xya')
109G_off9 = Geospatial_data(file_name = project.offshore_dir_name9 + '.xya')
110G_off10 = Geospatial_data(file_name = project.offshore_dir_name10 + '.xya')
111G_off11 = Geospatial_data(file_name = project.offshore_dir_name11 + '.xya')
112G_off12 = Geospatial_data(file_name = project.offshore_dir_name12 + '.xya')
113G_off13 = Geospatial_data(file_name = project.offshore_dir_name13 + '.xya')
114G_off14 = Geospatial_data(file_name = project.offshore_dir_name14 + '.xya')
115
116
117
118print'clip nw', project.clip_poly_nw
119print'clip e', project.clip_poly_e
120
121print'reading combined_dir_name'
122G_offshore_data = Geospatial_data(file_name = project.topographies_dir+'dampier_combined_elevation_final.pts')
123
124print'reading offshore_dir_name_old'
125G_offshore_old = Geospatial_data(file_name = project.offshore_dir_name_old + '.pts')
126
127
128print 'G_offshore_data_old_nw',
129G_nw_name = project.topographies_dir + 'nw_old_data'
130G_offshore_nw = G_offshore_old.clip(project.clip_poly_nw)
131G_offshore_nw.export_points_file(G_nw_name + '.pts')
132G_offshore_nw.export_points_file(G_nw_name + '.xya')
133G_nw = array(G_offshore_nw.get_data_points())
134print'shape of arr nw data', G_nw.shape
135print' max and min of array 0',max(G_nw[:,0]),min(G_nw[:,0])
136print' max and min of array 1',max(G_nw[:,1]),min(G_nw[:,1])
137
138print 'G_offshore_data_old_e'#, G_offshore_old_nw.get_data_points()
139G_e_name = project.topographies_dir+'e_old_data'
140G_offshore_e = G_offshore_old.clip(project.clip_poly_e)
141G_offshore_e.export_points_file(G_e_name + '.pts')
142G_offshore_e.export_points_file(G_e_name + '.xya')
143G_e = array(G_offshore_e.get_data_points())
144print'shape of arr e data', G_e.shape
145print' max and min of array 0',max(G_e[:,0]),min(G_e[:,0])
146print' max and min of array 1',max(G_e[:,1]),min(G_e[:,1])
147
148
149print 'G_offshore_data_mid_e'#, G_offshore_old_nw.get_data_points()
150G_mid_e_name = project.topographies_dir+'mid_e_old_data'
151G_offshore_mid_e = G_offshore_old.clip(project.clip_poly_mid_e)
152G_offshore_mid_e.export_points_file(G_mid_e_name + '.pts')
153G_offshore_mid_e.export_points_file(G_mid_e_name + '.xya')
154G_mid_e = array(G_offshore_mid_e.get_data_points())
155print'shape of arr e data', G_mid_e.shape
156print' max and min of array 0',max(G_mid_e[:,0]),min(G_mid_e[:,0])
157print' max and min of array 1',max(G_mid_e[:,1]),min(G_mid_e[:,1])
158
159print 'G_offshore_data_mid_w'#, G_offshore_old_nw.get_data_points()
160G_mid_w_name = project.topographies_dir+'mid_w_old_data'
161G_offshore_mid_w = G_offshore_old.clip(project.clip_poly_mid_w)
162G_offshore_mid_w.export_points_file(G_mid_w_name + '.pts')
163G_offshore_mid_w.export_points_file(G_mid_w_name + '.xya')
164G_mid_w = array(G_offshore_mid_w.get_data_points())
165print'shape of arr e data', G_mid_w.shape
166print' max and min of array 0',max(G_mid_w[:,0]),min(G_mid_w[:,0])
167print' max and min of array 1',max(G_mid_w[:,1]),min(G_mid_w[:,1])
168
169
170print 'G_offshore_data_old_e'#, G_offshore_old_e.get_data_points()
171print'add all geospatial objects'
172#G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4 + G_off5 \
173#    + G_off6 + G_off7 + G_off8 + G_off9 + G_off10 + G_off11 + G_off12 \
174#    + G_off13 + G_off14
175
176G = G_offshore_data + G_offshore_mid_w + G_offshore_mid_e
177print'shape of arr G data', G.get_data_points().shape
178
179
180#print'clip combined geospatial object by bounding polygon'
181G_clipped = G.clip(project.bounding_polygon)
182#FIXME: add a clip function to pts
183print'shape of clipped data', G_clipped.get_data_points().shape
184
185print'export combined DEM file'
186if access(project.topographies_time_dir,F_OK) == 0:
187    mkdir (project.topographies_time_dir)
188G_clipped.export_points_file(project.combined_time_dir_final_name + '.pts')
189G_clipped.export_points_file(project.combined_time_dir_final_name + '.xya')
190
191
192'''
193#-------------------------------------------------------------------------
194# Convert URS to SWW file for boundary conditions
195#-------------------------------------------------------------------------
196print 'starting to create boundary conditions'
197boundaries_in_dir_name = project.boundaries_in_dir_name
198
199from anuga.shallow_water.data_manager import urs2sww
200
201print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
202print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
203
204#import sys; sys.exit()
205
206#if access(project.boundaries_dir,F_OK) == 0:
207#    mkdir (project.boundaries_dir)
208
209from caching import cache
210cache(urs2sww,
211      (boundaries_in_dir_name,
212       project.boundaries_dir_name1), 
213      {'verbose': True,
214       'minlat': project.south_boundary,
215       'maxlat': project.north_boundary,
216       'minlon': project.west_boundary,
217       'maxlon': project.east_boundary,
218#       'minlat': project.south,
219#       'maxlat': project.north,
220#       'minlon': project.west,
221#       'maxlon': project.east,
222       'mint': 0, 'maxt': 40000,
223#       'origin': domain.geo_reference.get_origin(),
224       'mean_stage': project.tide,
225#       'zscale': 1,                 #Enhance tsunami
226       'fail_on_NaN': False},
227       verbose = True,
228       )
229#       dependencies = source_dir + project.boundary_basename + '.sww')
230
231
232
233
234
235
236
237
238
Note: See TracBrowser for help on using the repository browser.