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 | res_factor= 1000000000000000 |
---|
37 | alpha = 0.1 |
---|
38 | friction=0.01 |
---|
39 | time_thinning=4 |
---|
40 | dir_comment='_DSG_'+str(tide)+'_'+str(user) |
---|
41 | starttime=3600 |
---|
42 | yieldstep=60 |
---|
43 | finaltime=25000 |
---|
44 | |
---|
45 | #Making assumptions about the location of scenario data |
---|
46 | state = 'western_australia' |
---|
47 | scenario_name = 'onslow' |
---|
48 | scenario = 'onslow_tsunami_scenario_2006' |
---|
49 | |
---|
50 | # onshore data provided by WA DLI |
---|
51 | onshore_name = 'onslow_onshore_30m_dted2' # original |
---|
52 | onshore_name1 = 'onslow_onshore_20m_dli' # original |
---|
53 | |
---|
54 | # AHO + DPI data + colin French coastline |
---|
55 | coast_name = 'onslow_coast' |
---|
56 | islands_name = 'onslow_islands_dted2' |
---|
57 | offshore_name = 'onslow_offshore_points' |
---|
58 | offshore1_name = '1' |
---|
59 | offshore2_name = '2' |
---|
60 | |
---|
61 | #final topo name |
---|
62 | combined_name ='onslow_combined_elevation' |
---|
63 | combined_smaller_name = 'onslow_combined_elevation_small' |
---|
64 | combined_smallest_name = 'onslow_combined_elevation_smallest' |
---|
65 | |
---|
66 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
67 | #anuga_dir_name = temp_dir + temp_time+sep |
---|
68 | |
---|
69 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'070112'+sep+'points'+sep |
---|
70 | topographies_dir = anuga_dir+'topographies'+sep |
---|
71 | topographies_time_dir = topographies_dir+build_time+sep |
---|
72 | |
---|
73 | |
---|
74 | # input topo file location |
---|
75 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
76 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
77 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
78 | offshore1_in_dir_name = topographies_in_dir + offshore1_name |
---|
79 | offshore2_in_dir_name = topographies_in_dir + offshore2_name |
---|
80 | |
---|
81 | onshore_dir_name = topographies_dir + onshore_name |
---|
82 | coast_dir_name = topographies_dir + coast_name |
---|
83 | offshore_dir_name = topographies_dir + offshore_name |
---|
84 | offshore1_dir_name = topographies_dir + offshore1_name |
---|
85 | offshore2_dir_name = topographies_dir + offshore2_name |
---|
86 | |
---|
87 | #final topo files |
---|
88 | combined_dir_name = topographies_dir + combined_name |
---|
89 | combined_time_dir_name = topographies_time_dir + combined_name |
---|
90 | #combined_smaller_dir_name = topographies_dir + combined_smaller_name |
---|
91 | #combined_smallest_dir_name = topographies_dir + combined_smallest_name |
---|
92 | #combined_time_dir_final_name = topographies_time_dir + combined_final_name |
---|
93 | |
---|
94 | meshes_dir = anuga_dir+'meshes'+sep |
---|
95 | meshes_dir_name = meshes_dir + scenario_name |
---|
96 | |
---|
97 | polygons_dir = anuga_dir+'polygons'+sep |
---|
98 | tide_dir = anuga_dir+'tide_data'+sep |
---|
99 | |
---|
100 | boundaries_source = '' |
---|
101 | boundaries_name = 'onslow_3854_17042007' |
---|
102 | |
---|
103 | #boundaries locations |
---|
104 | #boundaries_in_dir = anuga_dir+'boundaries'+sep |
---|
105 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'1_10000'+sep |
---|
106 | boundaries_in_dir_name = boundaries_in_dir + boundaries_name |
---|
107 | boundaries_dir = anuga_dir+'boundaries'+sep |
---|
108 | boundaries_dir_name = boundaries_dir + boundaries_name |
---|
109 | |
---|
110 | #output locations |
---|
111 | output_dir = anuga_dir+'outputs'+sep |
---|
112 | output_build_time_dir = output_dir+build_time+sep |
---|
113 | output_run_time_dir = output_dir +run_time+dir_comment+sep |
---|
114 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
115 | |
---|
116 | #gauges |
---|
117 | gauges_dir = anuga_dir+'gauges'+sep |
---|
118 | |
---|
119 | gauges_dir_name = gauges_dir + 'gauge_location_onslow.csv' |
---|
120 | gauges_dir_name_bindi = gauges_dir + 'gauge_location_bindi.csv' |
---|
121 | gauges_comparison_dir_name_50 = gauges_dir + '50_gauges.xya' |
---|
122 | gauges_comparison_dir_name = gauges_dir + 'MOST_comparison_gauges.xya' |
---|
123 | gauges_comparison_dir_name_3d = gauges_dir + 'MOST_comparison_gauges_3d.xya' |
---|
124 | |
---|
125 | community_filename = gauges_dir + 'CHINS_v2.csv' |
---|
126 | community_scenario = gauges_dir + 'community_onslow.csv' |
---|
127 | buildings_filename = gauges_dir + 'Onslow_res_Project.csv' |
---|
128 | buildings_filename_out = 'Onslow_res_Project_modified.csv' |
---|
129 | ############################### |
---|
130 | # Domain definitions |
---|
131 | ############################### |
---|
132 | |
---|
133 | south_boundary = degminsec2decimal_degrees(-22,15,0) |
---|
134 | north_boundary = degminsec2decimal_degrees(-20,30,0) |
---|
135 | west_boundary = degminsec2decimal_degrees(114,15,0) |
---|
136 | east_boundary = degminsec2decimal_degrees(115,50,0) |
---|
137 | |
---|
138 | #Updated Main Domain of Onslow: first run NB 6/4/06 |
---|
139 | d0 = [310000, 7690000] |
---|
140 | d1 = [280000, 7690000] |
---|
141 | d2 = [270000, 7645000] |
---|
142 | d3 = [240000, 7625000] |
---|
143 | d4 = [270000, 7580000] |
---|
144 | d5 = [300000, 7590000] |
---|
145 | d6 = [340000, 7610000] |
---|
146 | |
---|
147 | poly_all = [d0, d1, d2, d3, d4, d5, d6] |
---|
148 | res_poly_all = 100000*res_factor |
---|
149 | print 'bounding polygon area', polygon_area(poly_all)/1000000.0 |
---|
150 | #Interior region - Onslow town |
---|
151 | |
---|
152 | #for visualisation |
---|
153 | #i0 = [304000, 7609000] |
---|
154 | #i1 = [301500, 7605000] |
---|
155 | #i2 = [304000, 7603000] |
---|
156 | #i3 = [307000, 7602000] |
---|
157 | #i4 = [309000, 7603000] |
---|
158 | #i5 = [311000, 7607000] |
---|
159 | |
---|
160 | i0 = [304000, 7607000] |
---|
161 | i1 = [302000, 7605000] |
---|
162 | i2 = [304000, 7603000] |
---|
163 | i3 = [307000, 7602000] |
---|
164 | i4 = [309000, 7603000] |
---|
165 | i5 = [307000, 7606000] |
---|
166 | poly_onslow = [i0, i1, i2, i3, i4, i5] |
---|
167 | res_onslow = 500*res_factor |
---|
168 | print 'onslow polygon area', polygon_area(poly_onslow)/1000000.0 |
---|
169 | |
---|
170 | #Thevenard Island |
---|
171 | j0 = [294000, 7629000] |
---|
172 | j1 = [285000, 7625000] |
---|
173 | j2 = [294000, 7621000] |
---|
174 | j3 = [299000, 7625000] |
---|
175 | poly_thevenard = [j0, j1, j2, j3] |
---|
176 | res_thevenard = 2500*res_factor |
---|
177 | print 'thevenard polygon area', polygon_area(poly_thevenard)/1000000.0 |
---|
178 | |
---|
179 | #med res around onslow |
---|
180 | l0 = [300000, 7610000] |
---|
181 | l1 = [285000, 7600000] |
---|
182 | l2 = [300000, 7597500] |
---|
183 | l3 = [310000, 7600000] |
---|
184 | l4 = [315000, 7610000] |
---|
185 | poly_coast = [l0, l1, l2, l3, l4] |
---|
186 | res_coast = 2500*res_factor |
---|
187 | print 'coast polygon area', polygon_area(poly_coast)/1000000.0 |
---|
188 | |
---|
189 | #general coast and local area to onslow region |
---|
190 | m0 = [270000, 7581000] |
---|
191 | m1 = [300000, 7591000] |
---|
192 | m2 = [339000, 7610000] |
---|
193 | m3 = [330000, 7630000] |
---|
194 | m4 = [290000, 7640000] |
---|
195 | m5 = [260000, 7600000] |
---|
196 | poly_region = [m0, m1, m2, m3, m4, m5] |
---|
197 | res_region = 20000*res_factor |
---|
198 | print 'region polygon area', polygon_area(poly_region)/1000000.0 |
---|
199 | |
---|
200 | interior_regions = [[poly_onslow,res_onslow],[poly_coast,res_coast], |
---|
201 | [poly_region,res_region] |
---|
202 | # ,[poly_thevenard,res_thevenard] |
---|
203 | ] |
---|
204 | |
---|
205 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
206 | |
---|
207 | print 'min number triangles', trigs_min |
---|
208 | |
---|
209 | |
---|
210 | ################################################################### |
---|
211 | # Clipping regions for export to asc and regions for clipping data |
---|
212 | ################################################################### |
---|
213 | |
---|
214 | poly_mainland = read_polygon(polygons_dir+'InitialCondition_points.csv') |
---|
215 | |
---|
216 | # region to export |
---|
217 | e_min_area = 300000 |
---|
218 | e_max_area = 310000 |
---|
219 | n_min_area = 7600000 |
---|
220 | n_max_area = 7610000 |
---|
221 | |
---|