1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
2 | This script is the heart of all scripts in folder |
---|
3 | """ |
---|
4 | #------------------------------------------------------------------------------ |
---|
5 | # Import necessary modules |
---|
6 | #------------------------------------------------------------------------------ |
---|
7 | |
---|
8 | from os import sep, environ, getenv, getcwd |
---|
9 | from os.path import expanduser |
---|
10 | import sys |
---|
11 | from time import localtime, strftime, gmtime |
---|
12 | from anuga.utilities.polygon import read_polygon, plot_polygons, is_inside_polygon, number_mesh_triangles |
---|
13 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
14 | from anuga.shallow_water.data_manager import urs2sts,create_sts_boundary |
---|
15 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon |
---|
16 | |
---|
17 | #------------------------------------------------------------------------------ |
---|
18 | # Directory setup |
---|
19 | #------------------------------------------------------------------------------ |
---|
20 | ##Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
21 | |
---|
22 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name() |
---|
23 | muxhome = getenv('MUXHOME') |
---|
24 | user = get_user_name() |
---|
25 | host = get_host_name() |
---|
26 | |
---|
27 | ##time stuff |
---|
28 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
29 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
30 | build_time = time+'_build' |
---|
31 | run_time = time+'_run' |
---|
32 | print 'gtime: ', gtime |
---|
33 | |
---|
34 | #------------------------------------------------------------------------------ |
---|
35 | # Initial Conditions |
---|
36 | #------------------------------------------------------------------------------ |
---|
37 | |
---|
38 | ##Changed to reflect the modeled community (also sets up the directory system) |
---|
39 | state = 'western_australia' |
---|
40 | scenario_name = 'perth' |
---|
41 | scenario = 'perth_tsunami_scenario' |
---|
42 | ##One or all can be changed each time the run_scenario script is excuted |
---|
43 | tide = 0 #0.6 |
---|
44 | #event_number = 27255 |
---|
45 | event_number = 27283 |
---|
46 | alpha = 0.1 |
---|
47 | friction=0.01 |
---|
48 | starttime=0 |
---|
49 | finaltime=80000 |
---|
50 | |
---|
51 | interior_mesh = 'all' # Can have 'all' or 'none' for Phase 2 study |
---|
52 | |
---|
53 | setup='final' ## Can replace with trial or basic, this action will thin the mesh |
---|
54 | ## so that the run script will take less time (hence less acurate) |
---|
55 | |
---|
56 | if setup =='trial': |
---|
57 | print'trial' |
---|
58 | res_factor=10 |
---|
59 | time_thinning=48 |
---|
60 | yieldstep=240 |
---|
61 | if setup =='basic': |
---|
62 | print'basic' |
---|
63 | res_factor=4 |
---|
64 | time_thinning=12 |
---|
65 | yieldstep=120 |
---|
66 | if setup =='final': |
---|
67 | print'final' |
---|
68 | res_factor=1 |
---|
69 | time_thinning=4 |
---|
70 | yieldstep=60 |
---|
71 | |
---|
72 | #------------------------------------------------------------------------------ |
---|
73 | # Output Filename |
---|
74 | #------------------------------------------------------------------------------ |
---|
75 | ##Important to distiquish each run |
---|
76 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_250m_' + str(interior_mesh) +'_'+str(user) |
---|
77 | |
---|
78 | #------------------------------------------------------------------------------ |
---|
79 | # INPUT DATA |
---|
80 | #------------------------------------------------------------------------------ |
---|
81 | |
---|
82 | ##ELEVATION DATA## - used in build_perth.py |
---|
83 | ## onshore data: format ascii grid with accompaning projection file |
---|
84 | grid_250m_2005 = 'grid' |
---|
85 | |
---|
86 | ##GAUGES## - used in get_timeseries.py |
---|
87 | gauge_name = 'perth.csv' |
---|
88 | gauge_name2 = 'thinned_MGA50.csv' |
---|
89 | |
---|
90 | ##BOUNDING POLYGON## -used in build_boundary.py and run_perth.py respectively |
---|
91 | #NOTE: when files are put together must be in sequence - for ease go clockwise! |
---|
92 | #Check the run_perth.py for boundary_tags |
---|
93 | ##thinned ordering file from Hazard Map: format index,latitude,longitude (with title) |
---|
94 | order_filename = 'thinned_boundary_ordering.txt' |
---|
95 | ##landward bounding points |
---|
96 | landward = 'landward_bounding_polygon.txt' |
---|
97 | |
---|
98 | #------------------------------------------------------------------------------ |
---|
99 | # OUTPUT ELEVATION DATA |
---|
100 | #------------------------------------------------------------------------------ |
---|
101 | ##Output filename for elevation |
---|
102 | ## its a combination of all the data put together (utilisied in build_boundary) |
---|
103 | combined_name ='perth_combined_elevation_250m' |
---|
104 | |
---|
105 | #------------------------------------------------------------------------------ |
---|
106 | # Directory Structure |
---|
107 | #------------------------------------------------------------------------------ |
---|
108 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
109 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
110 | topographies_dir = anuga_dir+'topographies'+sep |
---|
111 | polygons_dir = anuga_dir+'polygons'+sep |
---|
112 | tide_dir = anuga_dir+'tide_data'+sep |
---|
113 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
114 | output_dir = anuga_dir+'outputs'+sep |
---|
115 | gauges_dir = anuga_dir+'gauges'+sep |
---|
116 | meshes_dir = anuga_dir+'meshes'+sep |
---|
117 | |
---|
118 | #------------------------------------------------------------------------------ |
---|
119 | # Location of input and output Data |
---|
120 | #------------------------------------------------------------------------------ |
---|
121 | ##where the input data sits |
---|
122 | onshore_in_dir_name = topographies_in_dir + grid_250m_2005 |
---|
123 | |
---|
124 | ##where the output data sits |
---|
125 | onshore_dir_name = topographies_dir + grid_250m_2005 |
---|
126 | |
---|
127 | ##where the combined file sits |
---|
128 | combined_dir_name = topographies_dir + combined_name |
---|
129 | |
---|
130 | ##where the mesh sits (this is created during the run_perth.py) |
---|
131 | meshes_dir_name = meshes_dir + scenario_name + interior_mesh + '.msh' |
---|
132 | |
---|
133 | #where the boundary order files sit (this is used within build_boundary.py) |
---|
134 | order_filename_dir = boundaries_dir + order_filename |
---|
135 | |
---|
136 | #where the landward points of boundary extent sit (this is used within run_perth.py) |
---|
137 | landward_dir = boundaries_dir + landward |
---|
138 | |
---|
139 | #where the event sts files sits (this is created during the build_boundary.py) |
---|
140 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
141 | boundaries_dir_mux = muxhome |
---|
142 | |
---|
143 | #where the directory of the output filename sits |
---|
144 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_perth.py |
---|
145 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_perth.py |
---|
146 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
147 | |
---|
148 | #where the directory of the gauges sit |
---|
149 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
150 | gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
151 | |
---|
152 | #------------------------------------------------------------------------------ |
---|
153 | # Interior region definitions |
---|
154 | #------------------------------------------------------------------------------ |
---|
155 | |
---|
156 | #Land, to set the stage/water to be offcoast only |
---|
157 | poly_mainland = read_polygon(polygons_dir+'initial_condition.csv') |
---|
158 | |
---|
159 | #Initial bounding polygon for data clipping |
---|
160 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
161 | res_poly_all = 100000*res_factor |
---|
162 | |
---|
163 | #Area of Interest 1 (Fremantle) |
---|
164 | poly_aoi1 = read_polygon(polygons_dir+'CBD_coastal.csv') |
---|
165 | res_aoi1 = 500*res_factor |
---|
166 | |
---|
167 | #Area of Interest 2 (Rockingham) |
---|
168 | poly_aoi2 = read_polygon(polygons_dir+'rockingham_penguin.csv') |
---|
169 | res_aoi2 = 500*res_factor |
---|
170 | |
---|
171 | #Area of Interest 2 (garden Island) |
---|
172 | poly_aoi2a = read_polygon(polygons_dir+'garden.csv') |
---|
173 | res_aoi2a= 500*res_factor |
---|
174 | |
---|
175 | #Area of Interest 3 (geordie bay - record of tsunami impact) |
---|
176 | poly_aoi3 = read_polygon(polygons_dir+'geordie_bay.csv') |
---|
177 | res_aoi3 = 500*res_factor |
---|
178 | |
---|
179 | #Area of Interest 4 (sorrento - record of tsunami impact) |
---|
180 | poly_aoi4 = read_polygon(polygons_dir+'sorrento_gauge.csv') |
---|
181 | res_aoi4 = 500*res_factor |
---|
182 | |
---|
183 | #Area of Significance 1 (Garden Island and sand bank infront of Rockingham) |
---|
184 | poly_aos1 = read_polygon(polygons_dir+'garden_rockingham.csv') |
---|
185 | res_aos1 = 1000*res_factor |
---|
186 | |
---|
187 | #Area of Significance 2 (incorporate coastline of rottnest) |
---|
188 | poly_aos2 = read_polygon(polygons_dir+'rottnest_external.csv') |
---|
189 | res_aos2 = 1000*res_factor |
---|
190 | |
---|
191 | #Refined areas |
---|
192 | #Polygon designed to incorporate Dredge Area from Fremantle to |
---|
193 | #Rockingham the steep incline was making the mesh go to 0 |
---|
194 | poly_aos3 = read_polygon(polygons_dir+'DredgeArea.csv') |
---|
195 | res_aos3 = 1000*res_factor |
---|
196 | |
---|
197 | #Shallow water 1 |
---|
198 | poly_sw1 = read_polygon(polygons_dir+'internal_h20mORd3km.csv') |
---|
199 | res_sw1 = 25000*res_factor |
---|
200 | |
---|
201 | #Deep water (land of Rottnest, ANUGA does not do donuts!) |
---|
202 | poly_dw1 = read_polygon(polygons_dir+'rottnest_internal.csv') |
---|
203 | res_dw1 = 100000*res_factor |
---|
204 | |
---|
205 | # Combined all regions, must check that all are included! |
---|
206 | |
---|
207 | if interior_mesh =='all': |
---|
208 | print'Mesh = all' |
---|
209 | interior_regions = [[poly_aoi1,res_aoi1],[poly_aoi2,res_aoi2] |
---|
210 | ,[poly_aoi2a,res_aoi2a],[poly_aoi3,res_aoi3] |
---|
211 | ,[poly_aoi4,res_aoi4],[poly_aos1,res_aos1] |
---|
212 | ,[poly_aos2,res_aos2],[poly_aos3,res_aos3] |
---|
213 | ,[poly_sw1,res_sw1], [poly_dw1,res_dw1]] |
---|
214 | if interior_mesh =='none': |
---|
215 | print'Mesh = none' |
---|
216 | interior_regions = [] |
---|
217 | |
---|
218 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
219 | print 'min estimated number of triangles', trigs_min |
---|
220 | |
---|
221 | |
---|
222 | #------------------------------------------------------------------------------ |
---|
223 | # Clipping regions for export to asc and regions for clipping data |
---|
224 | #------------------------------------------------------------------------------ |
---|
225 | |
---|
226 | #Geordie Bay extract ascii grid |
---|
227 | xminGeordie = 358000 |
---|
228 | xmaxGeordie = 362000 |
---|
229 | yminGeordie = 6458500 |
---|
230 | ymaxGeordie = 6461000 |
---|
231 | |
---|
232 | #Sorrento extract ascii grid |
---|
233 | xminSorrento = 379000 |
---|
234 | xmaxSorrento = 382500 |
---|
235 | yminSorrento = 6477000 |
---|
236 | ymaxSorrento = 6480000 |
---|
237 | |
---|
238 | #Fremantle extract ascii grid |
---|
239 | xminFremantle = 376000 |
---|
240 | xmaxFremantle = 388000 |
---|
241 | yminFremantle = 6449000 |
---|
242 | ymaxFremantle = 6461000 |
---|
243 | |
---|
244 | #Rockingham extract ascii grid |
---|
245 | xminRockingham = 373500 |
---|
246 | xmaxRockingham = 385500 |
---|
247 | yminRockingham = 6424000 |
---|
248 | ymaxRockingham = 6433000 |
---|
249 | |
---|