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 | import csv |
---|
11 | |
---|
12 | |
---|
13 | #------------------------------------------------------------------------------- |
---|
14 | # Directory setup |
---|
15 | #------------------------------------------------------------------------------- |
---|
16 | |
---|
17 | # this section needs to be updated to reflect the modelled community. |
---|
18 | # Note, the user needs to set up the directory system accordingly |
---|
19 | state = 'new_south_wales' |
---|
20 | scenario_name = 'gosford' |
---|
21 | scenario_folder = 'gosford_tsunami_scenario_2009' |
---|
22 | |
---|
23 | #------------------------------------------------------------------------------- |
---|
24 | # Initial Conditions |
---|
25 | #------------------------------------------------------------------------------- |
---|
26 | |
---|
27 | |
---|
28 | # Model specific parameters. |
---|
29 | # One or all can be changed each time the run_model script is executed |
---|
30 | tide = 0 # difference between MSL and HAT in metres |
---|
31 | zone = 56 # specify zone of model |
---|
32 | #event_number = 58242 # Puysegur 1 in 10 000 # the event number or the mux file name |
---|
33 | event_number = 51436 # New Hebrides 1 in 10 000 |
---|
34 | #event_number = 58349 # Puysegur 1 in 5000 |
---|
35 | #event_number = 58284 # Puysegur 1 in 2000 |
---|
36 | #event_number = 58187 # Puysegur 1 in 1000 |
---|
37 | #event_number = 58113 # Puysegur 1 in 500 |
---|
38 | #event_number = 58025 # Puysegur 1 in 200 |
---|
39 | |
---|
40 | alpha = 0.1 # smoothing parameter for mesh |
---|
41 | friction=0.01 # manning's friction coefficient |
---|
42 | starttime=0 # start time for simulation |
---|
43 | finaltime=1000 # final time for simulation |
---|
44 | |
---|
45 | setup = 'final' # This can be one of three values |
---|
46 | # trial - coarsest mesh, fast |
---|
47 | # basic - coarse mesh |
---|
48 | # final - fine mesh, slowest |
---|
49 | |
---|
50 | #------------------------------------------------------------------------------- |
---|
51 | # Output filename |
---|
52 | # |
---|
53 | # Your output filename should be unique between different runs on different data. |
---|
54 | # The list of items below will be used to create a file in your output directory. |
---|
55 | # Your user name and time+date will be automatically added. For example, |
---|
56 | # [setup, tide, event_number] |
---|
57 | # will result in a filename like |
---|
58 | # 20090212_091046_run_final_0_27283_rwilson |
---|
59 | #------------------------------------------------------------------------------- |
---|
60 | |
---|
61 | output_comment = [setup, tide, event_number] |
---|
62 | |
---|
63 | #------------------------------------------------------------------------------- |
---|
64 | # Input Data |
---|
65 | #------------------------------------------------------------------------------- |
---|
66 | |
---|
67 | # ELEVATION DATA |
---|
68 | # Used in build_elevation.py |
---|
69 | # Format for ascii grids, as produced in ArcGIS + a projection file |
---|
70 | ascii_grid_filenames = ['e151_s34_clip2', |
---|
71 | 'aus197_topo2raster_clip', |
---|
72 | 'hydro_topo2raster_clip'] |
---|
73 | #'aus197_topo2raster_terrigal'] #GA data?? |
---|
74 | |
---|
75 | |
---|
76 | |
---|
77 | #Get long list of Lidar filenames. |
---|
78 | ENV_INUNDATIONHOME = 'INUNDATIONHOME' |
---|
79 | home = join(os.getenv(ENV_INUNDATIONHOME), 'data') |
---|
80 | anuga_folder = join(home, state, scenario_folder, 'anuga') |
---|
81 | topographies_folder = join(anuga_folder, 'topographies/original') |
---|
82 | |
---|
83 | file_list = join(topographies_folder, 'file_list.csv') |
---|
84 | ###file_list2 = join(topographies_folder, 'file_list2.csv') |
---|
85 | fid = csv.reader(open(file_list)) |
---|
86 | ###fid2 = csv.reader(open(file_list2)) |
---|
87 | lidar_filenames = [] |
---|
88 | for row in fid: |
---|
89 | lidar_filenames.append(','.join(row)) |
---|
90 | ##for row in fid2: |
---|
91 | ## lidar_filenames.append(','.join(row)) |
---|
92 | ###print lidar_filenames |
---|
93 | #lidar_filenames = list(lidar_filenames) |
---|
94 | #print lidar_filenames |
---|
95 | |
---|
96 | # Format for point is x,y,elevation (with header) |
---|
97 | point_filenames = ['estuaries.txt', |
---|
98 | ## 'XYHI341_HSDB_SD100035103', |
---|
99 | ## 'XYAHD', |
---|
100 | ## 'XYSCHOOL_11_99_HSDB_SD100021002_MGA', |
---|
101 | 'ENT5C1S08_03_AHD_prepared.txt', |
---|
102 | 'ENT5C1S09_03_AHD_prepared.txt', |
---|
103 | 'ENT5C1S10_03_AHD_prepared.txt', |
---|
104 | ## 'XYAHD', |
---|
105 | ## 'XYHI341_HSDB_SD100035103_MGA', |
---|
106 | ## 'XYHI339_F_HSDB_SD100031669_MGA', |
---|
107 | ## 'AUS197_MGA_AHD_1972.txt', |
---|
108 | 'hydro_neg.txt' |
---|
109 | ] |
---|
110 | point_filenames.extend(lidar_filenames) |
---|
111 | #print point_filenames |
---|
112 | |
---|
113 | |
---|
114 | ### Add csv header list to all files in point_filenames |
---|
115 | ##headerlist = ['x', 'y', 'elevation'] |
---|
116 | ##for f in point_filenames: |
---|
117 | ## add_csv_header(join(topographies_folder, f), headerlist) |
---|
118 | |
---|
119 | # BOUNDING POLYGON - for data clipping and estimate of triangles in mesh |
---|
120 | # Used in build_elevation.py |
---|
121 | # Format for points easting,northing (no header) |
---|
122 | bounding_polygon_filename = 'bounding_polygon.csv' |
---|
123 | bounding_polygon_maxarea = 100000 |
---|
124 | |
---|
125 | # INTERIOR REGIONS - for designing the mesh |
---|
126 | # Used in run_model.py |
---|
127 | # Format for points easting,northing (no header) |
---|
128 | |
---|
129 | interior_regions_data =[['aoi_umina.csv', 500], |
---|
130 | ['aoi_terrigal.csv', 500], |
---|
131 | ['aos_umina.csv', 2500], |
---|
132 | ['aos_terrigal.csv', 2500]] |
---|
133 | |
---|
134 | |
---|
135 | # LAND - used to set the initial stage/water to be offcoast only |
---|
136 | # Used in run_model.py. Format for points easting,northing (no header) |
---|
137 | land_initial_conditions_filename = [['initial_conditions.csv', 0]] |
---|
138 | |
---|
139 | |
---|
140 | # GAUGES - for creating timeseries at a specific point |
---|
141 | # Used in get_timeseries.py. |
---|
142 | # Format easting,northing,name,elevation (with header) |
---|
143 | gauges_filename = 'gauges.csv' |
---|
144 | |
---|
145 | # BUILDINGS EXPOSURE - for identifying inundated houses |
---|
146 | # Used in run_building_inundation.py |
---|
147 | # Format latitude,longitude etc (geographic) |
---|
148 | ##building_exposure_filename = 'busselton_res_clip.csv' # from NEXIS |
---|
149 | |
---|
150 | # BOUNDING POLYGON - used in build_boundary.py and run_model.py respectively |
---|
151 | # NOTE: when files are put together the points must be in sequence |
---|
152 | # For ease go clockwise! |
---|
153 | # Check the run_model.py for boundary_tags |
---|
154 | |
---|
155 | # Thinned ordering file from Hazard Map (geographic) |
---|
156 | # Format is index,latitude,longitude (with header) |
---|
157 | urs_order_filename = 'urs_order.csv' |
---|
158 | |
---|
159 | # Landward bounding points |
---|
160 | # Format easting,northing (no header) |
---|
161 | landward_boundary_filename = 'landward_boundary.csv' |
---|
162 | |
---|
163 | # MUX input filename. |
---|
164 | # If a meta-file from EventSelection is used, set 'multi-mux' to True. |
---|
165 | # If a single MUX stem filename (*.grd) is used, set 'multi-mux' to False. |
---|
166 | ##mux_input_filename = event_number # to be found in event_folder |
---|
167 | # (ie boundaries/event_number/) |
---|
168 | ##multi_mux = False |
---|
169 | mux_input_filename = 'event.list' |
---|
170 | multi_mux = True |
---|
171 | |
---|
172 | zone = 56 |
---|
173 | #------------------------------------------------------------------------------- |
---|
174 | # Clipping regions for export to asc and regions for clipping data |
---|
175 | # Final inundation maps should only be created in regions of the finest mesh |
---|
176 | #------------------------------------------------------------------------------- |
---|
177 | |
---|
178 | # ASCII export grid for Busselton |
---|
179 | xminBusselton = 340000 |
---|
180 | xmaxBusselton = 352000 |
---|
181 | yminBusselton = 6271500 |
---|
182 | ymaxBusselton = 6280000 |
---|
183 | |
---|
184 | # ASCII export grid for Bunbury |
---|
185 | xminBunbury = 369000 |
---|
186 | xmaxBunbury = 381000 |
---|
187 | yminBunbury = 6308000 |
---|
188 | ymaxBunbury = 6316500 |
---|
189 | |
---|
190 | ################################################################################ |
---|
191 | ################################################################################ |
---|
192 | #### NOTE: NOTHING WOULD NORMALLY CHANGE BELOW THIS POINT. #### |
---|
193 | ################################################################################ |
---|
194 | ################################################################################ |
---|
195 | |
---|
196 | # Get system user and host names. |
---|
197 | # These values can be used to distinguish between two similar runs by two |
---|
198 | # different users or runs by the same user on two different machines. |
---|
199 | user = get_user_name() |
---|
200 | host = get_host_name() |
---|
201 | |
---|
202 | # Environment variable names. |
---|
203 | # The inundation directory, not the data directory. |
---|
204 | ENV_INUNDATIONHOME = 'INUNDATIONHOME' |
---|
205 | |
---|
206 | # Path to MUX data |
---|
207 | ENV_MUXHOME = 'MUXHOME' |
---|
208 | |
---|
209 | #------------------------------------------------------------------------------- |
---|
210 | # Output Elevation Data |
---|
211 | #------------------------------------------------------------------------------- |
---|
212 | |
---|
213 | # Output filename for elevation |
---|
214 | # this is a combination of all the data generated in build_elevation.py |
---|
215 | combined_elevation_basename = scenario_name + '_combined_elevation' |
---|
216 | |
---|
217 | #------------------------------------------------------------------------------- |
---|
218 | # Directory Structure |
---|
219 | #------------------------------------------------------------------------------- |
---|
220 | |
---|
221 | # determines time for setting up output directories |
---|
222 | time = strftime('%Y%m%d_%H%M%S', localtime()) |
---|
223 | gtime = strftime('%Y%m%d_%H%M%S', gmtime()) |
---|
224 | build_time = time + '_build' |
---|
225 | run_time = time + '_run_' |
---|
226 | |
---|
227 | # create paths generated from environment variables. |
---|
228 | home = join(os.getenv(ENV_INUNDATIONHOME), 'data') # Absolute path for data folder |
---|
229 | muxhome = os.getenv(ENV_MUXHOME) |
---|
230 | |
---|
231 | # check various directories/files that must exist |
---|
232 | anuga_folder = join(home, state, scenario_folder, 'anuga') |
---|
233 | topographies_folder = join(anuga_folder, 'topographies/original') |
---|
234 | polygons_folder = join(anuga_folder, 'polygons') |
---|
235 | boundaries_folder = join(anuga_folder, 'boundaries') |
---|
236 | output_folder = join(anuga_folder, 'outputs') |
---|
237 | gauges_folder = join(anuga_folder, 'gauges') |
---|
238 | meshes_folder = join(anuga_folder, 'meshes') |
---|
239 | event_folder = join(boundaries_folder, str(event_number)) |
---|
240 | |
---|
241 | # MUX data files |
---|
242 | # Directory containing the MUX data files to be used with EventSelection. |
---|
243 | mux_data_folder = join(muxhome, 'mux') |
---|
244 | |
---|
245 | #------------------------------------------------------------------------------- |
---|
246 | # Location of input and output data |
---|
247 | #------------------------------------------------------------------------------- |
---|
248 | |
---|
249 | # Convert the user output_comment to a string for run_model.py |
---|
250 | output_comment = ('_'.join([str(x) for x in output_comment if x != user]) |
---|
251 | + '_' + user) |
---|
252 | |
---|
253 | # The absolute pathname of the all elevation, generated in build_elevation.py |
---|
254 | combined_elevation = join(topographies_folder, combined_elevation_basename) |
---|
255 | |
---|
256 | # The absolute pathname of the mesh, generated in run_model.py |
---|
257 | meshes = join(meshes_folder, scenario_name) + '.msh' |
---|
258 | |
---|
259 | # The pathname for the urs order points, used within build_urs_boundary.py |
---|
260 | urs_order = join(boundaries_folder, urs_order_filename) |
---|
261 | |
---|
262 | # The absolute pathname for the landward points of the bounding polygon, |
---|
263 | # Used within run_model.py) |
---|
264 | landward_boundary = join(boundaries_folder, landward_boundary_filename) |
---|
265 | |
---|
266 | # The absolute pathname for the .sts file, generated in build_boundary.py |
---|
267 | event_sts = join(event_folder, scenario_name) |
---|
268 | |
---|
269 | # The absolute pathname for the output folder names |
---|
270 | # Used for build_elevation.py |
---|
271 | output_build = join(output_folder, build_time) + '_' + str(user) |
---|
272 | # Used for run_model.py |
---|
273 | output_run = join(output_folder, run_time) + output_comment |
---|
274 | # Used by post processing |
---|
275 | output_run_time = join(output_run, scenario_name) |
---|
276 | |
---|
277 | # The absolute pathname for the gauges file |
---|
278 | # Used for get_timeseries.py |
---|
279 | gauges = join(gauges_folder, gauges_filename) |
---|
280 | |
---|
281 | # The absolute pathname for the building file |
---|
282 | # Used for run_building_inundation.py |
---|
283 | ##building_exposure = join(gauges_folder, building_exposure_filename) |
---|
284 | |
---|
285 | # full path to where MUX files (or meta-files) live |
---|
286 | mux_input = join(event_folder, mux_input_filename) |
---|
287 | |
---|