1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
2 | This script is the heart of all scripts in the 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 | # determines time for setting up output directories |
---|
28 | time = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
29 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) |
---|
30 | build_time = time+'_build' |
---|
31 | run_time = time+'_run' |
---|
32 | |
---|
33 | #------------------------------------------------------------------------------ |
---|
34 | # Initial Conditions |
---|
35 | #------------------------------------------------------------------------------ |
---|
36 | |
---|
37 | # this section needs to be updated to reflect the modelled community. |
---|
38 | # Note, the user needs to set up the directory system accordingly |
---|
39 | state = 'western_australia' |
---|
40 | scenario_name = 'pt_hedland' |
---|
41 | scenario = 'pt_hedland_tsunami_scenario_2008' |
---|
42 | |
---|
43 | # Model specific parameters. One or all can be changed each time the |
---|
44 | # run_scenario script is executed |
---|
45 | tide = 0 #0.6 |
---|
46 | #event_number = 27255 # linked to hazard map |
---|
47 | event_number = 27283 |
---|
48 | alpha = 0.1 # smoothing parameter for mesh |
---|
49 | friction=0.01 # manning's friction coefficient |
---|
50 | starttime=0 |
---|
51 | finaltime=80000 # final time for simulation |
---|
52 | |
---|
53 | setup='final' # Final can be replaced with trial or basic. |
---|
54 | # Either will result in a coarser mesh that will allow a |
---|
55 | # faster, but less accurate, simulation. |
---|
56 | |
---|
57 | if setup =='trial': |
---|
58 | print'trial' |
---|
59 | res_factor=10 |
---|
60 | time_thinning=48 |
---|
61 | yieldstep=240 |
---|
62 | if setup =='basic': |
---|
63 | print'basic' |
---|
64 | res_factor=4 |
---|
65 | time_thinning=12 |
---|
66 | yieldstep=120 |
---|
67 | if setup =='final': |
---|
68 | print'final' |
---|
69 | res_factor=1 |
---|
70 | time_thinning=4 |
---|
71 | yieldstep=60 |
---|
72 | |
---|
73 | #------------------------------------------------------------------------------ |
---|
74 | # Output Filename |
---|
75 | #------------------------------------------------------------------------------ |
---|
76 | # Important to distinguish each run - ensure str(user) is included! |
---|
77 | # Note, the user is free to include as many parameters as desired |
---|
78 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_'+ 'alpha' +str(alpha)+'_'+str(user) |
---|
79 | |
---|
80 | #------------------------------------------------------------------------------ |
---|
81 | # Input Data |
---|
82 | #------------------------------------------------------------------------------ |
---|
83 | |
---|
84 | # elevation data used in build_pt_hedland.py |
---|
85 | # onshore data: format ascii grid with accompanying projection file |
---|
86 | onshore_name = 'dli_dem_clip' |
---|
87 | # island: format ascii grid with accompanying projection file |
---|
88 | |
---|
89 | # coastline: format x,y,elevation (with title) |
---|
90 | coast_name = 'coastline.txt' |
---|
91 | # bathymetry: format x,y,elevation (with title) |
---|
92 | offshore_name = 'port_hedland_new2.txt' |
---|
93 | |
---|
94 | |
---|
95 | # gauges - used in get_timeseries.py |
---|
96 | #gauge_name = 'pt_hedland.csv' |
---|
97 | #gauge_name2 = 'thinned_MGA50.csv' |
---|
98 | |
---|
99 | # BOUNDING POLYGON - used in build_boundary.py and run_pt_hedland.py respectively |
---|
100 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
101 | # Check the run_pt_hedland.py for boundary_tags |
---|
102 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
103 | order_filename = 'thinned_boundary_ordering.csv' |
---|
104 | #landward bounding points |
---|
105 | landward = 'landward_bounding_polygon.csv' |
---|
106 | |
---|
107 | #------------------------------------------------------------------------------ |
---|
108 | # Output Elevation Data |
---|
109 | #------------------------------------------------------------------------------ |
---|
110 | # Output filename for elevation |
---|
111 | # this is a combination of all the data (utilisied in build_boundary) |
---|
112 | combined_name ='pt_hedland_combined_elevation' |
---|
113 | combined_smaller_name = 'pt_hedland_combined_elevation_smaller' |
---|
114 | |
---|
115 | #------------------------------------------------------------------------------ |
---|
116 | # Directory Structure |
---|
117 | #------------------------------------------------------------------------------ |
---|
118 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
119 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
120 | topographies_dir = anuga_dir+'topographies'+sep |
---|
121 | polygons_dir = anuga_dir+'polygons'+sep |
---|
122 | tide_dir = anuga_dir+'tide_data'+sep |
---|
123 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
124 | output_dir = anuga_dir+'outputs'+sep |
---|
125 | gauges_dir = anuga_dir+'gauges'+sep |
---|
126 | meshes_dir = anuga_dir+'meshes'+sep |
---|
127 | |
---|
128 | #------------------------------------------------------------------------------ |
---|
129 | # Location of input and output data |
---|
130 | #------------------------------------------------------------------------------ |
---|
131 | # where the input data sits |
---|
132 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
133 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
134 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
135 | |
---|
136 | # where the output data sits |
---|
137 | onshore_dir_name = topographies_dir + onshore_name |
---|
138 | coast_dir_name = topographies_dir + coast_name |
---|
139 | offshore_dir_name = topographies_dir + offshore_name |
---|
140 | |
---|
141 | |
---|
142 | # where the combined elevation file sits |
---|
143 | combined_dir_name = topographies_dir + combined_name |
---|
144 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
145 | |
---|
146 | # where the mesh sits (this is created during the run_pt_hedland.py) |
---|
147 | meshes_dir_name = meshes_dir + scenario_name+'.msh' |
---|
148 | |
---|
149 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
150 | order_filename_dir = boundaries_dir + order_filename |
---|
151 | |
---|
152 | # where the landward points of boundary extent sit (this is used within run_pt_hedland.py) |
---|
153 | landward_dir = boundaries_dir + landward |
---|
154 | |
---|
155 | # where the event sts files sits (this is created during the build_boundary.py) |
---|
156 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
157 | boundaries_dir_mux = muxhome |
---|
158 | |
---|
159 | # where the directory of the output filename sits |
---|
160 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_pt_hedland.py |
---|
161 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_pt_hedland.py |
---|
162 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
163 | |
---|
164 | #w here the directory of the gauges sit |
---|
165 | #gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
166 | #gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
167 | |
---|
168 | #------------------------------------------------------------------------------ |
---|
169 | # Interior region definitions |
---|
170 | #------------------------------------------------------------------------------ |
---|
171 | |
---|
172 | #Land, to set the initial stage/water to be offcoast only |
---|
173 | poly_mainland = read_polygon(polygons_dir+'initial_conditions_mainland.csv') |
---|
174 | |
---|
175 | #Ocean |
---|
176 | poly_ocean = read_polygon(polygons_dir+'initial_conditions_ocean.csv') |
---|
177 | |
---|
178 | # Initial bounding polygon for data clipping |
---|
179 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
180 | res_poly_all = 100000*res_factor |
---|
181 | |
---|
182 | # Area of Interest 1 (pt_hedland) |
---|
183 | poly_aoi1 = read_polygon(polygons_dir+'area_of_interest.csv') |
---|
184 | res_aoi1 = 500*res_factor |
---|
185 | |
---|
186 | # Area of Significance 1 (pt_hedland) |
---|
187 | poly_aos1 = read_polygon(polygons_dir+'area_of_significance.csv') |
---|
188 | res_aos1 = 1000*res_factor |
---|
189 | |
---|
190 | # Shallow water 1 |
---|
191 | poly_sw1 = read_polygon(polygons_dir+'shallow_water.csv') |
---|
192 | res_sw1 = 25000*res_factor |
---|
193 | |
---|
194 | |
---|
195 | # Combined all regions, must check that all are included! |
---|
196 | interior_regions = [[poly_aoi1,res_aoi1],[poly_aos1,res_aos1] |
---|
197 | ,[poly_sw1,res_sw1]] |
---|
198 | |
---|
199 | |
---|
200 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
201 | print 'min estimated number of triangles', trigs_min |
---|
202 | |
---|
203 | #------------------------------------------------------------------------------ |
---|
204 | # Clipping regions for export to asc and regions for clipping data |
---|
205 | # Final inundation maps should only be created in regions of the finest mesh |
---|
206 | #------------------------------------------------------------------------------ |
---|
207 | ## |
---|
208 | ###Geordie Bay extract ascii grid |
---|
209 | ##xminGeordie = 358000 |
---|
210 | ##xmaxGeordie = 362000 |
---|
211 | ##yminGeordie = 6458500 |
---|
212 | ##ymaxGeordie = 6461000 |
---|
213 | ## |
---|
214 | ###Sorrento extract ascii grid |
---|
215 | ##xminSorrento = 379000 |
---|
216 | ##xmaxSorrento = 382500 |
---|
217 | ##yminSorrento = 6477000 |
---|
218 | ##ymaxSorrento = 6480000 |
---|
219 | ## |
---|
220 | ###Fremantle extract ascii grid |
---|
221 | ##xminFremantle = 376000 |
---|
222 | ##xmaxFremantle = 388000 |
---|
223 | ##yminFremantle = 6449000 |
---|
224 | ##ymaxFremantle = 6461000 |
---|
225 | ## |
---|
226 | ###Rockingham extract ascii grid |
---|
227 | ##xminRockingham = 373500 |
---|
228 | ##xmaxRockingham = 385500 |
---|
229 | ##yminRockingham = 6424000 |
---|
230 | ##ymaxRockingham = 6433000 |
---|
231 | |
---|