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 | temp_time = time+'_temp' |
---|
28 | print 'gtime: ', gtime |
---|
29 | |
---|
30 | #tide = -2.5 |
---|
31 | #tide = 0.0 |
---|
32 | tide = 2.4 |
---|
33 | |
---|
34 | #Making assumptions about the location of scenario data |
---|
35 | state = 'western_australia' |
---|
36 | scenario_name = 'dampier' |
---|
37 | scenario = 'dampier_tsunami_scenario_2006' |
---|
38 | |
---|
39 | # onshore data provided by WA DLI |
---|
40 | onshore_name = 'DLI_DTED_raster_clipped' # original |
---|
41 | |
---|
42 | # AHO + DPI data + colin French coastline |
---|
43 | coast_name = 'coastline_edited_w_DEM' |
---|
44 | offshore_name = 'clipped_bathy' |
---|
45 | offshore1_name = 'elev_501' |
---|
46 | offshore2_name = 'inferrec_e' |
---|
47 | |
---|
48 | #final topo name |
---|
49 | combined_name ='dampier_combined_elevation' |
---|
50 | combined_smaller_name = 'dampier_combined_elevation_small' |
---|
51 | combined_smallest_name = 'dampier_combined_elevation_smallest' |
---|
52 | |
---|
53 | topographies_in_dir = home+sep+state+sep+scenario+sep+'elevation_final'+sep+'070112'+sep+'points'+sep |
---|
54 | topographies_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'topographies'+sep |
---|
55 | topographies_time_dir = topographies_dir+build_time+sep |
---|
56 | |
---|
57 | temp_dir = home+sep+state+sep+scenario+sep+'anuga'+sep |
---|
58 | temp_dir_name = temp_dir + temp_time+sep |
---|
59 | |
---|
60 | # input topo file location |
---|
61 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
62 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
63 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
64 | offshore1_in_dir_name = topographies_in_dir + offshore1_name |
---|
65 | offshore2_in_dir_name = topographies_in_dir + offshore2_name |
---|
66 | |
---|
67 | onshore_dir_name = topographies_dir + onshore_name |
---|
68 | coast_dir_name = topographies_dir + coast_name |
---|
69 | offshore_dir_name = topographies_dir + offshore_name |
---|
70 | offshore1_dir_name = topographies_dir + offshore1_name |
---|
71 | offshore2_dir_name = topographies_dir + offshore2_name |
---|
72 | |
---|
73 | #final topo files |
---|
74 | combined_dir_name = topographies_dir + combined_name |
---|
75 | combined_time_dir_name = topographies_time_dir + combined_name |
---|
76 | combined_smaller_dir_name = topographies_dir + combined_smaller_name |
---|
77 | combined_smallest_dir_name = topographies_dir + combined_smallest_name |
---|
78 | #combined_time_dir_final_name = topographies_time_dir + combined_final_name |
---|
79 | |
---|
80 | meshes_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'meshes'+sep |
---|
81 | meshes_dir_name = meshes_dir + scenario_name |
---|
82 | |
---|
83 | polygons_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'polygons'+sep+'2007polys'+sep |
---|
84 | tide_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'tide_data'+sep |
---|
85 | |
---|
86 | boundaries_source = '' |
---|
87 | boundaries_name = 'o' |
---|
88 | boundaries_name1 = 'o_new1' |
---|
89 | boundaries_name2 = 'o_test' |
---|
90 | |
---|
91 | #boundaries locations |
---|
92 | #boundaries_in_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep |
---|
93 | boundaries_in_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+'urs'+sep+'1_10000'+sep |
---|
94 | boundaries_in_dir_name = boundaries_in_dir + boundaries_name |
---|
95 | boundaries_in_dir2 = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+'urs'+sep+'ungridded'+sep |
---|
96 | boundaries_in_dir_name2 = boundaries_in_dir2 + boundaries_name |
---|
97 | boundaries_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep |
---|
98 | boundaries_dir_name = boundaries_dir + boundaries_name |
---|
99 | boundaries_dir_namea = boundaries_dir + boundaries_name+'_5000_35000' |
---|
100 | boundaries_dir_name1 = boundaries_dir + boundaries_name1 |
---|
101 | boundaries_dir_name2 = boundaries_dir + boundaries_name2 |
---|
102 | boundaries_dir_name3 = boundaries_dir + boundaries_name+'_test_8500_12000' |
---|
103 | boundaries_dir_name4 = boundaries_dir + boundaries_name+'_8500_12000_no_zone' |
---|
104 | boundaries_dir_name5 = boundaries_dir + '20061026_173920_build'+sep+'dampier' |
---|
105 | boundaries_dir_name6 = boundaries_dir + 'SU-AU' |
---|
106 | |
---|
107 | #boundaries_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'boundaries'+sep+build_time+sep |
---|
108 | #boundaries_time_dir_name = boundaries_time_dir + boundaries_name #Used by post processing |
---|
109 | |
---|
110 | #output locations |
---|
111 | output_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep |
---|
112 | output_build_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep+build_time+sep |
---|
113 | output_run_time_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'outputs'+sep+run_time+sep |
---|
114 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
115 | |
---|
116 | #gauges |
---|
117 | gauge_name = 'dampier_gauges_up2.csv' #'dampier.csv' |
---|
118 | gauge_name_simple = 'dampier_gauges_simple.csv' |
---|
119 | gauge_name_test = 'dampier_gauges_up_test.csv' #'dampier.csv' |
---|
120 | gauges_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep |
---|
121 | gauges_dir_name = gauges_dir + gauge_name |
---|
122 | gauges_dir_name_simple = gauges_dir + gauge_name_simple |
---|
123 | gauges_dir_name_test = gauges_dir + gauge_name_test |
---|
124 | |
---|
125 | |
---|
126 | #buildings_filename = gauges_dir + 'dampier_res_nexis.csv' |
---|
127 | buildings_filename_damage_out = 'dampier_res_nexis_modified.csv' |
---|
128 | ############################### |
---|
129 | # Domain definitions |
---|
130 | ############################### |
---|
131 | |
---|
132 | refzone = 50 |
---|
133 | south_boundary = degminsec2decimal_degrees(-20,58,0) |
---|
134 | #north_boundary = degminsec2decimal_degrees(-20,13,0) |
---|
135 | north_boundary = degminsec2decimal_degrees(-19,30,0) |
---|
136 | west_boundary = degminsec2decimal_degrees(116,15,0) |
---|
137 | east_boundary = degminsec2decimal_degrees(117,11,0) |
---|
138 | ## |
---|
139 | ##p0 = [south, degminsec2decimal_degrees(116,32,0)] |
---|
140 | ##p1 = [south, west] |
---|
141 | ##p2 = [degminsec2decimal_degrees(-20,23,0), west] |
---|
142 | ##p3 = [north, degminsec2decimal_degrees(116,45,0)] |
---|
143 | ##p4 = [north, degminsec2decimal_degrees(117,0,0)] |
---|
144 | ##p5 = [p2[0], degminsec2decimal_degrees(117,8,0)] |
---|
145 | ##p6 = [degminsec2decimal_degrees(-20,30,0), east] |
---|
146 | ##p7 = [degminsec2decimal_degrees(-20,38,0), east] |
---|
147 | ##p8 = [south, east] |
---|
148 | ## |
---|
149 | ##poly_all, zone = convert_from_latlon_to_utm([p0, p1, p2, p3, p4, p5, p6, p7, p8]) |
---|
150 | ##refzone = zone |
---|
151 | poly_all = read_polygon(polygons_dir+'extent.csv') |
---|
152 | print 'Area of bounding polygon', polygon_area(poly_all)/1000000.0 |
---|
153 | |
---|
154 | res_factor = 1 |
---|
155 | res_poly_all = 150000*res_factor |
---|
156 | |
---|
157 | ############################### |
---|
158 | # Interior region definitions |
---|
159 | ############################### |
---|
160 | |
---|
161 | poly_region = read_polygon(polygons_dir+'region.csv') |
---|
162 | res_region = 50000*res_factor |
---|
163 | |
---|
164 | poly_dampier = read_polygon(polygons_dir+'dampier_town.csv') |
---|
165 | res_dampier = 500*res_factor |
---|
166 | |
---|
167 | poly_karratha = read_polygon(polygons_dir+'karrathav2.csv') |
---|
168 | res_karratha = 15000*res_factor |
---|
169 | |
---|
170 | poly_karratha_town = read_polygon(polygons_dir+'karratha_townv2.csv') |
---|
171 | res_karratha_town = 500*res_factor |
---|
172 | |
---|
173 | poly_facility = read_polygon(polygons_dir+'facility.csv') |
---|
174 | res_facility = 1000*res_factor |
---|
175 | |
---|
176 | poly_delambre = read_polygon(polygons_dir+'delambre.csv') |
---|
177 | res_delambre = 1000*res_factor |
---|
178 | |
---|
179 | poly_coast = read_polygon(polygons_dir+'coastpoly.csv') |
---|
180 | res_coast = 5000*res_factor |
---|
181 | |
---|
182 | poly_NWislands = read_polygon(polygons_dir+'nw_islands_area.csv') |
---|
183 | res_NWislands = 50000*res_factor |
---|
184 | |
---|
185 | poly_island0 = read_polygon(polygons_dir+'island0.csv') |
---|
186 | res_island0 = res_poly_all |
---|
187 | |
---|
188 | poly_island1 = read_polygon(polygons_dir+'island1.csv') |
---|
189 | res_island0 = res_poly_all |
---|
190 | |
---|
191 | poly_island2 = read_polygon(polygons_dir+'island2.csv') |
---|
192 | res_island0 = res_poly_all |
---|
193 | |
---|
194 | poly_island3 = read_polygon(polygons_dir+'island3.csv') |
---|
195 | res_island0 = res_poly_all |
---|
196 | |
---|
197 | res_islands = 5000*res_factor |
---|
198 | |
---|
199 | poly_ref_nw4 = read_polygon(polygons_dir+'ref_nw4.csv') |
---|
200 | res_ref_nw4 = res_islands |
---|
201 | |
---|
202 | poly_island4 = read_polygon(polygons_dir+'island4.csv') |
---|
203 | res_island0 = res_poly_all |
---|
204 | |
---|
205 | poly_ref_nw5 = read_polygon(polygons_dir+'ref_nw5.csv') |
---|
206 | res_ref_nw5 = res_islands |
---|
207 | |
---|
208 | poly_island5 = read_polygon(polygons_dir+'island5.csv') |
---|
209 | res_island0 = res_poly_all |
---|
210 | |
---|
211 | poly_ref_nw6 = read_polygon(polygons_dir+'ref_nw6.csv') |
---|
212 | res_ref_nw6 = res_islands |
---|
213 | |
---|
214 | poly_island6 = read_polygon(polygons_dir+'island6.csv') |
---|
215 | res_island0 = res_poly_all |
---|
216 | |
---|
217 | poly_ref_nw7 = read_polygon(polygons_dir+'ref_nw7.csv') |
---|
218 | res_ref_nw7 = res_islands |
---|
219 | |
---|
220 | poly_island7 = read_polygon(polygons_dir+'island7.csv') |
---|
221 | res_island0 = res_poly_all |
---|
222 | |
---|
223 | poly_ref_nw8 = read_polygon(polygons_dir+'ref_nw8.csv') |
---|
224 | res_ref_nw8 = res_islands |
---|
225 | |
---|
226 | poly_island8 = read_polygon(polygons_dir+'island8.csv') |
---|
227 | res_island0 = res_poly_all |
---|
228 | |
---|
229 | |
---|
230 | #plot_polygons([poly_dampier,poly_karratha,poly_karratha_town,poly_delambre, |
---|
231 | # poly_coast,poly_NWislands,poly_island0,poly_island1,poly_island2, |
---|
232 | # poly_island3,poly_island4,poly_island5,poly_island6, |
---|
233 | # poly_island7,poly_island8,poly_ref_nw4,poly_ref_nw5, |
---|
234 | # poly_ref_nw6,poly_ref_nw7,poly_ref_nw8,poly_all],'poly_pic') |
---|
235 | |
---|
236 | interior_regions = [[poly_dampier,res_dampier], |
---|
237 | [poly_karratha,res_karratha],[poly_karratha_town,res_karratha_town], |
---|
238 | [poly_delambre,res_delambre],[poly_coast,res_coast], |
---|
239 | [poly_facility,res_facility], |
---|
240 | #[poly_NWislands,res_NWislands], |
---|
241 | [poly_island0,res_island0],[poly_island1,res_island0], |
---|
242 | [poly_island2,res_island0],[poly_island3,res_island0], |
---|
243 | [poly_island4,res_island0],[poly_island5,res_island0], |
---|
244 | [poly_island6,res_island0],[poly_island7,res_island0], |
---|
245 | [poly_island8,res_island0],[poly_ref_nw4,res_ref_nw4], |
---|
246 | [poly_ref_nw5,res_ref_nw5],[poly_ref_nw6,res_ref_nw6], |
---|
247 | [poly_ref_nw7,res_ref_nw7],[poly_ref_nw8,res_ref_nw8]] |
---|
248 | |
---|
249 | interior_regions_test = [[poly_dampier,res_dampier], |
---|
250 | [poly_karratha,res_karratha],[poly_karratha_town,res_karratha_town]] |
---|
251 | |
---|
252 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
253 | |
---|
254 | print 'min number triangles', trigs_min |
---|
255 | |
---|
256 | ################################################################### |
---|
257 | # Clipping regions for export to asc and regions for clipping data |
---|
258 | ################################################################### |
---|
259 | |
---|
260 | poly_bathy = read_polygon(polygons_dir+'mainland_only.csv') |
---|
261 | |
---|
262 | # exporting asc grid - Dampier |
---|
263 | e_min_area = 474000 |
---|
264 | e_max_area = 480000 |
---|
265 | n_min_area = 7719000 |
---|
266 | n_max_area = 7725000 |
---|
267 | |
---|