1 | """ |
---|
2 | This file contains all your file and directory definitions |
---|
3 | for elevation, meshes and outputs. |
---|
4 | """ |
---|
5 | |
---|
6 | import os |
---|
7 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
8 | from time import localtime, strftime, gmtime |
---|
9 | from os.path import join, exists |
---|
10 | from anuga.lib.add_csv_header.add_csv_header import add_csv_header |
---|
11 | |
---|
12 | #------------------------------------------------------------------------------- |
---|
13 | # Directory setup |
---|
14 | #------------------------------------------------------------------------------- |
---|
15 | |
---|
16 | # this section needs to be updated to reflect the modelled community. |
---|
17 | # Note, the user needs to set up the directory system accordingly |
---|
18 | state = 'australia_ph2' |
---|
19 | scenario_name = 'rockhampton' |
---|
20 | |
---|
21 | #------------------------------------------------------------------------------- |
---|
22 | # Initial Conditions |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | |
---|
25 | # Model specific parameters. |
---|
26 | # One or all can be changed each time the run_model script is executed |
---|
27 | |
---|
28 | central_meridian = None # Central meridian for projection (optional) |
---|
29 | zone = 56 |
---|
30 | import sys |
---|
31 | if len(sys.argv) > 1: |
---|
32 | event_number = int(sys.argv[1]) |
---|
33 | else: |
---|
34 | event_number = 31939 # the event number or the mux file name |
---|
35 | |
---|
36 | event_number_list = [31939, 51314, 63737] # To piggy back multiple events |
---|
37 | |
---|
38 | tide = 0 # difference between MSL and HAT |
---|
39 | alpha = 0.1 # smoothing parameter for mesh |
---|
40 | friction=0.01 # manning's friction coefficient |
---|
41 | starttime=0 # start time for simulation |
---|
42 | finaltime=60000 # final time for simulation |
---|
43 | setup = 'final' # This can be one of three values |
---|
44 | # trial - coarsest mesh, fast |
---|
45 | # basic - coarse mesh |
---|
46 | # final - fine mesh, slowest |
---|
47 | |
---|
48 | # index is only used when wave = Tb |
---|
49 | index = 3163 # index from the PTHA - Y2000 0.257m |
---|
50 | wave = 'Tb' # Bf (sts wave) Tb (index wave) |
---|
51 | |
---|
52 | |
---|
53 | internal_polygon = False |
---|
54 | |
---|
55 | #------------------------------------------------------------------------------- |
---|
56 | # Output filename |
---|
57 | # |
---|
58 | # Your output filename should be unique between different runs on different data. |
---|
59 | # The list of items below will be used to create a file in your output directory. |
---|
60 | # Your user name and time+date will be automatically added. For example, |
---|
61 | # [setup, tide, event_number] |
---|
62 | # will result in a filename like |
---|
63 | # 20090212_091046_run_final_0_27283_rwilson |
---|
64 | #------------------------------------------------------------------------------- |
---|
65 | |
---|
66 | if internal_polygon: |
---|
67 | internal_poly_comment = 'internal' |
---|
68 | else: |
---|
69 | internal_poly_comment = '' |
---|
70 | |
---|
71 | output_comment = [setup, tide, event_number, index, wave, internal_poly_comment] |
---|
72 | |
---|
73 | #------------------------------------------------------------------------------- |
---|
74 | # Input Data |
---|
75 | #------------------------------------------------------------------------------- |
---|
76 | |
---|
77 | # ELEVATION DATA |
---|
78 | # Used in build_elevation.py |
---|
79 | # Format for ascii grids, as produced in ArcGIS + a projection file |
---|
80 | ascii_grid_filenames = ['grid250m_pro'] # 250m grid 2005 |
---|
81 | |
---|
82 | # Format for points is x,y,elevation (with header) |
---|
83 | point_filenames = [] |
---|
84 | ##point_filenames = ['ahs100_0.txt', |
---|
85 | ## 'ahs100_1.txt', |
---|
86 | ## 'ahs100_2.txt', |
---|
87 | ## 'ahs100_3.txt', |
---|
88 | ## 'ahs100_4.txt', |
---|
89 | ## 'ahs100_5.txt', |
---|
90 | ## 'ahs100_6.txt', |
---|
91 | ## 'ahs100_7.txt', |
---|
92 | ## 'ahs100_8.txt', |
---|
93 | ## 'ahs100_9.txt', |
---|
94 | ## 'ahs100_10.txt', |
---|
95 | ## 'ahs100_11.txt', |
---|
96 | ## 'ahs100_12.txt', |
---|
97 | ## 'ahs100_13.txt'] # LADS data |
---|
98 | |
---|
99 | ### Add csv header list to all files in point_filenames |
---|
100 | ##headerlist = ['x', 'y', 'elevation'] |
---|
101 | ##for f in point_filenames: |
---|
102 | ## add_csv_header(join(topographies_folder, f), headerlist) |
---|
103 | |
---|
104 | # BOUNDING POLYGON - for data clipping and estimate of triangles in mesh |
---|
105 | # Used in build_elevation.py |
---|
106 | # Format for points: easting,northing (no header) |
---|
107 | bounding_polygon_filename = 'bounding_polygon.csv' |
---|
108 | bounding_polygon_maxarea = 125000 |
---|
109 | |
---|
110 | # INTERIOR REGIONS - for designing the mesh |
---|
111 | # Used in run_model.py |
---|
112 | # Format for points easting,northing (no header) |
---|
113 | interior_regions_data = [] |
---|
114 | |
---|
115 | # add an internal polygon to force different mesh generation |
---|
116 | # used to test for discretisation error when building elevation |
---|
117 | # make sure file is in same folder as interior regions and bouding polygon; |
---|
118 | # format is same (2 column .csv; easting, northing; no header) |
---|
119 | if internal_polygon: |
---|
120 | interior_regions_data.append(['internal_polygon.csv', |
---|
121 | bounding_polygon_maxarea]) |
---|
122 | |
---|
123 | # LAND - used to set the initial stage/water to be offcoast only |
---|
124 | # Used in run_model.py. Format for points easting,northing (no header) |
---|
125 | land_initial_conditions_filename = [] |
---|
126 | |
---|
127 | # GAUGES - for creating timeseries at a specific point |
---|
128 | # Used in get_timeseries.py. |
---|
129 | # Format easting,northing,name,elevation (with header) |
---|
130 | gauges_filename = 'gauges.csv' |
---|
131 | |
---|
132 | # BUILDINGS EXPOSURE - for identifying inundated houses |
---|
133 | # Used in run_building_inundation.py |
---|
134 | # Format latitude,longitude etc (geographic) |
---|
135 | building_exposure_filename = '.csv' # from NEXIS |
---|
136 | |
---|
137 | # BOUNDING POLYGON - used in build_boundary.py and run_model.py respectively |
---|
138 | # NOTE: when files are put together the points must be in sequence |
---|
139 | # For ease go clockwise! |
---|
140 | # Check the run_model.py for boundary_tags |
---|
141 | |
---|
142 | # Thinned ordering file from Hazard Map (geographic) |
---|
143 | # Format is index,latitude,longitude (with header) |
---|
144 | urs_order_filename = 'urs_order_simple.csv' |
---|
145 | |
---|
146 | # Landward bounding points |
---|
147 | # Format easting,northing (no header) |
---|
148 | landward_boundary_filename = 'landward_boundary.csv' |
---|
149 | |
---|
150 | # MUX input filename. |
---|
151 | # If a meta-file from EventSelection is used, set 'multi-mux' to True. |
---|
152 | # If a single MUX stem filename (*.grd) is used, set 'multi-mux' to False. |
---|
153 | ##mux_input_filename = 'Java-0016-z.grd' |
---|
154 | ##multi_mux = False |
---|
155 | mux_input_filename = 'event.list' |
---|
156 | multi_mux = True |
---|
157 | |
---|
158 | # Specify if share cache is to be used |
---|
159 | # Whatever is specified here will be relative to INUNDATION_HOME/.cache |
---|
160 | # If nothing is specified, local cache will be used. |
---|
161 | cachedir = '.python_cache_phII' |
---|
162 | |
---|
163 | |
---|
164 | ################################################################################ |
---|
165 | ################################################################################ |
---|
166 | #### NOTE: NOTHING WOULD NORMALLY CHANGE BELOW THIS POINT. #### |
---|
167 | ################################################################################ |
---|
168 | ################################################################################ |
---|
169 | |
---|
170 | # Get system user and host names. |
---|
171 | # These values can be used to distinguish between two similar runs by two |
---|
172 | # different users or runs by the same user on two different machines. |
---|
173 | user = get_user_name() |
---|
174 | host = get_host_name() |
---|
175 | |
---|
176 | # Environment variable names. |
---|
177 | # The inundation directory, not the data directory. |
---|
178 | ENV_INUNDATIONHOME = 'INUNDATIONHOME' |
---|
179 | |
---|
180 | # Path to MUX data |
---|
181 | ENV_MUXHOME = 'MUXHOME' |
---|
182 | |
---|
183 | #------------------------------------------------------------------------------- |
---|
184 | # Output Elevation Data |
---|
185 | #------------------------------------------------------------------------------- |
---|
186 | |
---|
187 | # Output filename for elevation |
---|
188 | # this is a combination of all the data generated in build_elevation.py |
---|
189 | combined_elevation_basename = scenario_name + '_combined_elevation' |
---|
190 | |
---|
191 | #------------------------------------------------------------------------------- |
---|
192 | # Directory Structure |
---|
193 | #------------------------------------------------------------------------------- |
---|
194 | |
---|
195 | # determines time for setting up output directories |
---|
196 | time = strftime('%Y%m%d_%H%M%S', localtime()) |
---|
197 | gtime = strftime('%Y%m%d_%H%M%S', gmtime()) |
---|
198 | build_time = time + '_build' |
---|
199 | run_time = time + '_run_' |
---|
200 | |
---|
201 | # create paths generated from environment variables. |
---|
202 | home = join(os.getenv(ENV_INUNDATIONHOME), 'data') # Absolute path for data folder |
---|
203 | muxhome = os.getenv(ENV_MUXHOME) |
---|
204 | |
---|
205 | # Create absolute pathname for cache directory |
---|
206 | # and change caching to use it |
---|
207 | if 'cachedir' in dir(): |
---|
208 | cachedir = join(os.getenv(ENV_INUNDATIONHOME), '.cache', cachedir) |
---|
209 | from anuga.caching import caching |
---|
210 | caching.set_option('cachedir', cachedir) |
---|
211 | |
---|
212 | # check various directories/files that must exist |
---|
213 | anuga_folder = join(home, state, scenario_name, 'anuga') |
---|
214 | topographies_folder = join(anuga_folder, 'topographies') |
---|
215 | polygons_folder = join(anuga_folder, 'polygons') |
---|
216 | boundaries_folder = join(anuga_folder, 'boundaries') |
---|
217 | output_folder = join(anuga_folder, 'outputs') |
---|
218 | gauges_folder = join(anuga_folder, 'gauges') |
---|
219 | meshes_folder = join(anuga_folder, 'meshes') |
---|
220 | event_folder = join(boundaries_folder, str(event_number)) |
---|
221 | |
---|
222 | # MUX data files |
---|
223 | # Directory containing the MUX data files to be used with EventSelection. |
---|
224 | mux_data_folder = join(muxhome, 'mux') |
---|
225 | |
---|
226 | #------------------------------------------------------------------------------- |
---|
227 | # Location of input and output data |
---|
228 | #------------------------------------------------------------------------------- |
---|
229 | |
---|
230 | # Convert the user output_comment to a string for run_model.py |
---|
231 | output_comment = ('_'.join([str(x) for x in output_comment if x != user]) |
---|
232 | + '_' + user) |
---|
233 | |
---|
234 | # The absolute pathname of the all elevation, generated in build_elevation.py |
---|
235 | combined_elevation = join(topographies_folder, combined_elevation_basename) |
---|
236 | |
---|
237 | # The absolute pathname of the mesh, generated in run_model.py |
---|
238 | meshes = join(meshes_folder, scenario_name) + '.msh' |
---|
239 | |
---|
240 | # The pathname for the urs order points, used within build_urs_boundary.py |
---|
241 | urs_order = join(boundaries_folder, urs_order_filename) |
---|
242 | |
---|
243 | # The absolute pathname for the landward points of the bounding polygon, |
---|
244 | # Used within run_model.py) |
---|
245 | landward_boundary = join(boundaries_folder, landward_boundary_filename) |
---|
246 | |
---|
247 | # The absolute pathname for the .sts file, generated in build_boundary.py |
---|
248 | event_sts = join(event_folder, scenario_name) |
---|
249 | |
---|
250 | # The absolute pathname for the output folder names |
---|
251 | # Used for build_elevation.py |
---|
252 | output_build = join(output_folder, build_time) + '_' + str(user) |
---|
253 | # Used for run_model.py |
---|
254 | output_run = join(output_folder, run_time) + output_comment |
---|
255 | # Used by post processing |
---|
256 | output_run_time = join(output_run, scenario_name) |
---|
257 | |
---|
258 | # The absolute pathname for the gauges file |
---|
259 | # Used for get_timeseries.py |
---|
260 | gauges = join(gauges_folder, gauges_filename) |
---|
261 | |
---|
262 | # The absolute pathname for the building file |
---|
263 | # Used for run_building_inundation.py |
---|
264 | building_exposure = join(gauges_folder, building_exposure_filename) |
---|
265 | |
---|
266 | # full path to where MUX files (or meta-files) live |
---|
267 | mux_input = join(event_folder, mux_input_filename) |
---|
268 | |
---|
269 | # sts gauge with desired index number - used for wave 'Tb' |
---|
270 | boundary_csv = join(event_folder, 'sts_gauge_' + str(index) + '.csv') |
---|
271 | |
---|
272 | |
---|