[6026] | 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 = 'perth' |
---|
| 41 | scenario = 'perth_tsunami_scenario' |
---|
| 42 | |
---|
| 43 | # Model specific parameters. One or all can be changed each time the |
---|
| 44 | # run_scenario script is executed |
---|
| 45 | tide = 0.6 #0.6 |
---|
| 46 | #event_number = 27255 # Java 9.3 worst case for Perth |
---|
| 47 | #event_number = 68693 # Sumatra 9.2 |
---|
| 48 | event_number = 27283 # Java 9.3 original |
---|
| 49 | alpha = 0.1 # smoothing parameter for mesh |
---|
| 50 | friction=0.01 # manning's friction coefficient |
---|
| 51 | starttime=0 |
---|
| 52 | finaltime=80000 # final time for simulation |
---|
| 53 | |
---|
| 54 | setup='final' # Final can be replaced with trial or basic. |
---|
| 55 | # Either will result in a coarser mesh that will allow a |
---|
| 56 | # faster, but less accurate, simulation. |
---|
| 57 | |
---|
| 58 | if setup =='trial': |
---|
| 59 | print'trial' |
---|
| 60 | res_factor=10 |
---|
| 61 | time_thinning=48 |
---|
| 62 | yieldstep=240 |
---|
| 63 | if setup =='basic': |
---|
| 64 | print'basic' |
---|
| 65 | res_factor=4 |
---|
| 66 | time_thinning=12 |
---|
| 67 | yieldstep=120 |
---|
| 68 | if setup =='final': |
---|
| 69 | print'final' |
---|
| 70 | res_factor=1 |
---|
| 71 | time_thinning=4 |
---|
| 72 | yieldstep=60 |
---|
| 73 | |
---|
| 74 | #------------------------------------------------------------------------------ |
---|
| 75 | # Output Filename |
---|
| 76 | #------------------------------------------------------------------------------ |
---|
| 77 | # Important to distinguish each run - ensure str(user) is included! |
---|
| 78 | # Note, the user is free to include as many parameters as desired |
---|
| 79 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_'+ 'Rockingham_'+str(user) |
---|
| 80 | |
---|
| 81 | #------------------------------------------------------------------------------ |
---|
| 82 | # Input Data |
---|
| 83 | #------------------------------------------------------------------------------ |
---|
| 84 | |
---|
| 85 | # elevation data used in build_perth.py |
---|
| 86 | # onshore data: format ascii grid with accompanying projection file |
---|
| 87 | onshore_name = 'perth_dli_ext' |
---|
| 88 | # island: format ascii grid with accompanying projection file |
---|
| 89 | island_name = 'rott_dli_ext' |
---|
| 90 | island_name1 = 'gard_dli_ext' |
---|
| 91 | island_name2 = 'carnac_island_dli_ext' |
---|
| 92 | island_name3 = 'penguin_dli_ext' |
---|
| 93 | # coastline: format x,y,elevation (with title) |
---|
| 94 | coast_name = 'coastline_perthP.txt' |
---|
| 95 | # bathymetry: format x,y,elevation (with title) |
---|
| 96 | offshore_name = 'Perth.txt' |
---|
| 97 | offshore_name1 = 'Perth_Chart.txt' |
---|
| 98 | offshore_name2 = 'Fremantle_north.txt' |
---|
| 99 | offshore_name3 = 'port_swanriver.txt' |
---|
| 100 | |
---|
| 101 | # gauges - used in get_timeseries.py |
---|
| 102 | gauge_name = 'perth.csv' |
---|
| 103 | gauge_name2 = 'thinned_MGA50.csv' |
---|
| 104 | |
---|
| 105 | #buildings - used in run_building_inundation.py |
---|
| 106 | building = 'perth_res_combined.csv' |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | # BOUNDING POLYGON - used in build_boundary.py and run_perth.py respectively |
---|
| 110 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
| 111 | # Check the run_perth.py for boundary_tags |
---|
| 112 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
| 113 | order_filename = 'thinned_boundary_ordering.csv' |
---|
| 114 | #landward bounding points |
---|
| 115 | landward = 'landward_bounding_polygon.csv' |
---|
| 116 | |
---|
| 117 | #------------------------------------------------------------------------------ |
---|
| 118 | # Output Elevation Data |
---|
| 119 | #------------------------------------------------------------------------------ |
---|
| 120 | # Output filename for elevation |
---|
| 121 | # this is a combination of all the data (utilisied in build_boundary) |
---|
| 122 | combined_name ='perth_combined_elevation' |
---|
| 123 | combined_smaller_name = 'perth_combined_elevation_smaller' |
---|
| 124 | |
---|
| 125 | #------------------------------------------------------------------------------ |
---|
| 126 | # Directory Structure |
---|
| 127 | #------------------------------------------------------------------------------ |
---|
| 128 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
| 129 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
| 130 | topographies_dir = anuga_dir+'topographies'+sep |
---|
| 131 | polygons_dir = anuga_dir+'polygons'+sep |
---|
| 132 | tide_dir = anuga_dir+'tide_data'+sep |
---|
| 133 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
| 134 | output_dir = anuga_dir+'outputs'+sep |
---|
| 135 | gauges_dir = anuga_dir+'gauges'+sep |
---|
| 136 | meshes_dir = anuga_dir+'meshes'+sep |
---|
| 137 | |
---|
| 138 | #------------------------------------------------------------------------------ |
---|
| 139 | # Location of input and output data |
---|
| 140 | #------------------------------------------------------------------------------ |
---|
| 141 | # where the input data sits |
---|
| 142 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
| 143 | island_in_dir_name = topographies_in_dir + island_name |
---|
| 144 | island_in_dir_name1 = topographies_in_dir + island_name1 |
---|
| 145 | island_in_dir_name2 = topographies_in_dir + island_name2 |
---|
| 146 | island_in_dir_name3 = topographies_in_dir + island_name3 |
---|
| 147 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
| 148 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
| 149 | offshore_in_dir_name1 = topographies_in_dir + offshore_name1 |
---|
| 150 | offshore_in_dir_name2 = topographies_in_dir + offshore_name2 |
---|
| 151 | offshore_in_dir_name3 = topographies_in_dir + offshore_name3 |
---|
| 152 | |
---|
| 153 | # where the output data sits |
---|
| 154 | onshore_dir_name = topographies_dir + onshore_name |
---|
| 155 | island_dir_name = topographies_dir + island_name |
---|
| 156 | island_dir_name1 = topographies_dir + island_name1 |
---|
| 157 | island_dir_name2 = topographies_dir + island_name2 |
---|
| 158 | island_dir_name3 = topographies_dir + island_name3 |
---|
| 159 | coast_dir_name = topographies_dir + coast_name |
---|
| 160 | offshore_dir_name = topographies_dir + offshore_name |
---|
| 161 | offshore_dir_name1 = topographies_dir + offshore_name1 |
---|
| 162 | offshore_dir_name2 = topographies_dir + offshore_name2 |
---|
| 163 | offshore_dir_name3 = topographies_dir + offshore_name3 |
---|
| 164 | |
---|
| 165 | # where the combined elevation file sits |
---|
| 166 | combined_dir_name = topographies_dir + combined_name |
---|
| 167 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
| 168 | |
---|
| 169 | # where the mesh sits (this is created during the run_perth.py) |
---|
| 170 | meshes_dir_name = meshes_dir + scenario_name+'.msh' |
---|
| 171 | |
---|
| 172 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
| 173 | order_filename_dir = boundaries_dir + order_filename |
---|
| 174 | |
---|
| 175 | # where the landward points of boundary extent sit (this is used within run_perth.py) |
---|
| 176 | landward_dir = boundaries_dir + landward |
---|
| 177 | |
---|
| 178 | # where the event sts files sits (this is created during the build_boundary.py) |
---|
| 179 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
| 180 | boundaries_dir_mux = muxhome |
---|
| 181 | |
---|
| 182 | # where the directory of the output filename sits |
---|
| 183 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_perth.py |
---|
| 184 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_perth.py |
---|
| 185 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
| 186 | |
---|
| 187 | #w here the directory of the gauges sit |
---|
| 188 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
| 189 | gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
| 190 | building_in_dir_name = gauges_dir + building #used for run_building_inundation.py |
---|
| 191 | |
---|
| 192 | #------------------------------------------------------------------------------ |
---|
| 193 | # Interior region definitions |
---|
| 194 | #------------------------------------------------------------------------------ |
---|
| 195 | |
---|
| 196 | #Land, to set the initial stage/water to be offcoast only |
---|
| 197 | poly_mainland_N = read_polygon(polygons_dir+'initial_conditions_N.csv') |
---|
| 198 | |
---|
| 199 | #Land, to set the initial stage/water to be offcoast only |
---|
| 200 | poly_mainland_S = read_polygon(polygons_dir+'initial_conditions_S.csv') |
---|
| 201 | |
---|
| 202 | #Island, to set the initial stage/water to be offcoast only |
---|
| 203 | poly_island1 = read_polygon(polygons_dir+'initial_conditions_rottnest.csv') |
---|
| 204 | |
---|
| 205 | #Island, to set the initial stage/water to be offcoast only |
---|
| 206 | poly_island2 = read_polygon(polygons_dir+'initial_conditions_garden.csv') |
---|
| 207 | |
---|
| 208 | # Initial bounding polygon for data clipping |
---|
| 209 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
| 210 | res_poly_all = 100000*res_factor |
---|
| 211 | |
---|
| 212 | ### Area of Interest 1 (Fremantle, increase to reach Perth) |
---|
| 213 | ##poly_aoi1 = read_polygon(polygons_dir+'CBD_increase.csv') |
---|
| 214 | ##res_aoi1 = 500*res_factor |
---|
| 215 | |
---|
| 216 | ### Area of Interest 1 (Fremantle) |
---|
| 217 | ##poly_aoi1 = read_polygon(polygons_dir+'CBD_coastal.csv') |
---|
| 218 | ##res_aoi1 = 500*res_factor |
---|
| 219 | ## |
---|
| 220 | # Area of Interest 2 (Rockingham) |
---|
| 221 | poly_aoi2 = read_polygon(polygons_dir+'rockingham_penguin_increase.csv') |
---|
| 222 | res_aoi2 = 500*res_factor |
---|
| 223 | |
---|
| 224 | ### Area of Interest 2 (Rockingham) |
---|
| 225 | ##poly_aoi2 = read_polygon(polygons_dir+'rockingham_penguin.csv') |
---|
| 226 | ##res_aoi2 = 500*res_factor |
---|
| 227 | ## |
---|
| 228 | ### Area of Interest 2 (garden Island) |
---|
| 229 | ##poly_aoi2a = read_polygon(polygons_dir+'garden.csv') |
---|
| 230 | ##res_aoi2a= 500*res_factor |
---|
| 231 | ## |
---|
| 232 | ### Area of Interest 3 (geordie bay - record of tsunami impact) |
---|
| 233 | ##poly_aoi3 = read_polygon(polygons_dir+'geordie_bay.csv') |
---|
| 234 | ##res_aoi3 = 500*res_factor |
---|
| 235 | ## |
---|
| 236 | ### Area of Interest 4 (sorrento - record of tsunami impact) |
---|
| 237 | ##poly_aoi4 = read_polygon(polygons_dir+'sorrento_gauge.csv') |
---|
| 238 | ##res_aoi4 = 500*res_factor |
---|
| 239 | |
---|
| 240 | # Area of Significance 1 (Garden Island and sand bank infront of Rockingham) |
---|
| 241 | poly_aos1 = read_polygon(polygons_dir+'garden_rockingham_increase.csv') |
---|
| 242 | res_aos1 = 1000*res_factor |
---|
| 243 | |
---|
| 244 | # Area of Significance 2 (incorporate coastline of rottnest) |
---|
| 245 | poly_aos2 = read_polygon(polygons_dir+'rottnest_external.csv') |
---|
| 246 | res_aos2 = 1000*res_factor |
---|
| 247 | |
---|
| 248 | # Refined areas |
---|
| 249 | # Polygon designed to incorporate dredged area from Fremantle to |
---|
| 250 | # Rockingham as the steep incline was making the elevation go to 0 |
---|
| 251 | poly_aos3 = read_polygon(polygons_dir+'DredgeArea.csv') |
---|
| 252 | res_aos3 = 1000*res_factor |
---|
| 253 | |
---|
| 254 | # Shallow water 1 |
---|
| 255 | poly_sw1 = read_polygon(polygons_dir+'internal_h20mORd3km.csv') |
---|
| 256 | res_sw1 = 25000*res_factor |
---|
| 257 | |
---|
| 258 | # Deep water (land of Rottnest, ANUGA does not do donuts!) |
---|
| 259 | poly_dw1 = read_polygon(polygons_dir+'rottnest_internal.csv') |
---|
| 260 | res_dw1 = 100000*res_factor |
---|
| 261 | |
---|
| 262 | # Combined all regions, must check that all are included! |
---|
| 263 | interior_regions = [[poly_aoi2,res_aoi2], [poly_aos1,res_aos1] |
---|
| 264 | ,[poly_aos2,res_aos2],[poly_aos3,res_aos3] |
---|
| 265 | ,[poly_sw1,res_sw1], [poly_dw1,res_dw1]] |
---|
| 266 | |
---|
| 267 | ##interior_regions = [[poly_aoi1,res_aoi1],[poly_aoi2,res_aoi2] |
---|
| 268 | ## ,[poly_aoi2a,res_aoi2a],[poly_aoi3,res_aoi3] |
---|
| 269 | ## ,[poly_aoi4,res_aoi4],[poly_aos1,res_aos1] |
---|
| 270 | ## ,[poly_aos2,res_aos2],[poly_aos3,res_aos3] |
---|
| 271 | ## ,[poly_sw1,res_sw1], [poly_dw1,res_dw1]] |
---|
| 272 | |
---|
| 273 | |
---|
| 274 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
| 275 | print 'min estimated number of triangles', trigs_min |
---|
| 276 | |
---|
| 277 | #------------------------------------------------------------------------------ |
---|
| 278 | # Clipping regions for export to asc and regions for clipping data |
---|
| 279 | # Final inundation maps should only be created in regions of the finest mesh |
---|
| 280 | #------------------------------------------------------------------------------ |
---|
| 281 | |
---|
| 282 | #Geordie Bay extract ascii grid |
---|
| 283 | xminGeordie = 358000 |
---|
| 284 | xmaxGeordie = 362000 |
---|
| 285 | yminGeordie = 6458500 |
---|
| 286 | ymaxGeordie = 6461000 |
---|
| 287 | |
---|
| 288 | #Sorrento extract ascii grid |
---|
| 289 | xminSorrento = 379000 |
---|
| 290 | xmaxSorrento = 382500 |
---|
| 291 | yminSorrento = 6477000 |
---|
| 292 | ymaxSorrento = 6480000 |
---|
| 293 | |
---|
| 294 | #Fremantle extract ascii grid |
---|
| 295 | xminFremantle = 376000 |
---|
| 296 | xmaxFremantle = 388000 |
---|
| 297 | yminFremantle = 6449000 |
---|
| 298 | ymaxFremantle = 6461000 |
---|
| 299 | |
---|
| 300 | #Rockingham extract ascii grid |
---|
| 301 | xminRockingham = 373500 |
---|
| 302 | xmaxRockingham = 385500 |
---|
| 303 | yminRockingham = 6424000 |
---|
| 304 | ymaxRockingham = 6433000 |
---|
| 305 | |
---|
| 306 | #Fremantle and Perth extract ascii grid |
---|
| 307 | xminPerth = 376000 |
---|
| 308 | xmaxPerth = 396000 |
---|
| 309 | yminPerth = 6449000 |
---|
| 310 | ymaxPerth = 6467000 |
---|
| 311 | |
---|