1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
2 | """ |
---|
3 | |
---|
4 | from os import sep, environ, getenv, getcwd |
---|
5 | from os.path import expanduser |
---|
6 | import sys |
---|
7 | from time import localtime, strftime, gmtime |
---|
8 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon # number_mesh_triangles |
---|
9 | from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees, convert_from_latlon_to_utm |
---|
10 | from anuga.utilities.system_tools import get_user_name |
---|
11 | |
---|
12 | # file and system info |
---|
13 | #--------------------------------- |
---|
14 | codename = 'project.py' |
---|
15 | |
---|
16 | home = getenv('INUNDATIONHOME') #Sandpit's parent dir |
---|
17 | user = get_user_name() |
---|
18 | |
---|
19 | # INUNDATIONHOME is the inundation directory, not the data directory. |
---|
20 | home += sep +'data' |
---|
21 | |
---|
22 | #time stuff |
---|
23 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
24 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
25 | build_time = time+'_build' |
---|
26 | run_time = time+'_run' |
---|
27 | print 'gtime: ', gtime |
---|
28 | |
---|
29 | tide = 2.4 |
---|
30 | |
---|
31 | #Making assumptions about the location of scenario data |
---|
32 | state = 'western_australia' |
---|
33 | scenario_name = 'dampier' |
---|
34 | scenario = 'dampier_tsunami_scenario_2006' |
---|
35 | |
---|
36 | # onshore data provided by WA DLI |
---|
37 | onshore_name = 'DLI_DTED_raster_clipped' # original |
---|
38 | |
---|
39 | # AHO + DPI data + colin French coastline |
---|
40 | coast_name = 'coastline_edited_w_DEM' |
---|
41 | offshore_name = 'clipped_bathy' |
---|
42 | offshore1_name = 'elev_501' |
---|
43 | offshore2_name = 'inferrec_e' |
---|
44 | |
---|
45 | #final topo name |
---|
46 | combined_name ='dampier_combined_elevation' |
---|
47 | combined_smaller_name = 'dampier_combined_elevation_smaller' |
---|
48 | |
---|
49 | topographies_in_dir = home+sep+state+sep+scenario+sep+'elevation_final'+sep+'070112'+sep+'points'+sep |
---|
50 | topographies_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'topographies'+sep |
---|
51 | topographies_time_dir = topographies_dir+build_time+sep |
---|
52 | |
---|
53 | # input topo file location |
---|
54 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
55 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
56 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
57 | offshore1_in_dir_name = topographies_in_dir + offshore1_name |
---|
58 | offshore2_in_dir_name = topographies_in_dir + offshore2_name |
---|
59 | |
---|
60 | onshore_dir_name = topographies_dir + onshore_name |
---|
61 | coast_dir_name = topographies_dir + coast_name |
---|
62 | offshore_dir_name = topographies_dir + offshore_name |
---|
63 | offshore1_dir_name = topographies_dir + offshore1_name |
---|
64 | offshore2_dir_name = topographies_dir + offshore2_name |
---|
65 | |
---|
66 | #final topo files |
---|
67 | combined_dir_name = topographies_dir + combined_name |
---|
68 | combined_time_dir_name = topographies_time_dir + combined_name |
---|
69 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
70 | #combined_time_dir_final_name = topographies_time_dir + combined_final_name |
---|
71 | |
---|
72 | meshes_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'meshes'+sep |
---|
73 | meshes_dir_name = meshes_dir + scenario_name |
---|
74 | |
---|
75 | polygons_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'polygons'+sep+'2007polys'+sep |
---|
76 | tide_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'tide_data'+sep |
---|
77 | |
---|
78 | boundaries_source = '' |
---|
79 | boundaries_name = 'o' |
---|
80 | boundaries_name1 = 'o_new' |
---|
81 | |
---|
82 | #boundaries locations |
---|
83 | boundaries_in_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries' |
---|
84 | #boundaries_in_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+'urs'+sep+'1_10000'+sep |
---|
85 | boundaries_in_dir_name = boundaries_in_dir + boundaries_name |
---|
86 | boundaries_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep |
---|
87 | boundaries_dir_name = boundaries_dir + boundaries_name |
---|
88 | boundaries_dir_name1 = boundaries_dir + boundaries_name1 |
---|
89 | #boundaries_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+build_time+sep |
---|
90 | #boundaries_time_dir_name = boundaries_time_dir + boundaries_name #Used by post processing |
---|
91 | |
---|
92 | #output locations |
---|
93 | output_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep |
---|
94 | output_build_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep+build_time+sep |
---|
95 | output_run_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep+run_time+sep |
---|
96 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
97 | |
---|
98 | #gauges |
---|
99 | gauge_name = 'dampier_gauges_up2.csv' #'dampier.csv' |
---|
100 | gauges_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep |
---|
101 | gauges_dir_name = gauges_dir + gauge_name |
---|
102 | |
---|
103 | #buildings_filename = gauges_dir + 'dampier_res_nexis.csv' |
---|
104 | buildings_filename_damage_out = 'dampier_res_nexis_modified.csv' |
---|
105 | ############################### |
---|
106 | # Domain definitions |
---|
107 | ############################### |
---|
108 | |
---|
109 | refzone = 50 |
---|
110 | south_boundary = degminsec2decimal_degrees(-20,58,0) |
---|
111 | north_boundary = degminsec2decimal_degrees(-20,13,0) |
---|
112 | west_boundary = degminsec2decimal_degrees(116,15,0) |
---|
113 | east_boundary = degminsec2decimal_degrees(117,11,0) |
---|
114 | ## |
---|
115 | ##p0 = [south, degminsec2decimal_degrees(116,32,0)] |
---|
116 | ##p1 = [south, west] |
---|
117 | ##p2 = [degminsec2decimal_degrees(-20,23,0), west] |
---|
118 | ##p3 = [north, degminsec2decimal_degrees(116,45,0)] |
---|
119 | ##p4 = [north, degminsec2decimal_degrees(117,0,0)] |
---|
120 | ##p5 = [p2[0], degminsec2decimal_degrees(117,8,0)] |
---|
121 | ##p6 = [degminsec2decimal_degrees(-20,30,0), east] |
---|
122 | ##p7 = [degminsec2decimal_degrees(-20,38,0), east] |
---|
123 | ##p8 = [south, east] |
---|
124 | ## |
---|
125 | ##poly_all, zone = convert_from_latlon_to_utm([p0, p1, p2, p3, p4, p5, p6, p7, p8]) |
---|
126 | ##refzone = zone |
---|
127 | poly_all = read_polygon(polygons_dir+'extent.csv') |
---|
128 | print 'Area of bounding polygon', polygon_area(poly_all)/1000000.0 |
---|
129 | |
---|
130 | res_poly_all = 100000 |
---|
131 | #res_poly_all = 500000 |
---|
132 | |
---|
133 | ############################### |
---|
134 | # Interior region definitions |
---|
135 | ############################### |
---|
136 | |
---|
137 | poly_region = read_polygon(polygons_dir+'region.csv') |
---|
138 | res_region = 50000 |
---|
139 | |
---|
140 | poly_dampier = read_polygon(polygons_dir+'dampier_town.csv') |
---|
141 | res_dampier = 500 |
---|
142 | #res_dampier = 5000 |
---|
143 | |
---|
144 | poly_karratha = read_polygon(polygons_dir+'karrathav2.csv') |
---|
145 | res_karratha = 15000 |
---|
146 | |
---|
147 | poly_karratha_town = read_polygon(polygons_dir+'karratha_townv2.csv') |
---|
148 | res_karratha_town = 500 |
---|
149 | #res_karratha_town = 5000 |
---|
150 | |
---|
151 | poly_facility = read_polygon(polygons_dir+'facility.csv') |
---|
152 | res_facility = 1000 |
---|
153 | |
---|
154 | poly_delambre = read_polygon(polygons_dir+'delambre.csv') |
---|
155 | res_delambre = 5000 |
---|
156 | |
---|
157 | poly_coast = read_polygon(polygons_dir+'coastpoly.csv') |
---|
158 | res_coast = 1000 |
---|
159 | #res_coast = 10000 |
---|
160 | |
---|
161 | poly_NWislands = read_polygon(polygons_dir+'nw_islands_area.csv') |
---|
162 | res_NWislands = 50000 |
---|
163 | |
---|
164 | poly_island0 = read_polygon(polygons_dir+'island0.csv') |
---|
165 | res_island0 = res_poly_all |
---|
166 | |
---|
167 | poly_island1 = read_polygon(polygons_dir+'island1.csv') |
---|
168 | res_island0 = res_poly_all |
---|
169 | |
---|
170 | poly_island2 = read_polygon(polygons_dir+'island2.csv') |
---|
171 | res_island0 = res_poly_all |
---|
172 | |
---|
173 | poly_island3 = read_polygon(polygons_dir+'island3.csv') |
---|
174 | res_island0 = res_poly_all |
---|
175 | |
---|
176 | res_islands = 5000 |
---|
177 | #res_islands = 15000 |
---|
178 | |
---|
179 | poly_ref_nw4 = read_polygon(polygons_dir+'ref_nw4.csv') |
---|
180 | res_ref_nw4 = res_islands |
---|
181 | |
---|
182 | poly_island4 = read_polygon(polygons_dir+'island4.csv') |
---|
183 | res_island0 = res_poly_all |
---|
184 | |
---|
185 | poly_ref_nw5 = read_polygon(polygons_dir+'ref_nw5.csv') |
---|
186 | res_ref_nw5 = res_islands |
---|
187 | |
---|
188 | poly_island5 = read_polygon(polygons_dir+'island5.csv') |
---|
189 | res_island0 = res_poly_all |
---|
190 | |
---|
191 | poly_ref_nw6 = read_polygon(polygons_dir+'ref_nw6.csv') |
---|
192 | res_ref_nw6 = res_islands |
---|
193 | |
---|
194 | poly_island6 = read_polygon(polygons_dir+'island6.csv') |
---|
195 | res_island0 = res_poly_all |
---|
196 | |
---|
197 | poly_ref_nw7 = read_polygon(polygons_dir+'ref_nw7.csv') |
---|
198 | res_ref_nw7 = res_islands |
---|
199 | |
---|
200 | poly_island7 = read_polygon(polygons_dir+'island7.csv') |
---|
201 | res_island0 = res_poly_all |
---|
202 | |
---|
203 | poly_ref_nw8 = read_polygon(polygons_dir+'ref_nw8.csv') |
---|
204 | res_ref_nw8 = res_islands |
---|
205 | |
---|
206 | poly_island8 = read_polygon(polygons_dir+'island8.csv') |
---|
207 | res_island0 = res_poly_all |
---|
208 | |
---|
209 | |
---|
210 | ##plot_polygons([poly_dampier,poly_karratha,poly_karratha_town,poly_delambre, |
---|
211 | ## poly_coast,poly_NWislands,poly_island0,poly_island1,poly_island2, |
---|
212 | ## poly_island3,poly_island4,poly_island5,poly_island6, |
---|
213 | ## poly_island7,poly_island8,poly_ref_nw4,poly_ref_nw5, |
---|
214 | ## poly_ref_nw6,poly_ref_nw7,poly_ref_nw8,poly_all],'poly_pic') |
---|
215 | |
---|
216 | interior_regions = [[poly_dampier,res_dampier], |
---|
217 | [poly_karratha,res_karratha],[poly_karratha_town,res_karratha_town], |
---|
218 | [poly_delambre,res_delambre],[poly_coast,res_coast], |
---|
219 | [poly_facility,res_facility], |
---|
220 | #[poly_NWislands,res_NWislands], |
---|
221 | [poly_island0,res_island0],[poly_island1,res_island0], |
---|
222 | [poly_island2,res_island0],[poly_island3,res_island0], |
---|
223 | [poly_island4,res_island0],[poly_island5,res_island0], |
---|
224 | [poly_island6,res_island0],[poly_island7,res_island0], |
---|
225 | [poly_island8,res_island0],[poly_ref_nw4,res_ref_nw4], |
---|
226 | [poly_ref_nw5,res_ref_nw5],[poly_ref_nw6,res_ref_nw6], |
---|
227 | [poly_ref_nw7,res_ref_nw7],[poly_ref_nw8,res_ref_nw8]] |
---|
228 | |
---|
229 | #trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
230 | # |
---|
231 | #print 'min number triangles', trigs_min |
---|
232 | |
---|
233 | ################################################################### |
---|
234 | # Clipping regions for export to asc and regions for clipping data |
---|
235 | ################################################################### |
---|
236 | |
---|
237 | poly_bathy = read_polygon(polygons_dir+'mainland_only.csv') |
---|
238 | |
---|
239 | # exporting asc grid - Dampier |
---|
240 | e_min_area = 474000 |
---|
241 | e_max_area = 480000 |
---|
242 | n_min_area = 7719000 |
---|
243 | n_max_area = 7725000 |
---|
244 | |
---|
245 | # exporting asc grid - Karratha |
---|
246 | ##e_min_area = |
---|
247 | ##e_max_area = |
---|
248 | ##n_min_area = |
---|
249 | ##n_max_area = |
---|
250 | |
---|
251 | """ |
---|
252 | # used in the CIPMA 2006 scenario |
---|
253 | # CIPMA point of interest |
---|
254 | cipma_latitude = -20.588456 |
---|
255 | cipma_longitude = 116.771527 |
---|
256 | |
---|
257 | k0 = [cipma_latitude-0.02, cipma_longitude-0.02] |
---|
258 | k1 = [cipma_latitude-0.02, cipma_longitude+0.02] |
---|
259 | k2 = [cipma_latitude+0.02, cipma_longitude+0.02] |
---|
260 | k3 = [cipma_latitude+0.02, cipma_longitude-0.02] |
---|
261 | |
---|
262 | cipma_polygon, zone = convert_from_latlon_to_utm([k0, k1, k2, k3]) |
---|
263 | assert zone == refzone |
---|
264 | |
---|
265 | poly_facility = read_polygon(polygons_dir+'facility.csv') |
---|
266 | poly_pipeline = read_polygon(polygons_dir+'pipeline2.csv') |
---|
267 | poly_interior = read_polygon(polygons_dir+'interior.csv') |
---|
268 | poly_coast = read_polygon(polygons_dir+'coast_final.csv') |
---|
269 | clip_poly_e = read_polygon(polygons_dir+'gap_e.csv') |
---|
270 | clip_poly_nw = read_polygon(polygons_dir+'gap_nw.csv') |
---|
271 | clip_poly_mid_w = read_polygon(polygons_dir+'gap_mid_w.cvs') |
---|
272 | clip_poly_mid_e = read_polygon(polygons_dir+'gap_mid_e.cvs') |
---|
273 | |
---|
274 | # exporting asc grid |
---|
275 | e_min_area = 474000 |
---|
276 | e_max_area = 480000 |
---|
277 | n_min_area = 7719000 |
---|
278 | n_max_area = 7725000 |
---|
279 | |
---|
280 | # used in the original 2005 scenario |
---|
281 | #Interior regions |
---|
282 | karratha_south = degminsec2decimal_degrees(-20,44,0) |
---|
283 | karratha_north = degminsec2decimal_degrees(-20,42,0) |
---|
284 | karratha_west = degminsec2decimal_degrees(116,48,0) |
---|
285 | karratha_east = degminsec2decimal_degrees(116,53,30) |
---|
286 | |
---|
287 | k0 = [karratha_south, karratha_west] |
---|
288 | k1 = [karratha_south, karratha_east] |
---|
289 | k2 = [karratha_north, karratha_east] |
---|
290 | k3 = [karratha_north, karratha_west] |
---|
291 | |
---|
292 | karratha_polygon, zone = convert_from_latlon_to_utm([k0, k1, k2, k3]) |
---|
293 | assert zone == refzone |
---|
294 | |
---|
295 | #Interior regions |
---|
296 | dampier_south = degminsec2decimal_degrees(-20,40,0) |
---|
297 | dampier_north = degminsec2decimal_degrees(-20,38,10) |
---|
298 | dampier_west = degminsec2decimal_degrees(116,43,0) |
---|
299 | dampier_east = degminsec2decimal_degrees(116,45,0) |
---|
300 | |
---|
301 | d0 = [dampier_south, dampier_west] |
---|
302 | d1 = [dampier_south, dampier_east] |
---|
303 | d2 = [dampier_north, dampier_east] |
---|
304 | d3 = [dampier_north, dampier_west] |
---|
305 | |
---|
306 | dampier_polygon, zone = convert_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
307 | assert zone == refzone |
---|
308 | |
---|
309 | #Interior regions |
---|
310 | refinery_south = degminsec2decimal_degrees(-20,37,50) |
---|
311 | refinery_north = degminsec2decimal_degrees(-20,36,0) |
---|
312 | refinery_west = degminsec2decimal_degrees(116,44,0) |
---|
313 | refinery_east = degminsec2decimal_degrees(116,46,10) |
---|
314 | |
---|
315 | d0 = [refinery_south, refinery_west] |
---|
316 | d1 = [refinery_south, refinery_east] |
---|
317 | d2 = [refinery_north, refinery_east] |
---|
318 | d3 = [refinery_north, refinery_west] |
---|
319 | |
---|
320 | refinery_polygon, zone = convert_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
321 | assert zone == refzone |
---|
322 | |
---|
323 | #Interior region around 468899, 7715177: |
---|
324 | #lat (-20, 39, 44.93753), lon (116, 42, 5.09106) |
---|
325 | |
---|
326 | point_south = degminsec2decimal_degrees(-20,39,46) |
---|
327 | point_north = degminsec2decimal_degrees(-20,39,42) |
---|
328 | point_west = degminsec2decimal_degrees(116,42,0) |
---|
329 | point_east = degminsec2decimal_degrees(116,42,10) |
---|
330 | |
---|
331 | d0 = [point_south, point_west] |
---|
332 | d1 = [point_south, point_east] |
---|
333 | d2 = [point_north, point_east] |
---|
334 | d3 = [point_north, point_west] |
---|
335 | |
---|
336 | point_polygon, zone = convert_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
337 | assert zone == refzone |
---|
338 | |
---|
339 | #Neils areas around interesting points |
---|
340 | neil1_point1 = [degminsec2decimal_degrees(-20,35,34), |
---|
341 | degminsec2decimal_degrees(116,45,18)] |
---|
342 | neil1_point2 = [degminsec2decimal_degrees(-20,36,15), |
---|
343 | degminsec2decimal_degrees(116,46,18)] |
---|
344 | neil1_point3 = [degminsec2decimal_degrees(-20,35,9), |
---|
345 | degminsec2decimal_degrees(116,47,17)] |
---|
346 | neil1_point4 = [degminsec2decimal_degrees(-20,34,26), |
---|
347 | degminsec2decimal_degrees(116,46,17)] |
---|
348 | |
---|
349 | neil1_polygon, zone = convert_from_latlon_to_utm([neil1_point1, |
---|
350 | neil1_point2, |
---|
351 | neil1_point3, |
---|
352 | neil1_point4]) |
---|
353 | assert zone == refzone |
---|
354 | |
---|
355 | neil2_point1 = [degminsec2decimal_degrees(-20,39,36), |
---|
356 | degminsec2decimal_degrees(116,41,33)] |
---|
357 | neil2_point2 = [degminsec2decimal_degrees(-20,40,10), |
---|
358 | degminsec2decimal_degrees(116,42,13)] |
---|
359 | neil2_point3 = [degminsec2decimal_degrees(-20,38,39), |
---|
360 | degminsec2decimal_degrees(116,43,49)] |
---|
361 | neil2_point4 = [degminsec2decimal_degrees(-20,38,5), |
---|
362 | degminsec2decimal_degrees(116,43,9)] |
---|
363 | |
---|
364 | neil2_polygon, zone = convert_from_latlon_to_utm([neil2_point1, |
---|
365 | neil2_point2, |
---|
366 | neil2_point3, |
---|
367 | neil2_point4]) |
---|
368 | assert zone == refzone |
---|
369 | |
---|
370 | #Withnell bay |
---|
371 | wb_point1 = [degminsec2decimal_degrees(-20,35,34), |
---|
372 | degminsec2decimal_degrees(116,45,18)] |
---|
373 | wb_point2 = [degminsec2decimal_degrees(-20,36,15), |
---|
374 | degminsec2decimal_degrees(116,46,18)] |
---|
375 | wb_point3 = [degminsec2decimal_degrees(-20,35,9), |
---|
376 | degminsec2decimal_degrees(116,47,17)] |
---|
377 | wb_point4 = [degminsec2decimal_degrees(-20,34,26), |
---|
378 | degminsec2decimal_degrees(116,46,17)] |
---|
379 | |
---|
380 | wb_polygon, zone = convert_from_latlon_to_utm([wb_point1, wb_point2, |
---|
381 | wb_point3, wb_point4]) |
---|
382 | assert zone == refzone |
---|
383 | |
---|
384 | #Larger Withnell bay |
---|
385 | lwb_point1 = [degminsec2decimal_degrees(-20,35,59), |
---|
386 | degminsec2decimal_degrees(116,42,00)] |
---|
387 | lwb_point2 = [degminsec2decimal_degrees(-20,36,50), |
---|
388 | degminsec2decimal_degrees(116,46,50)] |
---|
389 | lwb_point3 = [degminsec2decimal_degrees(-20,34,00), |
---|
390 | degminsec2decimal_degrees(116,47,39)] |
---|
391 | lwb_point4 = [degminsec2decimal_degrees(-20,33,00), |
---|
392 | degminsec2decimal_degrees(116,42,50)] |
---|
393 | |
---|
394 | lwb_polygon, zone = convert_from_latlon_to_utm([lwb_point1, lwb_point2, |
---|
395 | lwb_point3, lwb_point4]) |
---|
396 | |
---|
397 | assert zone == refzone |
---|
398 | """ |
---|