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 | import os |
---|
9 | from os import sep, getenv |
---|
10 | from time import localtime, strftime, gmtime |
---|
11 | from anuga.utilities.polygon import read_polygon, number_mesh_triangles |
---|
12 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
13 | |
---|
14 | #------------------------------------------------------------------------------ |
---|
15 | # Directory setup |
---|
16 | #------------------------------------------------------------------------------ |
---|
17 | # Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
18 | |
---|
19 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name() |
---|
20 | muxhome = getenv('MUXHOME') |
---|
21 | user = get_user_name() |
---|
22 | host = get_host_name() |
---|
23 | |
---|
24 | # determines time for setting up output directories |
---|
25 | time = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
26 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) |
---|
27 | build_time = time+'_build' |
---|
28 | run_time = time+'_run' |
---|
29 | |
---|
30 | #------------------------------------------------------------------------------ |
---|
31 | # Initial Conditions |
---|
32 | #------------------------------------------------------------------------------ |
---|
33 | |
---|
34 | # this section needs to be updated to reflect the modelled community. |
---|
35 | # Note, the user needs to set up the directory system accordingly |
---|
36 | state = 'western_australia' |
---|
37 | scenario_name = 'busselton' |
---|
38 | scenario = 'busselton_tsunami_scenario' |
---|
39 | |
---|
40 | # Model specific parameters. One or all can be changed each time the |
---|
41 | # run_scenario script is executed |
---|
42 | tide = 0 #0.6 |
---|
43 | #event_number = 27255 # Java 9.3 worst case for Perth |
---|
44 | #event_number = 68693 # Sumatra 9.2 |
---|
45 | event_number = 27283 # Java 9.3 original |
---|
46 | alpha = 0.1 # smoothing parameter for mesh |
---|
47 | friction=0.01 # manning's friction coefficient |
---|
48 | starttime=0 |
---|
49 | finaltime=80000 # final time for simulation |
---|
50 | |
---|
51 | setup='trial' # Final can be replaced with trial or basic. |
---|
52 | # Either will result in a coarser mesh that will allow a |
---|
53 | # faster, but less accurate, simulation. |
---|
54 | |
---|
55 | if setup =='trial': |
---|
56 | print'trial' |
---|
57 | res_factor=100 |
---|
58 | time_thinning=96 |
---|
59 | yieldstep=240 |
---|
60 | if setup =='basic': |
---|
61 | print'basic' |
---|
62 | res_factor=4 |
---|
63 | time_thinning=12 |
---|
64 | yieldstep=120 |
---|
65 | if setup =='final': |
---|
66 | print'final' |
---|
67 | res_factor=1 |
---|
68 | time_thinning=4 |
---|
69 | yieldstep=60 |
---|
70 | |
---|
71 | #------------------------------------------------------------------------------ |
---|
72 | # Revision numbers - for comparisons study |
---|
73 | #------------------------------------------------------------------------------ |
---|
74 | rev_num = 'newExtent' |
---|
75 | #rev_num = '5449' |
---|
76 | #rev_num = '4695' # 2nd Sept 2007 |
---|
77 | #rev_num = '4743' # 3nd Oct 2007 |
---|
78 | #rev_num = '4777' # 1st Nov 2007 |
---|
79 | #rev_num = '4874' # 3rd Dec 2007 |
---|
80 | #rev_num = '4901' # 3rd Jan 2007 |
---|
81 | #rev_num = '4990' # 5th Feb 2007 |
---|
82 | #rev_num = '5103' # 3rd March 2007 |
---|
83 | #rev_num = '5120' # 5th March 2007 |
---|
84 | #rev_num = '5140' # 7th March 2007 |
---|
85 | #rev_num = '5160' # 11th March 2007 |
---|
86 | #rev_num = '5185' # 1st April 2007 |
---|
87 | #rev_num = '5273' # 2nd May 2007 |
---|
88 | |
---|
89 | |
---|
90 | #------------------------------------------------------------------------------ |
---|
91 | # Output Filename |
---|
92 | #------------------------------------------------------------------------------ |
---|
93 | # Important to distinguish each run - ensure str(user) is included! |
---|
94 | # Note, the user is free to include as many parameters as desired |
---|
95 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_'+ 'alpha' +str(alpha)+'_'+str(user) |
---|
96 | |
---|
97 | #------------------------------------------------------------------------------ |
---|
98 | # Input Data |
---|
99 | #------------------------------------------------------------------------------ |
---|
100 | |
---|
101 | |
---|
102 | # elevation data used in build_busselton.py |
---|
103 | # onshore data: format ascii grid with accompanying projection file |
---|
104 | onshore_name = 'busselton_v2_gda94_mga50' |
---|
105 | # coastline: format x,y,elevation (with title) |
---|
106 | coast_name = 'Busselton_Contour0.txt' |
---|
107 | coast_name1 = 'Busselton_BeachSurvey.txt' |
---|
108 | # bathymetry: format x,y,elevation (with title) |
---|
109 | offshore_name = 'Busselton_NavyFinal.txt' |
---|
110 | offshore_name1 = 'Busselton_Chart.txt' |
---|
111 | offshore_name2 = 'Busselton_Digitised.txt' |
---|
112 | offshore_name3 = 'Busselton_250m.txt' # for areas that were heading to zero - 2005 Bathymetry grid |
---|
113 | offshore_name4 = 'DPI.txt' # for area within Bunbury 500 mesh less than zero generated from TIN |
---|
114 | offshore_name5 = 'topo_20m_buss_1km' # for area within Busselton 500 mesh less than zero generated from TIN |
---|
115 | |
---|
116 | # gauges - used in get_timeseries.py |
---|
117 | #gauge_name = scenario_name+'.txt' |
---|
118 | gauge_name = 'Gauges.csv' |
---|
119 | # buildings - used in run_building_inundation.py |
---|
120 | building = 'busselton_res_clip' |
---|
121 | |
---|
122 | |
---|
123 | # BOUNDING POLYGON - used in build_boundary.py and run_busselton.py respectively |
---|
124 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
125 | # Check the run_busselton.py for boundary_tags |
---|
126 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
127 | order_filename = 'thinned_boundary_ordering.csv' |
---|
128 | #landward bounding points |
---|
129 | landward = 'landward_bounding_polygon.csv' |
---|
130 | |
---|
131 | |
---|
132 | #------------------------------------------------------------------------------ |
---|
133 | # Output Elevation Data |
---|
134 | #------------------------------------------------------------------------------ |
---|
135 | # Output filename for elevation |
---|
136 | # this is a combination of all the data (utilisied in build_boundary) |
---|
137 | combined_name ='busselton_combined_elevation' |
---|
138 | combined_smaller_name = 'busselton_combined_elevation_smaller' |
---|
139 | |
---|
140 | #------------------------------------------------------------------------------ |
---|
141 | # Directory Structure |
---|
142 | #------------------------------------------------------------------------------ |
---|
143 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
144 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
145 | topographies_dir = anuga_dir+'topographies'+sep |
---|
146 | polygons_dir = anuga_dir+'polygons'+sep |
---|
147 | tide_dir = anuga_dir+'tide_data'+sep |
---|
148 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
149 | output_dir = anuga_dir+'outputs'+sep |
---|
150 | gauges_dir = anuga_dir+'gauges'+sep |
---|
151 | meshes_dir = anuga_dir+'meshes'+sep |
---|
152 | |
---|
153 | #------------------------------------------------------------------------------ |
---|
154 | # Location of input and output data |
---|
155 | #------------------------------------------------------------------------------ |
---|
156 | |
---|
157 | ascii_grid_filenames = [onshore_name, # Topo |
---|
158 | offshore_name5] # Busselton Topo |
---|
159 | |
---|
160 | point_filenames = [coast_name, # Coastline |
---|
161 | coast_name1, # Beach survey |
---|
162 | offshore_name, # Bathymetry |
---|
163 | offshore_name1, # Bathymetry Charts |
---|
164 | offshore_name2, # Digitised Fairsheet |
---|
165 | offshore_name3, # 250m |
---|
166 | offshore_name4] # Bunbury DPI |
---|
167 | |
---|
168 | |
---|
169 | # Where the combined elevation file sits |
---|
170 | combined_dir_name = topographies_dir + combined_name |
---|
171 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
172 | |
---|
173 | # Where the mesh sits (this is created during the run_busselton.py) |
---|
174 | meshes_dir_name = meshes_dir + scenario_name+'.msh' |
---|
175 | |
---|
176 | # Where the boundary ordering files sit (this is used within build_boundary.py) |
---|
177 | order_filename_dir = boundaries_dir + order_filename |
---|
178 | |
---|
179 | # Where the landward points of boundary extent sit (this is used within run_busselton.py) |
---|
180 | landward_dir = boundaries_dir + landward |
---|
181 | |
---|
182 | # Where the event sts files sits (this is created during the build_boundary.py) |
---|
183 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
184 | boundaries_dir_mux = muxhome |
---|
185 | urs_boundary_name = os.path.join(boundaries_dir_event, |
---|
186 | scenario_name) |
---|
187 | |
---|
188 | |
---|
189 | # Where the directory of the output filename sits |
---|
190 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_busselton.py |
---|
191 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_busselton.py |
---|
192 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
193 | |
---|
194 | # Where the directory of the gauges sit |
---|
195 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
196 | building_in_dir_name = gauges_dir + building + '.csv' #used for run_building_inundation.py |
---|
197 | |
---|
198 | #------------------------------------------------------------------------------ |
---|
199 | # Interior region definitions |
---|
200 | #------------------------------------------------------------------------------ |
---|
201 | |
---|
202 | # Land, to set the initial stage/water to be offcoast only |
---|
203 | poly_mainland = read_polygon(polygons_dir+'initial_condition.csv') |
---|
204 | |
---|
205 | # Land, to set the initial stage/water to be offcoast only |
---|
206 | poly_marina = read_polygon(polygons_dir+'initial_condition_marina.csv') |
---|
207 | |
---|
208 | # Initial bounding polygon for data clipping |
---|
209 | poly_all = read_polygon(polygons_dir+'poly_all_extend.csv') |
---|
210 | res_poly_all = 100000*res_factor |
---|
211 | |
---|
212 | # Area of Interest 1 (Busselton) |
---|
213 | poly_aoi1 = read_polygon(polygons_dir+'busselton_1km.csv') |
---|
214 | res_aoi1 = 500*res_factor |
---|
215 | |
---|
216 | # Area of Interest 2 (Bunbury) |
---|
217 | poly_aoi2 = read_polygon(polygons_dir+'bunbury_1km.csv') |
---|
218 | res_aoi2 = 500*res_factor |
---|
219 | |
---|
220 | # Area of Significance 1 (Busselton) |
---|
221 | poly_aos1 = read_polygon(polygons_dir+'busselton_2km.csv') |
---|
222 | res_aos1 = 10000*res_factor |
---|
223 | |
---|
224 | # Area of Significance 2 (Bunbury) |
---|
225 | poly_aos2 = read_polygon(polygons_dir+'busselton_2km.csv') |
---|
226 | res_aos2 = 10000*res_factor |
---|
227 | |
---|
228 | # Refined areas |
---|
229 | # Polygon designed to islands |
---|
230 | poly_aos3 = read_polygon(polygons_dir+'island1.csv') |
---|
231 | res_aos3 = 10000*res_factor |
---|
232 | poly_aos4 = read_polygon(polygons_dir+'island2.csv') |
---|
233 | res_aos4 = 10000*res_factor |
---|
234 | |
---|
235 | # Shallow water 1 |
---|
236 | poly_sw1 = read_polygon(polygons_dir+'coast_5km_d20m.csv') |
---|
237 | res_sw1 = 40000*res_factor |
---|
238 | |
---|
239 | # Combined all regions, must check that all are included! |
---|
240 | interior_regions = [[poly_aoi1,res_aoi1],[poly_aoi2,res_aoi2], |
---|
241 | [poly_aos1,res_aos1],[poly_aos2,res_aos2], |
---|
242 | [poly_aos3,res_aos3],[poly_aos4,res_aos4], |
---|
243 | [poly_sw1,res_sw1]] |
---|
244 | |
---|
245 | |
---|
246 | trigs_min = number_mesh_triangles(interior_regions, poly_all, |
---|
247 | res_poly_all) |
---|
248 | print 'min estimated number of triangles', trigs_min |
---|
249 | |
---|
250 | #------------------------------------------------------------------------------ |
---|
251 | # Clipping regions for export to asc and regions for clipping data |
---|
252 | # Final inundation maps should only be created in regions of the finest mesh |
---|
253 | #------------------------------------------------------------------------------ |
---|
254 | |
---|
255 | # ASCII export grid for Busselton |
---|
256 | xminBusselton = 340000 |
---|
257 | xmaxBusselton = 352000 |
---|
258 | yminBusselton = 6271500 |
---|
259 | ymaxBusselton = 6280000 |
---|
260 | |
---|
261 | # ASCII export grid for Bunbury |
---|
262 | xminBunbury = 369000 |
---|
263 | xmaxBunbury = 381000 |
---|
264 | yminBunbury = 6308000 |
---|
265 | ymaxBunbury = 6316500 |
---|
266 | |
---|