1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
2 | This script is the heart of all scripts in the folder |
---|
3 | """ |
---|
4 | #------------------------------------------------------------------------------ |
---|
5 | # Import necessary modules |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | |
---|
8 | from os import sep, environ, getenv, getcwd |
---|
9 | from os.path import expanduser |
---|
10 | import sys |
---|
11 | from time import localtime, strftime, gmtime |
---|
12 | from anuga.utilities.polygon import read_polygon, plot_polygons, is_inside_polygon, number_mesh_triangles |
---|
13 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
14 | from anuga.shallow_water.data_manager import urs2sts,create_sts_boundary |
---|
15 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon |
---|
16 | |
---|
17 | #------------------------------------------------------------------------------ |
---|
18 | # Directory setup |
---|
19 | #------------------------------------------------------------------------------ |
---|
20 | # Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
21 | |
---|
22 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name() |
---|
23 | user = get_user_name() |
---|
24 | host = get_host_name() |
---|
25 | |
---|
26 | # determines time for setting up output directories |
---|
27 | time = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
28 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) |
---|
29 | build_time = time+'_build' |
---|
30 | run_time = time+'_run' |
---|
31 | |
---|
32 | #------------------------------------------------------------------------------ |
---|
33 | # Initial Conditions |
---|
34 | #------------------------------------------------------------------------------ |
---|
35 | |
---|
36 | # this section needs to be updated to reflect the modelled community. |
---|
37 | # Note, the user needs to set up the directory system accordingly |
---|
38 | state = 'thailand' |
---|
39 | scenario_name = 'patong' |
---|
40 | scenario = 'patong_tsunami_scenario' |
---|
41 | |
---|
42 | # Model specific parameters. One or all can be changed each time the |
---|
43 | # run_scenario script is executed |
---|
44 | tide = 0.8 #0.8 |
---|
45 | alpha = 0.1 # smoothing parameter for mesh |
---|
46 | friction=0.01 # manning's friction coefficient |
---|
47 | starttime=0 |
---|
48 | finaltime=15000 # final time for simulation 15000 |
---|
49 | |
---|
50 | setup='final' # Final can be replaced with trial or basic. |
---|
51 | # Either will result in a coarser mesh that will allow a |
---|
52 | # faster, but less accurate, simulation. |
---|
53 | |
---|
54 | if setup =='trial': |
---|
55 | print'trial' |
---|
56 | res_factor=10 |
---|
57 | time_thinning=48 |
---|
58 | yieldstep=240 |
---|
59 | if setup =='basic': |
---|
60 | print'basic' |
---|
61 | res_factor=4 |
---|
62 | time_thinning=12 |
---|
63 | yieldstep=120 |
---|
64 | if setup =='final': |
---|
65 | print'final' |
---|
66 | res_factor=1 |
---|
67 | time_thinning=4 |
---|
68 | #time_thinning=48 |
---|
69 | yieldstep=60 |
---|
70 | |
---|
71 | #------------------------------------------------------------------------------ |
---|
72 | # Output Filename |
---|
73 | #------------------------------------------------------------------------------ |
---|
74 | # Important to distinguish each run - ensure str(user) is included! |
---|
75 | # Note, the user is free to include as many parameters as desired |
---|
76 | dir_comment='_'+setup+'_'+str(tide)+'_poly_'+str(user) |
---|
77 | |
---|
78 | #------------------------------------------------------------------------------ |
---|
79 | # Input Data |
---|
80 | #------------------------------------------------------------------------------ |
---|
81 | |
---|
82 | # elevation data used in build_patong.py |
---|
83 | # four textfiles, with different resolutions |
---|
84 | elevation1 = 'patong_10m_grid_msl_Project.txt' |
---|
85 | elevation2 = 'patong_10m_small_grid_for_anuga_sub_Project.txt' |
---|
86 | elevation3 = 'patong_bay_1s_grid_Project.txt' |
---|
87 | elevation4 = 'andaman_3s_grid_Clip_Project.txt' |
---|
88 | |
---|
89 | # gauges - used in get_timeseries.py |
---|
90 | gauge_name = 'patong.csv' |
---|
91 | |
---|
92 | # BOUNDING POLYGON - used in build_boundary.py and run_patong.py respectively |
---|
93 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
94 | # Check the run_patong.py for boundary_tags |
---|
95 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
96 | order_filename = 'thinned_boundary_ordering.csv' |
---|
97 | #landward bounding points |
---|
98 | landward = 'landward_bounding_polygon.csv' |
---|
99 | |
---|
100 | #------------------------------------------------------------------------------ |
---|
101 | # Output Elevation Data |
---|
102 | #------------------------------------------------------------------------------ |
---|
103 | # Output filename for elevation |
---|
104 | # this is a combination of all the data (utilisied in build_boundary) |
---|
105 | combined_name ='patong_combined_elevation' |
---|
106 | combined_smaller_name = 'patong_combined_elevation_smaller' |
---|
107 | |
---|
108 | #------------------------------------------------------------------------------ |
---|
109 | # Directory Structure |
---|
110 | #------------------------------------------------------------------------------ |
---|
111 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
112 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
113 | topographies_dir = anuga_dir+'topographies'+sep |
---|
114 | polygons_dir = anuga_dir+'polygons'+sep |
---|
115 | tide_dir = anuga_dir+'tide_data'+sep |
---|
116 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
117 | output_dir = anuga_dir+'outputs'+sep |
---|
118 | gauges_dir = anuga_dir+'gauges'+sep |
---|
119 | meshes_dir = anuga_dir+'meshes'+sep |
---|
120 | |
---|
121 | #------------------------------------------------------------------------------ |
---|
122 | # Location of input and output data |
---|
123 | #------------------------------------------------------------------------------ |
---|
124 | # where the input data sits |
---|
125 | elevation_in_dir_name1 = topographies_in_dir + elevation1 |
---|
126 | elevation_in_dir_name2 = topographies_in_dir + elevation2 |
---|
127 | elevation_in_dir_name3 = topographies_in_dir + elevation3 |
---|
128 | elevation_in_dir_name4 = topographies_in_dir + elevation4 |
---|
129 | |
---|
130 | # where the output data sits |
---|
131 | elevation_dir_name1 = topographies_dir + elevation1 |
---|
132 | elevation_dir_name2 = topographies_dir + elevation2 |
---|
133 | elevation_dir_name3 = topographies_dir + elevation3 |
---|
134 | elevation_dir_name4 = topographies_dir + elevation4 |
---|
135 | |
---|
136 | |
---|
137 | # where the combined elevation file sits |
---|
138 | combined_dir_name = topographies_dir + combined_name + '_data' |
---|
139 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
140 | |
---|
141 | # where the mesh sits (this is created during the run_patong.py) |
---|
142 | meshes_dir_name = meshes_dir + scenario_name+'_poly.msh' |
---|
143 | |
---|
144 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
145 | order_filename_dir = boundaries_dir + order_filename |
---|
146 | |
---|
147 | # where the landward points of boundary extent sit (this is used within run_patong.py) |
---|
148 | landward_dir = boundaries_dir + landward |
---|
149 | |
---|
150 | # where the directory of the output filename sits |
---|
151 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_patong.py |
---|
152 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_patong.py |
---|
153 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
154 | |
---|
155 | # where the directory of the gauges sit |
---|
156 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
157 | |
---|
158 | #------------------------------------------------------------------------------ |
---|
159 | # Interior region definitions |
---|
160 | #------------------------------------------------------------------------------ |
---|
161 | |
---|
162 | # extents of elevation datasets |
---|
163 | extent_elev_dir1 = read_polygon(polygons_dir + 'patong_10m.txt') |
---|
164 | extent_elev_dir2 = read_polygon(polygons_dir + 'saddle_10m.txt') |
---|
165 | extent_elev_dir3 = read_polygon(polygons_dir + 'patong_1s.txt') |
---|
166 | extent_elev_dir4 = read_polygon(polygons_dir + 'patong_10m_aos.txt') |
---|
167 | |
---|
168 | #Land, to set the initial stage/water to be offcoast only |
---|
169 | poly_mainland = read_polygon(polygons_dir+'initial_conditions.csv') |
---|
170 | |
---|
171 | # Initial bounding polygon for data clipping |
---|
172 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
173 | res_poly_all = 10000*res_factor |
---|
174 | |
---|
175 | # Area of Interest 1 elevation from -10m to 20m |
---|
176 | poly_aoi1 = read_polygon(polygons_dir+'aoi.csv') |
---|
177 | res_aoi1 = 800*res_factor |
---|
178 | |
---|
179 | # Area of Significance 1 elevation from -20m to a 200m buffer of the 20m contour |
---|
180 | poly_aos1 = read_polygon(polygons_dir+'aos.csv') |
---|
181 | res_aos1 = 1000*res_factor |
---|
182 | |
---|
183 | # Area of Shallow water and coastal land that needs a finer res than 1000000 |
---|
184 | poly_sw = read_polygon(polygons_dir+'sw.csv') |
---|
185 | res_sw = 2000*res_factor |
---|
186 | |
---|
187 | |
---|
188 | # Area of buildings |
---|
189 | building_main = read_polygon(polygons_dir+'building_main.csv') |
---|
190 | building_main_small = read_polygon(polygons_dir+'building_main_small.csv') |
---|
191 | building_main_south = read_polygon(polygons_dir+'building_main_south.csv') |
---|
192 | building_saddle = read_polygon(polygons_dir+'building_saddle.csv') |
---|
193 | bld_res = 50*res_factor |
---|
194 | |
---|
195 | |
---|
196 | |
---|
197 | |
---|
198 | # Combined all regions, must check that all are included! |
---|
199 | interior_regions = [[poly_aoi1,res_aoi1], |
---|
200 | [poly_aos1,res_aos1], |
---|
201 | [poly_sw,res_sw], |
---|
202 | [building_main, bld_res], |
---|
203 | [building_main_small, bld_res], |
---|
204 | [building_main_south, bld_res], |
---|
205 | [building_saddle, bld_res]] |
---|
206 | |
---|
207 | |
---|
208 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
209 | print 'min estimated number of triangles', trigs_min |
---|
210 | |
---|
211 | #------------------------------------------------------------------------------ |
---|
212 | # Building polygons |
---|
213 | #------------------------------------------------------------------------------ |
---|
214 | |
---|
215 | building_polygon_file = polygons_dir+'buildings.csv' |
---|
216 | |
---|
217 | #------------------------------------------------------------------------------ |
---|
218 | # Clipping regions for export to asc and regions for clipping data |
---|
219 | # Final inundation maps should only be created in regions of the finest mesh |
---|
220 | #------------------------------------------------------------------------------ |
---|
221 | |
---|
222 | #CBD extract ascii grid - cooridnates from patong_1s extent |
---|
223 | xminCBD = 417445.1119 |
---|
224 | xmaxCBD = 425601.7881 |
---|
225 | yminCBD = 870663.4547 |
---|
226 | ymaxCBD = 876965.3856 |
---|
227 | |
---|
228 | |
---|