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 | # Related major packages |
---|
26 | from anuga.shallow_water import Domain |
---|
27 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
28 | from anuga.geospatial_data.geospatial_data import * |
---|
29 | from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files |
---|
30 | from anuga_parallel.parallel_abstraction import get_processor_name |
---|
31 | |
---|
32 | # Application specific imports |
---|
33 | import project # Definition of file names and polygons |
---|
34 | |
---|
35 | #------------------------------------------------------------------------------ |
---|
36 | # Copy scripts to time stamped output directory and capture screen |
---|
37 | # output to file |
---|
38 | #------------------------------------------------------------------------------ |
---|
39 | |
---|
40 | copy_code_files(project.output_build_time_dir,__file__, |
---|
41 | dirname(project.__file__)+sep+ project.__name__+'.py' ) |
---|
42 | |
---|
43 | start_screen_catcher(project.output_build_time_dir) |
---|
44 | |
---|
45 | print "Processor Name:",get_processor_name() |
---|
46 | print 'USER: ', project.user |
---|
47 | |
---|
48 | #------------------------------------------------------------------------------- |
---|
49 | # Preparation of topographic data |
---|
50 | # |
---|
51 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
52 | # Do for coarse and fine data |
---|
53 | # Fine pts file to be clipped to area of interest |
---|
54 | #------------------------------------------------------------------------------- |
---|
55 | print"project.combined_dir_name",project.combined_dir_name |
---|
56 | |
---|
57 | # topography directory filenames |
---|
58 | onshore_in_dir_name = project.onshore_in_dir_name |
---|
59 | onshore1_in_dir_name = project.onshore1_in_dir_name |
---|
60 | coast_in_dir_name = project.coast_in_dir_name |
---|
61 | #island_in_dir_name = project.island_in_dir_name |
---|
62 | offshore_in_dir_name = project.offshore_in_dir_name |
---|
63 | #offshore_in_dir_name1 = project.offshore_in_dir_name1 |
---|
64 | #offshore_in_dir_name2 = project.offshore_in_dir_name2 |
---|
65 | |
---|
66 | onshore_dir_name = project.onshore_dir_name |
---|
67 | onshore1_dir_name = project.onshore1_dir_name |
---|
68 | coast_dir_name = project.coast_dir_name |
---|
69 | #island_dir_name = project.island_dir_name |
---|
70 | offshore_dir_name = project.offshore_dir_name |
---|
71 | #offshore_dir_name1 = project.offshore_dir_name1 |
---|
72 | #offshore_dir_name2 = project.offshore_dir_name2 |
---|
73 | ''' |
---|
74 | # creates DEM from asc data |
---|
75 | print "creates DEMs from asc data" |
---|
76 | convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True) |
---|
77 | convert_dem_from_ascii2netcdf(onshore1_in_dir_name, basename_out=onshore1_dir_name, use_cache=True, verbose=True) |
---|
78 | |
---|
79 | #creates pts file for onshore DEM |
---|
80 | print "creates pts file for onshore DEM" |
---|
81 | dem2pts(onshore_dir_name, use_cache=True, verbose=True) |
---|
82 | dem2pts(onshore1_dir_name, use_cache=True, verbose=True) |
---|
83 | |
---|
84 | print'create Geospatial data1 objects from topographies',onshore_dir_name + '.pts' |
---|
85 | G1 = Geospatial_data(file_name = onshore_dir_name + '.pts',verbose=True) |
---|
86 | print'create Geospatial data2 objects from topographies',onshore1_dir_name + '.pts' |
---|
87 | G2 = Geospatial_data(file_name = onshore1_dir_name + '.pts',verbose=True) |
---|
88 | print'create Geospatial data3 objects from coast', coast_in_dir_name + '.txt' |
---|
89 | G3 = Geospatial_data(file_name = coast_in_dir_name + '.txt',verbose=True) |
---|
90 | print'create Geospatial data3 objects from offshore',offshore_in_dir_name + '.txt' |
---|
91 | G_off = Geospatial_data(file_name = offshore_in_dir_name + '.txt',verbose=True) |
---|
92 | |
---|
93 | print'add all geospatial objects' |
---|
94 | G = G2 + G3 + G_off |
---|
95 | |
---|
96 | print'add DLI data' |
---|
97 | G = G + G1 |
---|
98 | |
---|
99 | print'export combined DEM file' |
---|
100 | if access(project.topographies_dir,F_OK) == 0: |
---|
101 | mkdir (project.topographies_dir) |
---|
102 | print'export',project.combined_dir_name+'_unclipped' + '.txt' |
---|
103 | #G.export_points_file(project.combined_dir_name+ '.txt') |
---|
104 | |
---|
105 | print'create Geospatial data1 objects from topographies',onshore_dir_name + '.pts' |
---|
106 | #G = Geospatial_data(file_name = project.combined_dir_name+ '.txt',verbose=True) |
---|
107 | |
---|
108 | print'split' |
---|
109 | G_small, G_other = G.split(.10,verbose=True) |
---|
110 | |
---|
111 | print 'export', project.combined_small_dir_name + '.txt' |
---|
112 | G_small.export_points_file(project.combined_small_dir_name + '.txt') |
---|
113 | #G_clipped.export_points_file(project.combined_dir_name + '.xya') |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya' |
---|
118 | G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya') |
---|
119 | print'split' |
---|
120 | G_all_1, G_all_2 = G_all.split(.10) |
---|
121 | print'export 1' |
---|
122 | G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya') |
---|
123 | print'export 2' |
---|
124 | G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya') |
---|
125 | ''' |
---|
126 | |
---|
127 | #------------------------------------------------------------------------- |
---|
128 | # Convert URS to SWW file for boundary conditions |
---|
129 | #------------------------------------------------------------------------- |
---|
130 | print 'starting to create boundary conditions' |
---|
131 | boundaries_in_dir_name = project.boundaries_in_dir_name |
---|
132 | |
---|
133 | from anuga.shallow_water.data_manager import urs2sww, urs_ungridded2sww |
---|
134 | |
---|
135 | print 'boundaries_in_dir_name',boundaries_in_dir_name |
---|
136 | print 'project.boundaries_dir_name',project.boundaries_dir_name |
---|
137 | |
---|
138 | urs_ungridded2sww(boundaries_in_dir_name, boundaries_in_dir_name, |
---|
139 | verbose=True, mint=4000, maxt=35000, zscale=1) |
---|
140 | |
---|
141 | |
---|
142 | |
---|
143 | |
---|
144 | |
---|
145 | |
---|