1 | """Script for running tsunami inundation scenario for Dampier, WA, Australia. |
---|
2 | |
---|
3 | Source data such as elevation and boundary data is assumed to be available in |
---|
4 | directories specified by project.py |
---|
5 | The output sww file is stored in project.output_time_dir |
---|
6 | |
---|
7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
8 | the elevation data and a simulated submarine landslide. |
---|
9 | |
---|
10 | Ole 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 |
---|
18 | from os import sep |
---|
19 | from os.path import dirname, basename |
---|
20 | from os import mkdir, access, F_OK |
---|
21 | from shutil import copy |
---|
22 | import time |
---|
23 | import sys |
---|
24 | |
---|
25 | |
---|
26 | # Related major packages |
---|
27 | from anuga.shallow_water import Domain |
---|
28 | from anuga.shallow_water import Dirichlet_boundary |
---|
29 | from anuga.shallow_water import File_boundary |
---|
30 | from anuga.shallow_water import Reflective_boundary |
---|
31 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
32 | |
---|
33 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
34 | |
---|
35 | from anuga.geospatial_data.geospatial_data import * |
---|
36 | |
---|
37 | # Application specific imports |
---|
38 | import project # Definition of file names and polygons |
---|
39 | |
---|
40 | |
---|
41 | |
---|
42 | #------------------------------------------------------------------------------ |
---|
43 | # Copy scripts to time stamped output directory and capture screen |
---|
44 | # output to file |
---|
45 | #------------------------------------------------------------------------------ |
---|
46 | |
---|
47 | |
---|
48 | |
---|
49 | # creates copy of code in output dir if dir doesn't exist |
---|
50 | if access(project.output_time_dir,F_OK) == 0: |
---|
51 | mkdir (project.output_time_dir) |
---|
52 | copy (dirname(project.__file__) +sep+ project.__name__+'.py', |
---|
53 | project.output_time_dir + project.__name__+'.py') #copies project.py |
---|
54 | copy (__file__, project.output_time_dir + basename(__file__)) |
---|
55 | print 'project.output_time_dir',project.output_time_dir #copies this file |
---|
56 | |
---|
57 | |
---|
58 | |
---|
59 | |
---|
60 | boundary_dir_name = project.boundary_dir_name |
---|
61 | |
---|
62 | |
---|
63 | from anuga.shallow_water.data_manager import urs2sww |
---|
64 | |
---|
65 | print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary |
---|
66 | print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary |
---|
67 | |
---|
68 | #import sys; sys.exit() |
---|
69 | urs2sww(boundary_dir_name, |
---|
70 | # minlat=project.south, maxlat=project.north, |
---|
71 | # minlon= project.west, maxlon=project.east, |
---|
72 | # mint=0, maxt= 35000, |
---|
73 | verbose='true') |
---|
74 | |
---|
75 | import sys; sys.exit() |
---|
76 | #------------------------------------------------------------------------------- |
---|
77 | # Preparation of topographic data |
---|
78 | # |
---|
79 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
80 | # Do for coarse and fine data |
---|
81 | # Fine pts file to be clipped to area of interest |
---|
82 | #------------------------------------------------------------------------------- |
---|
83 | |
---|
84 | # topography directory filenames |
---|
85 | onshore_dir_name = project.onshore_dir_name |
---|
86 | coast_dir_name = project.coast_dir_name |
---|
87 | islands_dir_name = project.islands_dir_name |
---|
88 | offshore_dir_name = project.offshore_dir_name |
---|
89 | offshore_dir_name1 = project.offshore_dir_name1 |
---|
90 | offshore_dir_name2 = project.offshore_dir_name2 |
---|
91 | offshore_dir_name3 = project.offshore_dir_name3 |
---|
92 | offshore_dir_name4 = project.offshore_dir_name4 |
---|
93 | offshore_dir_name5 = project.offshore_dir_name5 |
---|
94 | offshore_dir_name6 = project.offshore_dir_name6 |
---|
95 | offshore_dir_name7 = project.offshore_dir_name7 |
---|
96 | offshore_dir_name8 = project.offshore_dir_name8 |
---|
97 | offshore_dir_name9 = project.offshore_dir_name9 |
---|
98 | offshore_dir_name10 = project.offshore_dir_name10 |
---|
99 | offshore_dir_name11 = project.offshore_dir_name11 |
---|
100 | offshore_dir_name12 = project.offshore_dir_name12 |
---|
101 | offshore_dir_name13 = project.offshore_dir_name13 |
---|
102 | offshore_dir_name14 = project.offshore_dir_name14 |
---|
103 | |
---|
104 | |
---|
105 | |
---|
106 | # files to be used |
---|
107 | #file_used = [] |
---|
108 | |
---|
109 | # creates DEM from asc data |
---|
110 | convert_dem_from_ascii2netcdf(onshore_dir_name, use_cache=True, verbose=True) |
---|
111 | convert_dem_from_ascii2netcdf(islands_dir_name, use_cache=True, verbose=True) |
---|
112 | |
---|
113 | #creates pts file for onshore DEM |
---|
114 | dem2pts(onshore_dir_name, |
---|
115 | # easting_min=project.eastingmin, |
---|
116 | # easting_max=project.eastingmax, |
---|
117 | # northing_min=project.northingmin, |
---|
118 | # northing_max= project.northingmax, |
---|
119 | use_cache=True, |
---|
120 | verbose=True) |
---|
121 | |
---|
122 | |
---|
123 | #creates pts file for islands DEM |
---|
124 | dem2pts(islands_dir_name, use_cache=True, verbose=True) |
---|
125 | |
---|
126 | |
---|
127 | print'create G1' |
---|
128 | G1 = Geospatial_data(file_name = project.onshore_dir_name + '.pts') |
---|
129 | G2 = Geospatial_data(file_name = project.coast_dir_name + '.xya') |
---|
130 | G3 = Geospatial_data(file_name = project.islands_dir_name + '.pts') |
---|
131 | G_off = Geospatial_data(file_name = project.offshore_dir_name + '.xya') |
---|
132 | G_off1 = Geospatial_data(file_name = project.offshore_dir_name1 + '.xya') |
---|
133 | G_off2 = Geospatial_data(file_name = project.offshore_dir_name2 + '.xya') |
---|
134 | G_off3 = Geospatial_data(file_name = project.offshore_dir_name3 + '.xya') |
---|
135 | G_off4 = Geospatial_data(file_name = project.offshore_dir_name4 + '.xya') |
---|
136 | G_off5 = Geospatial_data(file_name = project.offshore_dir_name5 + '.xya') |
---|
137 | G_off6 = Geospatial_data(file_name = project.offshore_dir_name6 + '.xya') |
---|
138 | G_off7 = Geospatial_data(file_name = project.offshore_dir_name7 + '.xya') |
---|
139 | G_off8 = Geospatial_data(file_name = project.offshore_dir_name8 + '.xya') |
---|
140 | G_off9 = Geospatial_data(file_name = project.offshore_dir_name9 + '.xya') |
---|
141 | G_off10 = Geospatial_data(file_name = project.offshore_dir_name10 + '.xya') |
---|
142 | G_off11 = Geospatial_data(file_name = project.offshore_dir_name11 + '.xya') |
---|
143 | G_off12 = Geospatial_data(file_name = project.offshore_dir_name12 + '.xya') |
---|
144 | G_off13 = Geospatial_data(file_name = project.offshore_dir_name13 + '.xya') |
---|
145 | G_off14 = Geospatial_data(file_name = project.offshore_dir_name14 + '.xya') |
---|
146 | |
---|
147 | print'add G1+G2+G3+all offshore data' |
---|
148 | G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4 + G_off5 \ |
---|
149 | + G_off6 + G_off7 + G_off8 + G_off9 + G_off10 + G_off11 + G_off12 \ |
---|
150 | + G_off13 + G_off14 |
---|
151 | |
---|
152 | G.clip(project.bounding_polygon) |
---|
153 | #FIXME: add a clip function to pts |
---|
154 | |
---|
155 | print'export G' |
---|
156 | G.export_points_file(project.combined_dir_name + '.pts') |
---|
157 | import sys; sys.exit() |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | #------------------------------------------------------------------------- |
---|
162 | # Convert URS to SWW file for boundary conditions |
---|
163 | #------------------------------------------------------------------------- |
---|
164 | |
---|
165 | # filenames |
---|
166 | meshname = project.mesh_name+'.msh' |
---|
167 | source_dir = project.boundarydir |
---|
168 | boundary_file = project.boundaryname |
---|
169 | |
---|
170 | print 'Available boundary tags', domain.get_boundary_tags() |
---|
171 | |
---|
172 | from anuga.shallow_water.data_manager import urs2sww |
---|
173 | |
---|
174 | urs2sww(boundary_file, |
---|
175 | minlat=project.north_boundary, maxlat=project.south_boundary, |
---|
176 | minlon= project.west_boundary, maxlon=project.east_boundary, |
---|
177 | verbose='true') |
---|
178 | |
---|
179 | |
---|
180 | |
---|
181 | |
---|
182 | |
---|
183 | |
---|