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 # 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.output_build_time_dir,__file__, |
---|
44 | dirname(project.__file__)+sep+ project.__name__+'.py' ) |
---|
45 | |
---|
46 | start_screen_catcher(project.output_build_time_dir) |
---|
47 | |
---|
48 | print 'USER: ', project.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.combined_dir_name |
---|
58 | |
---|
59 | # topography directory filenames |
---|
60 | onshore_dir_name = project.onshore_dir_name |
---|
61 | #island_in_dir_name = project_urs.island_in_dir_name |
---|
62 | Multibeam_dir_name = project.Multibeam_dir_name |
---|
63 | Singlebeam_dir_name = project.Singlebeam_dir_name |
---|
64 | Chart_dir_name = project.Chart_dir_name |
---|
65 | Derived_bath_dir_name = project.Derived_bath_dir_name |
---|
66 | added_data_dir_name =project.added_data_dir_name |
---|
67 | |
---|
68 | |
---|
69 | print'create Geospatial data1 objects from topographies',onshore_dir_name + '.txt' |
---|
70 | G1 = Geospatial_data(file_name = onshore_dir_name + '.txt') |
---|
71 | print'create Geospatial data2 objects from multibeam', Multibeam_dir_name + '.txt' |
---|
72 | G_off = Geospatial_data(file_name = Multibeam_dir_name + '.txt') |
---|
73 | #print'create Geospatial data3 objects from island' |
---|
74 | #G3 = Geospatial_data(file_name = island_dir_name + '.pts') |
---|
75 | print'create Geospatial data3 objects from singlebeam',Singlebeam_dir_name + '.txt' |
---|
76 | G_off1 = Geospatial_data(file_name = Singlebeam_dir_name + '.txt') |
---|
77 | print'create Geospatial data4 objects from chart',Chart_dir_name + '.txt' |
---|
78 | G_off2 = Geospatial_data(file_name = Chart_dir_name + '.txt') |
---|
79 | print'create Geospatial data4 objects from derived bathymetry',Derived_bath_dir_name + '.txt' |
---|
80 | G_off3 = Geospatial_data(file_name = Derived_bath_dir_name + '.txt') |
---|
81 | print'create Geospatial data objects from added data',added_data_dir_name + '.txt' |
---|
82 | G_off4 = Geospatial_data(file_name = added_data_dir_name + '.txt') |
---|
83 | |
---|
84 | print'add all geospatial objects' |
---|
85 | G = G1 + G_off + G_off1 + G_off2 + G_off3+ G_off4 |
---|
86 | |
---|
87 | print'clip combined geospatial object by bounding polygon' |
---|
88 | #G_clipped = G.clip(project_urs.poly_all) |
---|
89 | #FIXME: add a clip function to pts |
---|
90 | #print'shape of clipped data', G_clipped.get_data_points().shape |
---|
91 | |
---|
92 | print'export combined DEM file' |
---|
93 | if access(project.topographies_dir,F_OK) == 0: |
---|
94 | mkdir (project.topographies_dir) |
---|
95 | print'export',project.combined_dir_name+ '.txt' |
---|
96 | G.export_points_file(project.combined_dir_name+ '.txt') |
---|
97 | |
---|
98 | |
---|
99 | |
---|
100 | ''' |
---|
101 | print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya' |
---|
102 | G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya') |
---|
103 | print'split' |
---|
104 | G_all_1, G_all_2 = G_all.split(.10) |
---|
105 | print'export 1' |
---|
106 | G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya') |
---|
107 | print'export 2' |
---|
108 | G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya') |
---|
109 | |
---|
110 | |
---|
111 | #------------------------------------------------------------------------- |
---|
112 | # Convert URS to SWW file for boundary conditions |
---|
113 | #------------------------------------------------------------------------- |
---|
114 | print 'starting to create boundary conditions' |
---|
115 | boundaries_in_dir_name = project.boundaries_in_dir_name |
---|
116 | |
---|
117 | from anuga.shallow_water.data_manager import urs2sww |
---|
118 | |
---|
119 | print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary |
---|
120 | print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary |
---|
121 | |
---|
122 | #import sys; sys.exit() |
---|
123 | |
---|
124 | #if access(project.boundaries_dir,F_OK) == 0: |
---|
125 | # mkdir (project.boundaries_dir) |
---|
126 | |
---|
127 | from caching import cache |
---|
128 | cache(urs2sww, |
---|
129 | (boundaries_in_dir_name, |
---|
130 | project.boundaries_dir_name1), |
---|
131 | {'verbose': True, |
---|
132 | 'minlat': project.south_boundary, |
---|
133 | 'maxlat': project.north_boundary, |
---|
134 | 'minlon': project.west_boundary, |
---|
135 | 'maxlon': project.east_boundary, |
---|
136 | # 'minlat': project.south, |
---|
137 | # 'maxlat': project.north, |
---|
138 | # 'minlon': project.west, |
---|
139 | # 'maxlon': project.east, |
---|
140 | 'mint': 0, 'maxt': 40000, |
---|
141 | # 'origin': domain.geo_reference.get_origin(), |
---|
142 | 'mean_stage': project.tide, |
---|
143 | # 'zscale': 1, #Enhance tsunami |
---|
144 | 'fail_on_NaN': False}, |
---|
145 | verbose = True, |
---|
146 | ) |
---|
147 | # dependencies = source_dir + project.boundary_basename + '.sww') |
---|
148 | |
---|
149 | ''' |
---|
150 | |
---|
151 | |
---|
152 | |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | |
---|