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_points_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 = 0.6 |
---|
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 = 'dampier_dli_ext' # original |
---|
38 | |
---|
39 | # AHO + DPI data + colin French coastline |
---|
40 | coast_name = 'waterline' |
---|
41 | offshore_name = 'dampier_bathymetry' |
---|
42 | offshore1_name = 'nickelbay' |
---|
43 | offshore2_name = 'tinclip' |
---|
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+'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 |
---|
76 | tide_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'tide_data'+sep |
---|
77 | |
---|
78 | boundaries_source = '????' |
---|
79 | #boundaries locations |
---|
80 | boundaries_in_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+'urs'+sep+boundaries_source+sep |
---|
81 | boundaries_in_dir_name = boundaries_in_dir + scenario_name |
---|
82 | boundaries_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep |
---|
83 | boundaries_dir_name = boundaries_dir + scenario_name |
---|
84 | #boundaries_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+build_time+sep |
---|
85 | #boundaries_time_dir_name = boundaries_time_dir + boundaries_name #Used by post processing |
---|
86 | |
---|
87 | #output locations |
---|
88 | output_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep |
---|
89 | output_build_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep+build_time+sep |
---|
90 | output_run_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep+run_time+sep |
---|
91 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
92 | |
---|
93 | #gauges |
---|
94 | gauge_name = 'dampier.csv' |
---|
95 | gauges_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep |
---|
96 | gauges_dir_name = gauges_dir + gauge_name |
---|
97 | |
---|
98 | |
---|
99 | ############################### |
---|
100 | # Domain definitions |
---|
101 | ############################### |
---|
102 | |
---|
103 | refzone = 50 |
---|
104 | south = degminsec2decimal_degrees(-20,55,0) |
---|
105 | north = degminsec2decimal_degrees(-20,15,0) |
---|
106 | west = degminsec2decimal_degrees(116,17,0) |
---|
107 | east = degminsec2decimal_degrees(117,10,0) |
---|
108 | |
---|
109 | p0 = [south, degminsec2decimal_degrees(116,32,0)] |
---|
110 | p1 = [south, west] |
---|
111 | p2 = [degminsec2decimal_degrees(-20,23,0), west] |
---|
112 | p3 = [north, degminsec2decimal_degrees(116,45,0)] |
---|
113 | p4 = [north, degminsec2decimal_degrees(117,0,0)] |
---|
114 | p5 = [p2[0], degminsec2decimal_degrees(117,8,0)] |
---|
115 | p6 = [degminsec2decimal_degrees(-20,30,0), east] |
---|
116 | p7 = [degminsec2decimal_degrees(-20,38,0), east] |
---|
117 | p8 = [south, east] |
---|
118 | |
---|
119 | poly_all, zone = convert_from_latlon_to_utm([p0, p1, p2, p3, p4, p5, p6, p7, p8]) |
---|
120 | refzone = zone |
---|
121 | print 'Area of bounding polygon', polygon_area(poly_all)/1000000.0 |
---|
122 | |
---|
123 | res_poly_all = 100000 |
---|
124 | |
---|
125 | ############################### |
---|
126 | # Interior region definitions |
---|
127 | ############################### |
---|
128 | |
---|
129 | poly_pos20_neg20 = read_polygon(polygons_dir+'pos20_neg20_pts.csv') |
---|
130 | res_pos20_neg20 = 20000 |
---|
131 | |
---|
132 | poly_dampier = read_polygon(polygons_dir+'dampier_pts.csv') |
---|
133 | res_dampier = 500 |
---|
134 | |
---|
135 | poly_karratha = read_polygon(polygons_dir+'karratha_pts.csv') |
---|
136 | res_karratha = 500 |
---|
137 | |
---|
138 | poly_delambre = read_polygon(polygons_dir+'delambre_pts.csv') |
---|
139 | res_delambre = 1000 |
---|
140 | |
---|
141 | poly_mainisland = read_polygon(polygons_dir+'mainisland_pts.csv') |
---|
142 | res_mainisland = 1000 |
---|
143 | |
---|
144 | poly_NWislands = read_polygon(polygons_dir+'NWislands_pts.csv') |
---|
145 | res_NWislands = 1000 |
---|
146 | |
---|
147 | plot_polygons([poly_pos20_neg20,poly_dampier,poly_karratha,poly_delambre,polylmainisland, |
---|
148 | polyNWislands,poly_all],output_run_time_dir + 'poly_pic') |
---|
149 | |
---|
150 | interior_regions = [[poly_pos20_neg20,res_pos20_neg20],[poly_dampier,res_dampier], |
---|
151 | [poly_karratha,res_karratha],[poly_delambre,res_delambre], |
---|
152 | [poly_mainisland,res_mainisland],[poly_NWislands,res_NWislands]] |
---|
153 | |
---|
154 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
155 | |
---|
156 | print 'min number triangles', trigs_min |
---|
157 | |
---|
158 | ################################################################### |
---|
159 | # Clipping regions for export to asc and regions for clipping data |
---|
160 | ################################################################### |
---|
161 | |
---|
162 | poly_bathy = read_polygon(polygons_dir+'polybathy.csv') |
---|
163 | |
---|
164 | # exporting asc grid - Dampier |
---|
165 | e_min_area = 474000 |
---|
166 | e_max_area = 480000 |
---|
167 | n_min_area = 7719000 |
---|
168 | n_max_area = 7725000 |
---|
169 | |
---|
170 | # exporting asc grid - Karratha |
---|
171 | e_min_area = |
---|
172 | e_max_area = |
---|
173 | n_min_area = |
---|
174 | n_max_area = |
---|
175 | |
---|
176 | """ |
---|
177 | # used in the CIPMA 2006 scenario |
---|
178 | # CIPMA point of interest |
---|
179 | cipma_latitude = -20.588456 |
---|
180 | cipma_longitude = 116.771527 |
---|
181 | |
---|
182 | k0 = [cipma_latitude-0.02, cipma_longitude-0.02] |
---|
183 | k1 = [cipma_latitude-0.02, cipma_longitude+0.02] |
---|
184 | k2 = [cipma_latitude+0.02, cipma_longitude+0.02] |
---|
185 | k3 = [cipma_latitude+0.02, cipma_longitude-0.02] |
---|
186 | |
---|
187 | cipma_polygon, zone = convert_from_latlon_to_utm([k0, k1, k2, k3]) |
---|
188 | assert zone == refzone |
---|
189 | |
---|
190 | poly_facility = read_polygon(polygons_dir+'facility.csv') |
---|
191 | poly_pipeline = read_polygon(polygons_dir+'pipeline2.csv') |
---|
192 | poly_interior = read_polygon(polygons_dir+'interior.csv') |
---|
193 | poly_coast = read_polygon(polygons_dir+'coast_final.csv') |
---|
194 | clip_poly_e = read_polygon(polygons_dir+'gap_e.csv') |
---|
195 | clip_poly_nw = read_polygon(polygons_dir+'gap_nw.csv') |
---|
196 | clip_poly_mid_w = read_polygon(polygons_dir+'gap_mid_w.cvs') |
---|
197 | clip_poly_mid_e = read_polygon(polygons_dir+'gap_mid_e.cvs') |
---|
198 | |
---|
199 | # exporting asc grid |
---|
200 | e_min_area = 474000 |
---|
201 | e_max_area = 480000 |
---|
202 | n_min_area = 7719000 |
---|
203 | n_max_area = 7725000 |
---|
204 | |
---|
205 | # used in the original 2005 scenario |
---|
206 | #Interior regions |
---|
207 | karratha_south = degminsec2decimal_degrees(-20,44,0) |
---|
208 | karratha_north = degminsec2decimal_degrees(-20,42,0) |
---|
209 | karratha_west = degminsec2decimal_degrees(116,48,0) |
---|
210 | karratha_east = degminsec2decimal_degrees(116,53,30) |
---|
211 | |
---|
212 | k0 = [karratha_south, karratha_west] |
---|
213 | k1 = [karratha_south, karratha_east] |
---|
214 | k2 = [karratha_north, karratha_east] |
---|
215 | k3 = [karratha_north, karratha_west] |
---|
216 | |
---|
217 | karratha_polygon, zone = convert_from_latlon_to_utm([k0, k1, k2, k3]) |
---|
218 | assert zone == refzone |
---|
219 | |
---|
220 | #Interior regions |
---|
221 | dampier_south = degminsec2decimal_degrees(-20,40,0) |
---|
222 | dampier_north = degminsec2decimal_degrees(-20,38,10) |
---|
223 | dampier_west = degminsec2decimal_degrees(116,43,0) |
---|
224 | dampier_east = degminsec2decimal_degrees(116,45,0) |
---|
225 | |
---|
226 | d0 = [dampier_south, dampier_west] |
---|
227 | d1 = [dampier_south, dampier_east] |
---|
228 | d2 = [dampier_north, dampier_east] |
---|
229 | d3 = [dampier_north, dampier_west] |
---|
230 | |
---|
231 | dampier_polygon, zone = convert_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
232 | assert zone == refzone |
---|
233 | |
---|
234 | #Interior regions |
---|
235 | refinery_south = degminsec2decimal_degrees(-20,37,50) |
---|
236 | refinery_north = degminsec2decimal_degrees(-20,36,0) |
---|
237 | refinery_west = degminsec2decimal_degrees(116,44,0) |
---|
238 | refinery_east = degminsec2decimal_degrees(116,46,10) |
---|
239 | |
---|
240 | d0 = [refinery_south, refinery_west] |
---|
241 | d1 = [refinery_south, refinery_east] |
---|
242 | d2 = [refinery_north, refinery_east] |
---|
243 | d3 = [refinery_north, refinery_west] |
---|
244 | |
---|
245 | refinery_polygon, zone = convert_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
246 | assert zone == refzone |
---|
247 | |
---|
248 | #Interior region around 468899, 7715177: |
---|
249 | #lat (-20, 39, 44.93753), lon (116, 42, 5.09106) |
---|
250 | |
---|
251 | point_south = degminsec2decimal_degrees(-20,39,46) |
---|
252 | point_north = degminsec2decimal_degrees(-20,39,42) |
---|
253 | point_west = degminsec2decimal_degrees(116,42,0) |
---|
254 | point_east = degminsec2decimal_degrees(116,42,10) |
---|
255 | |
---|
256 | d0 = [point_south, point_west] |
---|
257 | d1 = [point_south, point_east] |
---|
258 | d2 = [point_north, point_east] |
---|
259 | d3 = [point_north, point_west] |
---|
260 | |
---|
261 | point_polygon, zone = convert_from_latlon_to_utm([d0, d1, d2, d3]) |
---|
262 | assert zone == refzone |
---|
263 | |
---|
264 | #Neils areas around interesting points |
---|
265 | neil1_point1 = [degminsec2decimal_degrees(-20,35,34), |
---|
266 | degminsec2decimal_degrees(116,45,18)] |
---|
267 | neil1_point2 = [degminsec2decimal_degrees(-20,36,15), |
---|
268 | degminsec2decimal_degrees(116,46,18)] |
---|
269 | neil1_point3 = [degminsec2decimal_degrees(-20,35,9), |
---|
270 | degminsec2decimal_degrees(116,47,17)] |
---|
271 | neil1_point4 = [degminsec2decimal_degrees(-20,34,26), |
---|
272 | degminsec2decimal_degrees(116,46,17)] |
---|
273 | |
---|
274 | neil1_polygon, zone = convert_from_latlon_to_utm([neil1_point1, |
---|
275 | neil1_point2, |
---|
276 | neil1_point3, |
---|
277 | neil1_point4]) |
---|
278 | assert zone == refzone |
---|
279 | |
---|
280 | neil2_point1 = [degminsec2decimal_degrees(-20,39,36), |
---|
281 | degminsec2decimal_degrees(116,41,33)] |
---|
282 | neil2_point2 = [degminsec2decimal_degrees(-20,40,10), |
---|
283 | degminsec2decimal_degrees(116,42,13)] |
---|
284 | neil2_point3 = [degminsec2decimal_degrees(-20,38,39), |
---|
285 | degminsec2decimal_degrees(116,43,49)] |
---|
286 | neil2_point4 = [degminsec2decimal_degrees(-20,38,5), |
---|
287 | degminsec2decimal_degrees(116,43,9)] |
---|
288 | |
---|
289 | neil2_polygon, zone = convert_from_latlon_to_utm([neil2_point1, |
---|
290 | neil2_point2, |
---|
291 | neil2_point3, |
---|
292 | neil2_point4]) |
---|
293 | assert zone == refzone |
---|
294 | |
---|
295 | #Withnell bay |
---|
296 | wb_point1 = [degminsec2decimal_degrees(-20,35,34), |
---|
297 | degminsec2decimal_degrees(116,45,18)] |
---|
298 | wb_point2 = [degminsec2decimal_degrees(-20,36,15), |
---|
299 | degminsec2decimal_degrees(116,46,18)] |
---|
300 | wb_point3 = [degminsec2decimal_degrees(-20,35,9), |
---|
301 | degminsec2decimal_degrees(116,47,17)] |
---|
302 | wb_point4 = [degminsec2decimal_degrees(-20,34,26), |
---|
303 | degminsec2decimal_degrees(116,46,17)] |
---|
304 | |
---|
305 | wb_polygon, zone = convert_from_latlon_to_utm([wb_point1, wb_point2, |
---|
306 | wb_point3, wb_point4]) |
---|
307 | assert zone == refzone |
---|
308 | |
---|
309 | #Larger Withnell bay |
---|
310 | lwb_point1 = [degminsec2decimal_degrees(-20,35,59), |
---|
311 | degminsec2decimal_degrees(116,42,00)] |
---|
312 | lwb_point2 = [degminsec2decimal_degrees(-20,36,50), |
---|
313 | degminsec2decimal_degrees(116,46,50)] |
---|
314 | lwb_point3 = [degminsec2decimal_degrees(-20,34,00), |
---|
315 | degminsec2decimal_degrees(116,47,39)] |
---|
316 | lwb_point4 = [degminsec2decimal_degrees(-20,33,00), |
---|
317 | degminsec2decimal_degrees(116,42,50)] |
---|
318 | |
---|
319 | lwb_polygon, zone = convert_from_latlon_to_utm([lwb_point1, lwb_point2, |
---|
320 | lwb_point3, lwb_point4]) |
---|
321 | |
---|
322 | assert zone == refzone |
---|
323 | """ |
---|