1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
2 | """ |
---|
3 | |
---|
4 | from os import sep, environ, getenv, getcwd,umask |
---|
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, get_host_name |
---|
11 | |
---|
12 | # file and system info |
---|
13 | #--------------------------------- |
---|
14 | codename = 'project.py' |
---|
15 | |
---|
16 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent dir |
---|
17 | user = get_user_name() |
---|
18 | host = get_host_name() |
---|
19 | #needed when running using mpirun, mpirun doesn't inherit umask from .bashrc |
---|
20 | umask(002) |
---|
21 | |
---|
22 | |
---|
23 | # INUNDATIONHOME is the inundation directory, not the data directory. |
---|
24 | #home += sep +'data' |
---|
25 | |
---|
26 | #time stuff |
---|
27 | time = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
28 | build_time = time+'_build' |
---|
29 | run_time = time+'_run' |
---|
30 | |
---|
31 | #tide = -1.5 |
---|
32 | #tide = 0.0 |
---|
33 | tide = 1.5 |
---|
34 | |
---|
35 | #Maybe will try to make project a class to allow these parameters to be passed in. |
---|
36 | alpha = 0.1 |
---|
37 | friction=0.01 |
---|
38 | starttime=3600 |
---|
39 | finaltime=25000 |
---|
40 | setup='final' |
---|
41 | #source='exmouth' |
---|
42 | source='onslow' |
---|
43 | #source='dampier' |
---|
44 | |
---|
45 | if setup =='trial': |
---|
46 | print'trial' |
---|
47 | res_factor=10 |
---|
48 | time_thinning=48 |
---|
49 | yieldstep=240 |
---|
50 | if setup =='basic': |
---|
51 | print'basic' |
---|
52 | res_factor=4 |
---|
53 | time_thinning=12 |
---|
54 | yieldstep=120 |
---|
55 | if setup =='final': |
---|
56 | print'final' |
---|
57 | res_factor=1 |
---|
58 | time_thinning=1 |
---|
59 | yieldstep=60 |
---|
60 | if setup =='store': |
---|
61 | print'store' |
---|
62 | res_factor=10 |
---|
63 | time_thinning=48 |
---|
64 | yieldstep=240 |
---|
65 | |
---|
66 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(source)+'_'+str(user) |
---|
67 | |
---|
68 | #Making assumptions about the location of scenario data |
---|
69 | state = 'western_australia' |
---|
70 | scenario_name = 'onslow' |
---|
71 | scenario = 'onslow_tsunami_scenario_2006' |
---|
72 | |
---|
73 | # onshore data provided by WA DLI |
---|
74 | onshore_name = 'onslow_onshore_30m_dted2' # original |
---|
75 | onshore_name1 = 'onslow_onshore_20m_dli' # original |
---|
76 | |
---|
77 | # AHO + DPI data + colin French coastline |
---|
78 | coast_name = 'onslow_coast' |
---|
79 | islands_name = 'onslow_islands_dted2' |
---|
80 | offshore_name = 'onslow_offshore_points' |
---|
81 | offshore1_name = '1' |
---|
82 | offshore2_name = '2' |
---|
83 | |
---|
84 | #final topo name |
---|
85 | combined_name ='onslow_combined_elevation' |
---|
86 | combined_smaller_name = 'onslow_combined_elevation_small' |
---|
87 | combined_smallest_name = 'onslow_combined_elevation_smallest' |
---|
88 | |
---|
89 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
90 | #anuga_dir_name = temp_dir + temp_time+sep |
---|
91 | |
---|
92 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'070112'+sep+'points'+sep |
---|
93 | topographies_dir = anuga_dir+'topographies'+sep |
---|
94 | topographies_time_dir = topographies_dir+build_time+sep |
---|
95 | |
---|
96 | |
---|
97 | # input topo file location |
---|
98 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
99 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
100 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
101 | offshore1_in_dir_name = topographies_in_dir + offshore1_name |
---|
102 | offshore2_in_dir_name = topographies_in_dir + offshore2_name |
---|
103 | |
---|
104 | onshore_dir_name = topographies_dir + onshore_name |
---|
105 | coast_dir_name = topographies_dir + coast_name |
---|
106 | offshore_dir_name = topographies_dir + offshore_name |
---|
107 | offshore1_dir_name = topographies_dir + offshore1_name |
---|
108 | offshore2_dir_name = topographies_dir + offshore2_name |
---|
109 | |
---|
110 | #final topo files |
---|
111 | combined_dir_name = topographies_dir + combined_name |
---|
112 | combined_time_dir_name = topographies_time_dir + combined_name |
---|
113 | #combined_smaller_dir_name = topographies_dir + combined_smaller_name |
---|
114 | #combined_smallest_dir_name = topographies_dir + combined_smallest_name |
---|
115 | #combined_time_dir_final_name = topographies_time_dir + combined_final_name |
---|
116 | |
---|
117 | meshes_dir = anuga_dir+'meshes'+sep |
---|
118 | meshes_dir_name = meshes_dir + scenario_name |
---|
119 | |
---|
120 | polygons_dir = anuga_dir+'polygons'+sep |
---|
121 | tide_dir = anuga_dir+'tide_data'+sep |
---|
122 | |
---|
123 | |
---|
124 | if source =='dampier': |
---|
125 | boundaries_name = 'onslow_3854_17042007' #Dampier gun |
---|
126 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'dampier'+sep+'1_10000'+sep |
---|
127 | |
---|
128 | if source=='onslow': |
---|
129 | boundaries_name = 'onslow_3859_16052007' #onslow_hedland_broome gun |
---|
130 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'onslow_hedland_broome'+sep+'1_10000'+sep |
---|
131 | |
---|
132 | if source=='exmouth': |
---|
133 | boundaries_name = 'onslow_3103_18052007' #exmouth gun |
---|
134 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'exmouth'+sep+'1_10000'+sep |
---|
135 | |
---|
136 | #boundaries locations |
---|
137 | boundaries_source = '' |
---|
138 | #boundaries_in_dir = anuga_dir+'boundaries'+sep |
---|
139 | boundaries_in_dir_name = boundaries_in_dir + boundaries_name |
---|
140 | |
---|
141 | boundaries_dir = anuga_dir+'boundaries'+sep |
---|
142 | boundaries_dir_name = boundaries_dir + boundaries_name |
---|
143 | |
---|
144 | #output locations |
---|
145 | output_dir = anuga_dir+'outputs'+sep |
---|
146 | output_build_time_dir = output_dir+build_time+'_'+source+sep |
---|
147 | #output_run_time_dir = output_dir +run_time+dir_comment+sep |
---|
148 | output_run_time_dir = output_dir +'20070619_042140_run_final_0_onslow_nbartzis'+sep |
---|
149 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
150 | |
---|
151 | #gauges |
---|
152 | gauges_dir = anuga_dir+'gauges'+sep |
---|
153 | |
---|
154 | gauges_dir_name = gauges_dir + 'gauge_location_onslow.csv' |
---|
155 | gauges_dir_name_bindi = gauges_dir + 'gauge_location_bindi.csv' |
---|
156 | gauges_comparison_dir_name_50 = gauges_dir + '50_gauges.xya' |
---|
157 | gauges_comparison_dir_name = gauges_dir + 'MOST_comparison_gauges.xya' |
---|
158 | gauges_comparison_dir_name_3d = gauges_dir + 'MOST_comparison_gauges_3d.xya' |
---|
159 | |
---|
160 | community_filename = gauges_dir + 'CHINS_v2.csv' |
---|
161 | community_scenario = gauges_dir + 'community_onslow.csv' |
---|
162 | buildings_filename = gauges_dir + 'Onslow_res_Project.csv' |
---|
163 | buildings_filename_out =output_run_time_dir + 'Onslow_res_Project_modified.csv' |
---|
164 | ############################### |
---|
165 | # Domain definitions |
---|
166 | ############################### |
---|
167 | |
---|
168 | south_boundary = degminsec2decimal_degrees(-22,15,0) |
---|
169 | north_boundary = degminsec2decimal_degrees(-20,30,0) |
---|
170 | west_boundary = degminsec2decimal_degrees(114,15,0) |
---|
171 | east_boundary = degminsec2decimal_degrees(115,50,0) |
---|
172 | |
---|
173 | #Updated Main Domain of Onslow: first run NB 6/4/06 |
---|
174 | d0 = [310000, 7690000] |
---|
175 | d1 = [280000, 7690000] |
---|
176 | d2 = [270000, 7645000] |
---|
177 | d3 = [240000, 7625000] |
---|
178 | d4 = [270000, 7580000] |
---|
179 | d5 = [300000, 7590000] |
---|
180 | d6 = [340000, 7610000] |
---|
181 | |
---|
182 | poly_all = [d0, d1, d2, d3, d4, d5, d6] |
---|
183 | res_poly_all = 100000*res_factor |
---|
184 | print 'bounding polygon area', polygon_area(poly_all)/1000000.0 |
---|
185 | #Interior region - Onslow town |
---|
186 | |
---|
187 | #for visualisation |
---|
188 | #i0 = [304000, 7609000] |
---|
189 | #i1 = [301500, 7605000] |
---|
190 | #i2 = [304000, 7603000] |
---|
191 | #i3 = [307000, 7602000] |
---|
192 | #i4 = [309000, 7603000] |
---|
193 | #i5 = [311000, 7607000] |
---|
194 | |
---|
195 | i0 = [304000, 7607000] |
---|
196 | i1 = [302000, 7605000] |
---|
197 | i2 = [304000, 7603000] |
---|
198 | i3 = [307000, 7602000] |
---|
199 | i4 = [309000, 7603000] |
---|
200 | i5 = [307000, 7606000] |
---|
201 | poly_onslow = [i0, i1, i2, i3, i4, i5] |
---|
202 | res_onslow = 500*res_factor |
---|
203 | print 'onslow polygon area', polygon_area(poly_onslow)/1000000.0 |
---|
204 | |
---|
205 | #Thevenard Island |
---|
206 | j0 = [294000, 7629000] |
---|
207 | j1 = [285000, 7625000] |
---|
208 | j2 = [294000, 7621000] |
---|
209 | j3 = [299000, 7625000] |
---|
210 | poly_thevenard = [j0, j1, j2, j3] |
---|
211 | res_thevenard = 2500*res_factor |
---|
212 | print 'thevenard polygon area', polygon_area(poly_thevenard)/1000000.0 |
---|
213 | |
---|
214 | #med res around onslow |
---|
215 | l0 = [300000, 7610000] |
---|
216 | l1 = [285000, 7600000] |
---|
217 | l2 = [300000, 7597500] |
---|
218 | l3 = [310000, 7600000] |
---|
219 | l4 = [315000, 7610000] |
---|
220 | poly_coast = [l0, l1, l2, l3, l4] |
---|
221 | res_coast = 2500*res_factor |
---|
222 | print 'coast polygon area', polygon_area(poly_coast)/1000000.0 |
---|
223 | |
---|
224 | #general coast and local area to onslow region |
---|
225 | m0 = [270000, 7581000] |
---|
226 | m1 = [300000, 7591000] |
---|
227 | m2 = [339000, 7610000] |
---|
228 | m3 = [330000, 7630000] |
---|
229 | m4 = [290000, 7640000] |
---|
230 | m5 = [260000, 7600000] |
---|
231 | poly_region = [m0, m1, m2, m3, m4, m5] |
---|
232 | res_region = 20000*res_factor |
---|
233 | print 'region polygon area', polygon_area(poly_region)/1000000.0 |
---|
234 | |
---|
235 | interior_regions = [[poly_onslow,res_onslow],[poly_coast,res_coast], |
---|
236 | [poly_region,res_region] |
---|
237 | # ,[poly_thevenard,res_thevenard] |
---|
238 | ] |
---|
239 | |
---|
240 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
241 | |
---|
242 | print 'min number triangles', trigs_min |
---|
243 | |
---|
244 | |
---|
245 | ################################################################### |
---|
246 | # Clipping regions for export to asc and regions for clipping data |
---|
247 | ################################################################### |
---|
248 | |
---|
249 | poly_mainland = read_polygon(polygons_dir+'InitialCondition_points.csv') |
---|
250 | |
---|
251 | # region to export |
---|
252 | eastingmin = 300000 |
---|
253 | eastingmax = 310000 |
---|
254 | northingmin = 7600000 |
---|
255 | northingmax = 7610000 |
---|
256 | |
---|