[5782] | 1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
[5785] | 2 | This script is the heart of all scripts in the folder |
---|
[5782] | 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 | #------------------------------------------------------------------------------ |
---|
[5785] | 20 | # Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
[5782] | 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 | |
---|
[5785] | 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()) |
---|
[5782] | 30 | build_time = time+'_build' |
---|
| 31 | run_time = time+'_run' |
---|
| 32 | |
---|
| 33 | #------------------------------------------------------------------------------ |
---|
| 34 | # Initial Conditions |
---|
| 35 | #------------------------------------------------------------------------------ |
---|
| 36 | |
---|
[5785] | 37 | # this section needs to be updated to reflect the modelled community. |
---|
| 38 | # Note, the user needs to set up the directory system accordingly |
---|
[5782] | 39 | state = 'western_australia' |
---|
| 40 | scenario_name = 'perth' |
---|
| 41 | scenario = 'perth_tsunami_scenario' |
---|
[5785] | 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 |
---|
[5782] | 47 | event_number = 27283 |
---|
[5785] | 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 |
---|
[5782] | 52 | |
---|
| 53 | interior_mesh = 'all' # Can have 'all' or 'none' for Phase 2 study |
---|
| 54 | |
---|
[5785] | 55 | setup='final' # Final can be replaced with trial or basic. |
---|
| 56 | # Either will result in a coarser mesh that will allow a |
---|
| 57 | # faster, but less accurate, simulation. |
---|
[5782] | 58 | |
---|
| 59 | if setup =='trial': |
---|
| 60 | print'trial' |
---|
| 61 | res_factor=10 |
---|
| 62 | time_thinning=48 |
---|
| 63 | yieldstep=240 |
---|
| 64 | if setup =='basic': |
---|
| 65 | print'basic' |
---|
| 66 | res_factor=4 |
---|
| 67 | time_thinning=12 |
---|
| 68 | yieldstep=120 |
---|
| 69 | if setup =='final': |
---|
| 70 | print'final' |
---|
| 71 | res_factor=1 |
---|
| 72 | time_thinning=4 |
---|
| 73 | yieldstep=60 |
---|
| 74 | |
---|
| 75 | #------------------------------------------------------------------------------ |
---|
| 76 | # Output Filename |
---|
| 77 | #------------------------------------------------------------------------------ |
---|
[5785] | 78 | # Important to distinguish each run - ensure str(user) is included! |
---|
| 79 | # Note, the user is free to include as many parameters as desired |
---|
[5782] | 80 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_250m_' + str(interior_mesh) +'_'+str(user) |
---|
| 81 | |
---|
| 82 | #------------------------------------------------------------------------------ |
---|
[5785] | 83 | # Input Data |
---|
[5782] | 84 | #------------------------------------------------------------------------------ |
---|
| 85 | |
---|
[5785] | 86 | # elevation data used in build_perth.py |
---|
| 87 | # onshore data: format ascii grid with accompanying projection file |
---|
[5787] | 88 | onshore_name = 'grid_250m_2005' |
---|
[5782] | 89 | |
---|
[5785] | 90 | # gauges - used in get_timeseries.py |
---|
[5782] | 91 | gauge_name = 'perth.csv' |
---|
| 92 | gauge_name2 = 'thinned_MGA50.csv' |
---|
| 93 | |
---|
[5785] | 94 | # BOUNDING POLYGON - used in build_boundary.py and run_perth.py respectively |
---|
| 95 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
| 96 | # Check the run_perth.py for boundary_tags |
---|
| 97 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
[5782] | 98 | order_filename = 'thinned_boundary_ordering.txt' |
---|
[5785] | 99 | #landward bounding points |
---|
[5782] | 100 | landward = 'landward_bounding_polygon.txt' |
---|
| 101 | |
---|
| 102 | #------------------------------------------------------------------------------ |
---|
[5785] | 103 | # Output Elevation Data |
---|
[5782] | 104 | #------------------------------------------------------------------------------ |
---|
[5785] | 105 | # Output filename for elevation |
---|
| 106 | # this is a combination of all the data (utilisied in build_boundary) |
---|
[5782] | 107 | combined_name ='perth_combined_elevation_250m' |
---|
| 108 | |
---|
| 109 | #------------------------------------------------------------------------------ |
---|
| 110 | # Directory Structure |
---|
| 111 | #------------------------------------------------------------------------------ |
---|
| 112 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
| 113 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
| 114 | topographies_dir = anuga_dir+'topographies'+sep |
---|
| 115 | polygons_dir = anuga_dir+'polygons'+sep |
---|
| 116 | tide_dir = anuga_dir+'tide_data'+sep |
---|
| 117 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
| 118 | output_dir = anuga_dir+'outputs'+sep |
---|
| 119 | gauges_dir = anuga_dir+'gauges'+sep |
---|
| 120 | meshes_dir = anuga_dir+'meshes'+sep |
---|
| 121 | |
---|
| 122 | #------------------------------------------------------------------------------ |
---|
[5785] | 123 | # Location of input and output data |
---|
[5782] | 124 | #------------------------------------------------------------------------------ |
---|
[5785] | 125 | # where the input data sits |
---|
| 126 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
[5782] | 127 | |
---|
[5785] | 128 | # where the output data sits |
---|
| 129 | onshore_dir_name = topographies_dir + onshore_name |
---|
[5782] | 130 | |
---|
[5785] | 131 | # where the combined elevation file sits |
---|
[5782] | 132 | combined_dir_name = topographies_dir + combined_name |
---|
| 133 | |
---|
[5785] | 134 | # where the mesh sits (this is created during the run_perth.py) |
---|
| 135 | meshes_dir_name = meshes_dir + scenario_name+ interior_mesh +'.msh' |
---|
[5782] | 136 | |
---|
[5785] | 137 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
[5782] | 138 | order_filename_dir = boundaries_dir + order_filename |
---|
| 139 | |
---|
[5785] | 140 | # where the landward points of boundary extent sit (this is used within run_perth.py) |
---|
[5782] | 141 | landward_dir = boundaries_dir + landward |
---|
| 142 | |
---|
[5785] | 143 | # where the event sts files sits (this is created during the build_boundary.py) |
---|
[5782] | 144 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
| 145 | boundaries_dir_mux = muxhome |
---|
| 146 | |
---|
[5785] | 147 | # where the directory of the output filename sits |
---|
| 148 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_perth.py |
---|
| 149 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_perth.py |
---|
[5782] | 150 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
| 151 | |
---|
[5785] | 152 | #w here the directory of the gauges sit |
---|
| 153 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
| 154 | gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
[5782] | 155 | |
---|
| 156 | #------------------------------------------------------------------------------ |
---|
| 157 | # Interior region definitions |
---|
| 158 | #------------------------------------------------------------------------------ |
---|
| 159 | |
---|
[5785] | 160 | #Land, to set the initial stage/water to be offcoast only |
---|
[5782] | 161 | poly_mainland = read_polygon(polygons_dir+'initial_condition.csv') |
---|
| 162 | |
---|
[5785] | 163 | # Initial bounding polygon for data clipping |
---|
[5782] | 164 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
| 165 | res_poly_all = 100000*res_factor |
---|
| 166 | |
---|
[5785] | 167 | # Area of Interest 1 (Fremantle) |
---|
[5782] | 168 | poly_aoi1 = read_polygon(polygons_dir+'CBD_coastal.csv') |
---|
| 169 | res_aoi1 = 500*res_factor |
---|
| 170 | |
---|
[5785] | 171 | # Area of Interest 2 (Rockingham) |
---|
[5782] | 172 | poly_aoi2 = read_polygon(polygons_dir+'rockingham_penguin.csv') |
---|
| 173 | res_aoi2 = 500*res_factor |
---|
| 174 | |
---|
[5785] | 175 | # Area of Interest 2 (garden Island) |
---|
[5782] | 176 | poly_aoi2a = read_polygon(polygons_dir+'garden.csv') |
---|
| 177 | res_aoi2a= 500*res_factor |
---|
| 178 | |
---|
[5785] | 179 | # Area of Interest 3 (geordie bay - record of tsunami impact) |
---|
[5782] | 180 | poly_aoi3 = read_polygon(polygons_dir+'geordie_bay.csv') |
---|
| 181 | res_aoi3 = 500*res_factor |
---|
| 182 | |
---|
[5785] | 183 | # Area of Interest 4 (sorrento - record of tsunami impact) |
---|
[5782] | 184 | poly_aoi4 = read_polygon(polygons_dir+'sorrento_gauge.csv') |
---|
| 185 | res_aoi4 = 500*res_factor |
---|
| 186 | |
---|
[5785] | 187 | # Area of Significance 1 (Garden Island and sand bank infront of Rockingham) |
---|
[5782] | 188 | poly_aos1 = read_polygon(polygons_dir+'garden_rockingham.csv') |
---|
| 189 | res_aos1 = 1000*res_factor |
---|
| 190 | |
---|
[5785] | 191 | # Area of Significance 2 (incorporate coastline of rottnest) |
---|
[5782] | 192 | poly_aos2 = read_polygon(polygons_dir+'rottnest_external.csv') |
---|
| 193 | res_aos2 = 1000*res_factor |
---|
| 194 | |
---|
[5785] | 195 | # Refined areas |
---|
| 196 | # Polygon designed to incorporate dredged area from Fremantle to |
---|
| 197 | # Rockingham as the steep incline was making the elevation go to 0 |
---|
[5782] | 198 | poly_aos3 = read_polygon(polygons_dir+'DredgeArea.csv') |
---|
| 199 | res_aos3 = 1000*res_factor |
---|
| 200 | |
---|
[5785] | 201 | # Shallow water 1 |
---|
[5782] | 202 | poly_sw1 = read_polygon(polygons_dir+'internal_h20mORd3km.csv') |
---|
| 203 | res_sw1 = 25000*res_factor |
---|
| 204 | |
---|
[5785] | 205 | # Deep water (land of Rottnest, ANUGA does not do donuts!) |
---|
[5782] | 206 | poly_dw1 = read_polygon(polygons_dir+'rottnest_internal.csv') |
---|
| 207 | res_dw1 = 100000*res_factor |
---|
| 208 | |
---|
| 209 | # Combined all regions, must check that all are included! |
---|
| 210 | |
---|
| 211 | if interior_mesh =='all': |
---|
| 212 | print'Mesh = all' |
---|
| 213 | interior_regions = [[poly_aoi1,res_aoi1],[poly_aoi2,res_aoi2] |
---|
| 214 | ,[poly_aoi2a,res_aoi2a],[poly_aoi3,res_aoi3] |
---|
| 215 | ,[poly_aoi4,res_aoi4],[poly_aos1,res_aos1] |
---|
| 216 | ,[poly_aos2,res_aos2],[poly_aos3,res_aos3] |
---|
| 217 | ,[poly_sw1,res_sw1], [poly_dw1,res_dw1]] |
---|
| 218 | if interior_mesh =='none': |
---|
| 219 | print'Mesh = none' |
---|
| 220 | interior_regions = [] |
---|
[5785] | 221 | |
---|
[5782] | 222 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
| 223 | print 'min estimated number of triangles', trigs_min |
---|
| 224 | |
---|
| 225 | #------------------------------------------------------------------------------ |
---|
| 226 | # Clipping regions for export to asc and regions for clipping data |
---|
[5785] | 227 | # Final inundation maps should only be created in regions of the finest mesh |
---|
[5782] | 228 | #------------------------------------------------------------------------------ |
---|
| 229 | |
---|
| 230 | #Geordie Bay extract ascii grid |
---|
| 231 | xminGeordie = 358000 |
---|
| 232 | xmaxGeordie = 362000 |
---|
| 233 | yminGeordie = 6458500 |
---|
| 234 | ymaxGeordie = 6461000 |
---|
| 235 | |
---|
| 236 | #Sorrento extract ascii grid |
---|
| 237 | xminSorrento = 379000 |
---|
| 238 | xmaxSorrento = 382500 |
---|
| 239 | yminSorrento = 6477000 |
---|
| 240 | ymaxSorrento = 6480000 |
---|
| 241 | |
---|
| 242 | #Fremantle extract ascii grid |
---|
| 243 | xminFremantle = 376000 |
---|
| 244 | xmaxFremantle = 388000 |
---|
| 245 | yminFremantle = 6449000 |
---|
| 246 | ymaxFremantle = 6461000 |
---|
| 247 | |
---|
| 248 | #Rockingham extract ascii grid |
---|
| 249 | xminRockingham = 373500 |
---|
| 250 | xmaxRockingham = 385500 |
---|
| 251 | yminRockingham = 6424000 |
---|
| 252 | ymaxRockingham = 6433000 |
---|
| 253 | |
---|