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