1 | """Script for running tsunami inundation scenario for Perth, 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 | # Related major packages |
---|
26 | from anuga.shallow_water import Domain |
---|
27 | #from anuga.shallow_water import Dirichlet_boundary |
---|
28 | #from anuga.shallow_water import File_boundary |
---|
29 | #from anuga.shallow_water import Reflective_boundary |
---|
30 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
31 | #from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
32 | from anuga.geospatial_data.geospatial_data import * |
---|
33 | from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files |
---|
34 | |
---|
35 | # Application specific imports |
---|
36 | import project_fangauta # Definition of file names and polygons |
---|
37 | |
---|
38 | #------------------------------------------------------------------------------ |
---|
39 | # Copy scripts to time stamped output directory and capture screen |
---|
40 | # output to file |
---|
41 | #------------------------------------------------------------------------------ |
---|
42 | |
---|
43 | copy_code_files(project_fangauta.output_build_time_dir,__file__, |
---|
44 | dirname(project_fangauta.__file__)+sep+ project_fangauta.__name__+'.py' ) |
---|
45 | |
---|
46 | start_screen_catcher(project_fangauta.output_build_time_dir) |
---|
47 | |
---|
48 | print 'USER: ', project_fangauta.user |
---|
49 | |
---|
50 | #------------------------------------------------------------------------------- |
---|
51 | # Preparation of topographic data |
---|
52 | # |
---|
53 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
54 | # Do for coarse and fine data |
---|
55 | # Fine pts file to be clipped to area of interest |
---|
56 | #------------------------------------------------------------------------------- |
---|
57 | print"project.combined_dir_name",project_fangauta.combined_dir_name |
---|
58 | |
---|
59 | # topography directory filenames |
---|
60 | onshore_dir_name = project_fangauta.onshore_dir_name |
---|
61 | onshore_dir_name1 = project_fangauta.onshore_dir_name1 |
---|
62 | #island_in_dir_name = project_urs.island_in_dir_name |
---|
63 | #Multibeam_dir_name = project.Multibeam_dir_name |
---|
64 | Singlebeam_dir_name = project_fangauta.Singlebeam_dir_name |
---|
65 | addedpoint_dir_name = project_fangauta.addedpoint_dir_name |
---|
66 | #Chart_dir_name = project.Chart_dir_name |
---|
67 | #Derived_bath_dir_name = project.Derived_bath_dir_name |
---|
68 | #added_data_dir_name =project.added_data_dir_name |
---|
69 | |
---|
70 | |
---|
71 | print'create Geospatial data1 objects from topographies',onshore_dir_name + '.txt' |
---|
72 | G1 = Geospatial_data(file_name = onshore_dir_name + '.txt') |
---|
73 | #print'create Geospatial data2 objects from multibeam', Multibeam_dir_name + '.txt' |
---|
74 | #G_off = Geospatial_data(file_name = Multibeam_dir_name + '.txt') |
---|
75 | #print'create Geospatial data3 objects from island' |
---|
76 | #G3 = Geospatial_data(file_name = island_dir_name + '.pts') |
---|
77 | print'create Geospatial data3 objects from singlebeam',Singlebeam_dir_name + '.txt' |
---|
78 | G_off1 = Geospatial_data(file_name = Singlebeam_dir_name + '.txt') |
---|
79 | |
---|
80 | print'create Geospatial data1 objects from topographies',addedpoint_dir_name + '.txt' |
---|
81 | G2 = Geospatial_data(file_name = addedpoint_dir_name + '.txt') |
---|
82 | |
---|
83 | print'create Geospatial data1 objects from topographies',onshore_dir_name1 + '.txt' |
---|
84 | Goff2=Geospatial_data(file_name = onshore_dir_name1 + '.txt') |
---|
85 | #print'create Geospatial data4 objects from chart',Chart_dir_name + '.txt' |
---|
86 | #G_off2 = Geospatial_data(file_name = Chart_dir_name + '.txt') |
---|
87 | #print'create Geospatial data4 objects from derived bathymetry',Derived_bath_dir_name + '.txt' |
---|
88 | #G_off3 = Geospatial_data(file_name = Derived_bath_dir_name + '.txt') |
---|
89 | #print'create Geospatial data objects from added data',added_data_dir_name + '.txt' |
---|
90 | #G_off4 = Geospatial_data(file_name = added_data_dir_name + '.txt') |
---|
91 | Gislands=Goff2.clip(Geospatial_data(project_fangauta.poly_island_Pea))+Goff2.clip(Geospatial_data(project_fangauta.poly_island_Mua)) |
---|
92 | print'add all geospatial objects' |
---|
93 | G = G1 + G_off1+G2+Gislands |
---|
94 | |
---|
95 | #print'clip combined geospatial object by bounding polygon' |
---|
96 | #G_clipped = G.clip(project_urs.poly_all) |
---|
97 | #FIXME: add a clip function to pts |
---|
98 | #print'shape of clipped data', G_clipped.get_data_points().shape |
---|
99 | |
---|
100 | print'export combined DEM file' |
---|
101 | if access(project_fangauta.topographies_dir,F_OK) == 0: |
---|
102 | mkdir (project_fangauta.topographies_dir) |
---|
103 | print'export',project_fangauta.combined_dir_name+ '.txt' |
---|
104 | G.export_points_file(project_fangauta.combined_dir_name+ '.txt') |
---|
105 | |
---|
106 | |
---|
107 | |
---|
108 | ''' |
---|
109 | print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya' |
---|
110 | G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya') |
---|
111 | print'split' |
---|
112 | G_all_1, G_all_2 = G_all.split(.10) |
---|
113 | print'export 1' |
---|
114 | G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya') |
---|
115 | print'export 2' |
---|
116 | G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya') |
---|
117 | |
---|
118 | |
---|
119 | #------------------------------------------------------------------------- |
---|
120 | # Convert URS to SWW file for boundary conditions |
---|
121 | #------------------------------------------------------------------------- |
---|
122 | print 'starting to create boundary conditions' |
---|
123 | boundaries_in_dir_name = project.boundaries_in_dir_name |
---|
124 | |
---|
125 | from anuga.shallow_water.data_manager import urs2sww |
---|
126 | |
---|
127 | print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary |
---|
128 | print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary |
---|
129 | |
---|
130 | #import sys; sys.exit() |
---|
131 | |
---|
132 | #if access(project.boundaries_dir,F_OK) == 0: |
---|
133 | # mkdir (project.boundaries_dir) |
---|
134 | |
---|
135 | from caching import cache |
---|
136 | cache(urs2sww, |
---|
137 | (boundaries_in_dir_name, |
---|
138 | project.boundaries_dir_name1), |
---|
139 | {'verbose': True, |
---|
140 | 'minlat': project.south_boundary, |
---|
141 | 'maxlat': project.north_boundary, |
---|
142 | 'minlon': project.west_boundary, |
---|
143 | 'maxlon': project.east_boundary, |
---|
144 | # 'minlat': project.south, |
---|
145 | # 'maxlat': project.north, |
---|
146 | # 'minlon': project.west, |
---|
147 | # 'maxlon': project.east, |
---|
148 | 'mint': 0, 'maxt': 40000, |
---|
149 | # 'origin': domain.geo_reference.get_origin(), |
---|
150 | 'mean_stage': project.tide, |
---|
151 | # 'zscale': 1, #Enhance tsunami |
---|
152 | 'fail_on_NaN': False}, |
---|
153 | verbose = True, |
---|
154 | ) |
---|
155 | # dependencies = source_dir + project.boundary_basename + '.sww') |
---|
156 | |
---|
157 | ''' |
---|
158 | |
---|
159 | |
---|
160 | |
---|
161 | |
---|
162 | |
---|
163 | |
---|
164 | |
---|