1 | # -*- coding: cp1252 -*- |
---|
2 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
3 | """ |
---|
4 | |
---|
5 | from os import sep, environ, getenv, getcwd ,umask |
---|
6 | from os.path import expanduser |
---|
7 | import sys |
---|
8 | from time import localtime, strftime, gmtime |
---|
9 | from anuga.utilities.polygon import read_polygon, plot_polygons, is_inside_polygon, number_mesh_triangles |
---|
10 | #from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees, convert_points_from_latlon_to_utm |
---|
11 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
12 | |
---|
13 | # file and system info |
---|
14 | #--------------------------------- |
---|
15 | |
---|
16 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent dir |
---|
17 | user = get_user_name() |
---|
18 | host = get_host_name() |
---|
19 | # INUNDATIONHOME is the inundation directory, not the data directory. |
---|
20 | |
---|
21 | #needed when running using mpirun, mpirun doesn't inherit umask from .bashrc |
---|
22 | umask(002) |
---|
23 | |
---|
24 | #time stuff |
---|
25 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
26 | build_time = time+'_build' |
---|
27 | run_time = time+'_run' |
---|
28 | |
---|
29 | tide = 0.75 #??? must check!!! |
---|
30 | |
---|
31 | #Making assumptions about the location of scenario data |
---|
32 | state = 'western_australia' |
---|
33 | scenario_name = 'geraldton' |
---|
34 | scenario = 'geraldton_tsunami_scenario' |
---|
35 | |
---|
36 | #Maybe will try to make project a class to allow these parameters to be passed in. |
---|
37 | alpha = 0.1 |
---|
38 | friction=0.01 |
---|
39 | starttime=10000 |
---|
40 | midtime=21600 |
---|
41 | #finaltime=25000 |
---|
42 | finaltime=10000 |
---|
43 | export_cellsize=50 |
---|
44 | setup='final' |
---|
45 | source='other' |
---|
46 | |
---|
47 | |
---|
48 | if setup =='trial': |
---|
49 | print'trial' |
---|
50 | res_factor=10 |
---|
51 | time_thinning=48 |
---|
52 | yieldstep=240 |
---|
53 | if setup =='basic': |
---|
54 | print'basic' |
---|
55 | res_factor=4 |
---|
56 | time_thinning=12 |
---|
57 | yieldstep=120 |
---|
58 | if setup =='final': |
---|
59 | print'final' |
---|
60 | res_factor=1 |
---|
61 | time_thinning=4 |
---|
62 | yieldstep=60 |
---|
63 | |
---|
64 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(source)+'_'+str(user) |
---|
65 | |
---|
66 | |
---|
67 | # onshore data provided by WA DLI |
---|
68 | onshore_name = 'landgate_dem_clip' # original |
---|
69 | island_name = 'dted_srtm_islands' |
---|
70 | |
---|
71 | # AHO + DPI data |
---|
72 | coast_name = 'coastline' |
---|
73 | offshore_name = 'geraldton_bathy' |
---|
74 | |
---|
75 | #final topo name |
---|
76 | combined_name ='geraldton_combined_elevation' |
---|
77 | combined_name_small = 'geraldton_combined_elevation_small' |
---|
78 | |
---|
79 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
80 | |
---|
81 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
82 | topographies_dir = home+state+sep+scenario+sep+'anuga'+sep+'topographies'+sep |
---|
83 | |
---|
84 | #input topo file location |
---|
85 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
86 | island_in_dir_name = topographies_in_dir + island_name |
---|
87 | |
---|
88 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
89 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
90 | |
---|
91 | onshore_dir_name = topographies_dir + onshore_name |
---|
92 | island_dir_name = topographies_dir + island_name |
---|
93 | coast_dir_name = topographies_dir + coast_name |
---|
94 | offshore_dir_name = topographies_dir + offshore_name |
---|
95 | |
---|
96 | #final topo files |
---|
97 | combined_dir_name = topographies_dir + combined_name |
---|
98 | combined_dir_name_small = topographies_dir + combined_name_small |
---|
99 | |
---|
100 | meshes_dir = anuga_dir+'meshes'+sep |
---|
101 | meshes_dir_name = meshes_dir + scenario_name |
---|
102 | |
---|
103 | polygons_dir = anuga_dir+'polygons'+sep |
---|
104 | tide_dir = anuga_dir+'tide_data'+sep |
---|
105 | |
---|
106 | if source =='dampier': |
---|
107 | boundaries_name = 'broome_3854_17042007' #Dampier gun |
---|
108 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'dampier'+sep+'1_10000'+sep |
---|
109 | |
---|
110 | if source=='onslow': |
---|
111 | boundaries_name = 'broome_3859_16052007' #onslow_hedland_broome gun |
---|
112 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'onslow_hedland_broome'+sep+'1_10000'+sep |
---|
113 | |
---|
114 | if source=='exmouth': |
---|
115 | boundaries_name = 'broome_3103_18052007' #exmouth gun |
---|
116 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'exmouth'+sep+'1_10000'+sep |
---|
117 | |
---|
118 | if source=='other': |
---|
119 | boundaries_name = 'other' #exmouth gun |
---|
120 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'exmouth'+sep+'1_10000'+sep |
---|
121 | |
---|
122 | |
---|
123 | #boundaries locations |
---|
124 | boundaries_in_dir_name = boundaries_in_dir + boundaries_name |
---|
125 | boundaries_dir = anuga_dir+'boundaries'+sep |
---|
126 | boundaries_dir_name = boundaries_dir + scenario_name |
---|
127 | |
---|
128 | #output locations |
---|
129 | output_dir = anuga_dir+'outputs'+sep |
---|
130 | output_build_time_dir = output_dir+build_time+dir_comment+sep |
---|
131 | output_run_time_dir = output_dir +run_time+dir_comment+sep |
---|
132 | #output_run_time_dir = output_dir+sep+run_time+sep |
---|
133 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
134 | |
---|
135 | #gauges |
---|
136 | gauge_name = '???.csv' |
---|
137 | gauges_dir = home+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep |
---|
138 | gauges_dir_name = gauges_dir + gauge_name |
---|
139 | |
---|
140 | buildings_filename = gauges_dir + 'Busselton_res_Project.csv' |
---|
141 | buildings_filename_out = 'Busselton_res_Project_modified.csv' |
---|
142 | |
---|
143 | community_filename = gauges_dir +'' |
---|
144 | community_broome = gauges_dir + '' |
---|
145 | |
---|
146 | |
---|
147 | ############################### |
---|
148 | # Domain definitions |
---|
149 | ############################### |
---|
150 | |
---|
151 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon |
---|
152 | |
---|
153 | |
---|
154 | ################################################################### |
---|
155 | # Clipping regions for export to asc and regions for clipping data |
---|
156 | ################################################################### |
---|
157 | |
---|
158 | # exporting asc grid |
---|
159 | eastingmin = 340000 |
---|
160 | eastingmax = 350000 |
---|
161 | northingmin = 6273400 |
---|
162 | northingmax = 6277700 |
---|
163 | |
---|
164 | ############################### |
---|
165 | # Interior region definitions |
---|
166 | ############################### |
---|
167 | |
---|
168 | #digitized polygons |
---|
169 | # bounding polygon for study area |
---|
170 | poly_all = read_polygon(polygons_dir+'extent_new_points.csv') |
---|
171 | res_poly_all = 100000*res_factor |
---|
172 | |
---|
173 | poly_neg20_pos20 = read_polygon(polygons_dir+'neg20_pos20_points.csv') |
---|
174 | res_neg20_pos20 = 20000*res_factor |
---|
175 | |
---|
176 | poly_neg10_pos10= read_polygon(polygons_dir+'neg10_pos10_points.csv') |
---|
177 | res_neg10_pos10 = 2000*res_factor |
---|
178 | |
---|
179 | poly_cbd = read_polygon(polygons_dir+'cbd_points.csv') |
---|
180 | res_cbd = 500*res_factor |
---|
181 | |
---|
182 | poly_wallabi = read_polygon(polygons_dir+'island_wallabi_poly_points.csv') |
---|
183 | res_wallabi = 20000*res_factor |
---|
184 | |
---|
185 | poly_dingiville = read_polygon(polygons_dir+'island_dingiville_poly_points.csv') |
---|
186 | res_dingiville = 20000*res_factor |
---|
187 | |
---|
188 | poly_pelsaert = read_polygon(polygons_dir+'island_pelsaert_poly_points.csv') |
---|
189 | res_pelsaert = 20000*res_factor |
---|
190 | |
---|
191 | |
---|
192 | #plot_polygons([polyAll,poly_broome1,poly_broome2,poly_broome3],figname='boundingpoly2',verbose=False) |
---|
193 | |
---|
194 | interior_regions = [[poly_neg20_pos20,res_neg20_pos20],[poly_neg10_pos10,res_neg10_pos10], |
---|
195 | [poly_cbd,res_cbd],[poly_wallabi,res_wallabi], |
---|
196 | [poly_dingiville,res_dingiville],[poly_pelsaert, res_pelsaert]] |
---|
197 | |
---|
198 | boundary_tags={'back': [2, 3, 4, 5], |
---|
199 | 'side': [1, 6], 'ocean': [0, 7, 8, 9, 10]} |
---|
200 | |
---|
201 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
202 | |
---|
203 | poly_mainland=read_polygon(polygons_dir+'initial_condition.csv') |
---|
204 | |
---|
205 | print 'min number triangles', trigs_min |
---|
206 | |
---|
207 | |
---|