[5786] | 1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
| 2 | This script is the heart of all scripts in the folder |
---|
[5000] | 3 | """ |
---|
[5786] | 4 | #------------------------------------------------------------------------------ |
---|
| 5 | # Import necessary modules |
---|
| 6 | #------------------------------------------------------------------------------ |
---|
[5000] | 7 | |
---|
[5786] | 8 | from os import sep, environ, getenv, getcwd |
---|
[5000] | 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 |
---|
[5786] | 14 | from anuga.shallow_water.data_manager import urs2sts,create_sts_boundary |
---|
[5575] | 15 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon |
---|
[5000] | 16 | |
---|
[5786] | 17 | #------------------------------------------------------------------------------ |
---|
| 18 | # Directory setup |
---|
| 19 | #------------------------------------------------------------------------------ |
---|
| 20 | # Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
[5000] | 21 | |
---|
[5786] | 22 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name() |
---|
[5575] | 23 | muxhome = getenv('MUXHOME') |
---|
[5000] | 24 | user = get_user_name() |
---|
| 25 | host = get_host_name() |
---|
[5415] | 26 | |
---|
[5786] | 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()) |
---|
[5000] | 30 | build_time = time+'_build' |
---|
| 31 | run_time = time+'_run' |
---|
| 32 | |
---|
[5786] | 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 |
---|
[5000] | 39 | state = 'western_australia' |
---|
| 40 | scenario_name = 'busselton' |
---|
[5149] | 41 | scenario = 'busselton_tsunami_scenario' |
---|
[5000] | 42 | |
---|
[5786] | 43 | # Model specific parameters. One or all can be changed each time the |
---|
| 44 | # run_scenario script is executed |
---|
[6062] | 45 | tide = 0 #0.6 |
---|
| 46 | #event_number = 27255 # Java 9.3 worst case for Perth |
---|
[6018] | 47 | #event_number = 68693 # Sumatra 9.2 |
---|
[6062] | 48 | event_number = 27283 # Java 9.3 original |
---|
[5786] | 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 |
---|
[5415] | 53 | |
---|
[5786] | 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. |
---|
[5000] | 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 | |
---|
[5786] | 74 | #------------------------------------------------------------------------------ |
---|
| 75 | # Revision numbers - for comparisons study |
---|
| 76 | #------------------------------------------------------------------------------ |
---|
[5526] | 77 | rev_num = 'newExtent' |
---|
[5457] | 78 | #rev_num = '5449' |
---|
[5448] | 79 | #rev_num = '4695' # 2nd Sept 2007 |
---|
| 80 | #rev_num = '4743' # 3nd Oct 2007 |
---|
| 81 | #rev_num = '4777' # 1st Nov 2007 |
---|
| 82 | #rev_num = '4874' # 3rd Dec 2007 |
---|
| 83 | #rev_num = '4901' # 3rd Jan 2007 |
---|
| 84 | #rev_num = '4990' # 5th Feb 2007 |
---|
| 85 | #rev_num = '5103' # 3rd March 2007 |
---|
[5472] | 86 | #rev_num = '5120' # 5th March 2007 |
---|
| 87 | #rev_num = '5140' # 7th March 2007 |
---|
[5526] | 88 | #rev_num = '5160' # 11th March 2007 |
---|
[5448] | 89 | #rev_num = '5185' # 1st April 2007 |
---|
[5479] | 90 | #rev_num = '5273' # 2nd May 2007 |
---|
[5000] | 91 | |
---|
| 92 | |
---|
[5786] | 93 | #------------------------------------------------------------------------------ |
---|
| 94 | # Output Filename |
---|
| 95 | #------------------------------------------------------------------------------ |
---|
| 96 | # Important to distinguish each run - ensure str(user) is included! |
---|
| 97 | # Note, the user is free to include as many parameters as desired |
---|
| 98 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_'+ 'alpha' +str(alpha)+'_'+str(user) |
---|
[5000] | 99 | |
---|
[5786] | 100 | #------------------------------------------------------------------------------ |
---|
| 101 | # Input Data |
---|
| 102 | #------------------------------------------------------------------------------ |
---|
[5415] | 103 | |
---|
[5786] | 104 | # elevation data used in build_busselton.py |
---|
| 105 | # onshore data: format ascii grid with accompanying projection file |
---|
| 106 | onshore_name = 'busselton_v2_gda94_mga50' |
---|
| 107 | # coastline: format x,y,elevation (with title) |
---|
| 108 | coast_name = 'Busselton_Contour0.txt' |
---|
| 109 | coast_name1 = 'Busselton_BeachSurvey.txt' |
---|
| 110 | # bathymetry: format x,y,elevation (with title) |
---|
[5796] | 111 | offshore_name = 'Busselton_NavyFinal.txt' |
---|
| 112 | offshore_name1 = 'Busselton_Chart.txt' |
---|
| 113 | offshore_name2 = 'Busselton_Digitised.txt' |
---|
| 114 | offshore_name3 = 'Busselton_250m.txt' # for areas that were heading to zero - 2005 Bathymetry grid |
---|
[6062] | 115 | offshore_name4 = 'DPI.txt' # for area within Bunbury 500 mesh less than zero generated from TIN |
---|
| 116 | offshore_name5 = 'topo_20m_buss_1km' # for area within Busselton 500 mesh less than zero generated from TIN |
---|
[5000] | 117 | |
---|
[5786] | 118 | # gauges - used in get_timeseries.py |
---|
[6201] | 119 | #gauge_name = scenario_name+'.txt' |
---|
[6342] | 120 | #gauge_name = 'Gauges.csv' |
---|
| 121 | gauge_name = 'MH_gauges.csv' |
---|
[6018] | 122 | # buildings - used in run_building_inundation.py |
---|
| 123 | building = 'busselton_res_clip' |
---|
[5526] | 124 | |
---|
[6018] | 125 | |
---|
[5786] | 126 | # BOUNDING POLYGON - used in build_boundary.py and run_busselton.py respectively |
---|
| 127 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
| 128 | # Check the run_busselton.py for boundary_tags |
---|
| 129 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
[5796] | 130 | order_filename = 'thinned_boundary_ordering.csv' |
---|
[5786] | 131 | #landward bounding points |
---|
[5796] | 132 | landward = 'landward_bounding_polygon.csv' |
---|
[5786] | 133 | |
---|
| 134 | #------------------------------------------------------------------------------ |
---|
| 135 | # Output Elevation Data |
---|
| 136 | #------------------------------------------------------------------------------ |
---|
| 137 | # Output filename for elevation |
---|
| 138 | # this is a combination of all the data (utilisied in build_boundary) |
---|
[5149] | 139 | combined_name ='busselton_combined_elevation' |
---|
[5786] | 140 | combined_smaller_name = 'busselton_combined_elevation_smaller' |
---|
[5000] | 141 | |
---|
[5786] | 142 | #------------------------------------------------------------------------------ |
---|
| 143 | # Directory Structure |
---|
| 144 | #------------------------------------------------------------------------------ |
---|
[5000] | 145 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
[5149] | 146 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
[5415] | 147 | topographies_dir = anuga_dir+'topographies'+sep |
---|
[5786] | 148 | polygons_dir = anuga_dir+'polygons'+sep |
---|
| 149 | tide_dir = anuga_dir+'tide_data'+sep |
---|
| 150 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
| 151 | output_dir = anuga_dir+'outputs'+sep |
---|
| 152 | gauges_dir = anuga_dir+'gauges'+sep |
---|
| 153 | meshes_dir = anuga_dir+'meshes'+sep |
---|
[5000] | 154 | |
---|
[5786] | 155 | #------------------------------------------------------------------------------ |
---|
| 156 | # Location of input and output data |
---|
| 157 | #------------------------------------------------------------------------------ |
---|
| 158 | # where the input data sits |
---|
[5381] | 159 | onshore_in_dir_name = topographies_in_dir + onshore_name #topo |
---|
| 160 | coast_in_dir_name = topographies_in_dir + coast_name #coastline |
---|
| 161 | coast_in_dir_name1 = topographies_in_dir + coast_name1 #beach survey |
---|
| 162 | offshore_in_dir_name = topographies_in_dir + offshore_name #bathymetry |
---|
[5415] | 163 | offshore_in_dir_name1 = topographies_in_dir + offshore_name1 #bathymetry Charts |
---|
| 164 | offshore_in_dir_name2 = topographies_in_dir + offshore_name2 #Digitised Fairsheet |
---|
[5526] | 165 | offshore_in_dir_name3 = topographies_in_dir + offshore_name3 #250m |
---|
[6062] | 166 | offshore_in_dir_name4 = topographies_in_dir + offshore_name4 #Bunbury DPI |
---|
| 167 | offshore_in_dir_name5 = topographies_in_dir + offshore_name5 #Busselton Topo |
---|
[5000] | 168 | |
---|
[5786] | 169 | # where the output data sits |
---|
[5000] | 170 | onshore_dir_name = topographies_dir + onshore_name |
---|
[5381] | 171 | |
---|
[5000] | 172 | coast_dir_name = topographies_dir + coast_name |
---|
[5149] | 173 | coast_dir_name1 = topographies_dir + coast_name1 |
---|
[5415] | 174 | |
---|
[5000] | 175 | offshore_dir_name = topographies_dir + offshore_name |
---|
[5415] | 176 | offshore_dir_name1 = topographies_dir + offshore_name1 |
---|
| 177 | offshore_dir_name2 = topographies_dir + offshore_name2 |
---|
[5526] | 178 | offshore_dir_name3 = topographies_dir + offshore_name3 |
---|
[5647] | 179 | offshore_dir_name4 = topographies_dir + offshore_name4 |
---|
| 180 | offshore_dir_name5 = topographies_dir + offshore_name5 |
---|
[5000] | 181 | |
---|
[5786] | 182 | # where the combined elevation file sits |
---|
[5000] | 183 | combined_dir_name = topographies_dir + combined_name |
---|
[5786] | 184 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
[5000] | 185 | |
---|
[5786] | 186 | # where the mesh sits (this is created during the run_busselton.py) |
---|
| 187 | meshes_dir_name = meshes_dir + scenario_name+'.msh' |
---|
[5000] | 188 | |
---|
[5786] | 189 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
| 190 | order_filename_dir = boundaries_dir + order_filename |
---|
[5000] | 191 | |
---|
[5786] | 192 | # where the landward points of boundary extent sit (this is used within run_busselton.py) |
---|
| 193 | landward_dir = boundaries_dir + landward |
---|
[5415] | 194 | |
---|
[5786] | 195 | # where the event sts files sits (this is created during the build_boundary.py) |
---|
| 196 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
[5575] | 197 | boundaries_dir_mux = muxhome |
---|
[5000] | 198 | |
---|
[5786] | 199 | # where the directory of the output filename sits |
---|
| 200 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_busselton.py |
---|
| 201 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_busselton.py |
---|
[5000] | 202 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
| 203 | |
---|
[5786] | 204 | #w here the directory of the gauges sit |
---|
| 205 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
[6018] | 206 | building_in_dir_name = gauges_dir + building + '.csv' #used for run_building_inundation.py |
---|
[5626] | 207 | |
---|
[5786] | 208 | #------------------------------------------------------------------------------ |
---|
| 209 | # Interior region definitions |
---|
| 210 | #------------------------------------------------------------------------------ |
---|
[5000] | 211 | |
---|
[5786] | 212 | #Land, to set the initial stage/water to be offcoast only |
---|
| 213 | poly_mainland = read_polygon(polygons_dir+'initial_condition.csv') |
---|
[5000] | 214 | |
---|
[6062] | 215 | #Land, to set the initial stage/water to be offcoast only |
---|
| 216 | poly_marina = read_polygon(polygons_dir+'initial_condition_marina.csv') |
---|
| 217 | |
---|
[5786] | 218 | # Initial bounding polygon for data clipping |
---|
[5526] | 219 | poly_all = read_polygon(polygons_dir+'poly_all_extend.csv') |
---|
[5000] | 220 | res_poly_all = 100000*res_factor |
---|
| 221 | |
---|
[5786] | 222 | # Area of Interest 1 (Busselton) |
---|
| 223 | poly_aoi1 = read_polygon(polygons_dir+'busselton_1km.csv') |
---|
| 224 | res_aoi1 = 500*res_factor |
---|
[5149] | 225 | |
---|
[5786] | 226 | # Area of Interest 2 (Bunbury) |
---|
| 227 | poly_aoi2 = read_polygon(polygons_dir+'bunbury_1km.csv') |
---|
| 228 | res_aoi2 = 500*res_factor |
---|
[5000] | 229 | |
---|
[5786] | 230 | # Area of Significance 1 (Busselton) |
---|
| 231 | poly_aos1 = read_polygon(polygons_dir+'busselton_2km.csv') |
---|
| 232 | res_aos1 = 10000*res_factor |
---|
[5000] | 233 | |
---|
[5786] | 234 | # Area of Significance 2 (Bunbury) |
---|
| 235 | poly_aos2 = read_polygon(polygons_dir+'busselton_2km.csv') |
---|
| 236 | res_aos2 = 10000*res_factor |
---|
[5000] | 237 | |
---|
[5786] | 238 | # Refined areas |
---|
| 239 | # Polygon designed to islands |
---|
| 240 | poly_aos3 = read_polygon(polygons_dir+'island1.csv') |
---|
| 241 | res_aos3 = 10000*res_factor |
---|
| 242 | poly_aos4 = read_polygon(polygons_dir+'island2.csv') |
---|
| 243 | res_aos4 = 10000*res_factor |
---|
[5415] | 244 | |
---|
[5786] | 245 | # Shallow water 1 |
---|
| 246 | poly_sw1 = read_polygon(polygons_dir+'coast_5km_d20m.csv') |
---|
| 247 | res_sw1 = 40000*res_factor |
---|
[5430] | 248 | |
---|
[5786] | 249 | # Combined all regions, must check that all are included! |
---|
| 250 | interior_regions = [[poly_aoi1,res_aoi1],[poly_aoi2,res_aoi2] |
---|
| 251 | ,[poly_aos1,res_aos1],[poly_aos2,res_aos2] |
---|
| 252 | ,[poly_aos3,res_aos3],[poly_aos4,res_aos4] |
---|
| 253 | ,[poly_sw1,res_sw1]] |
---|
[5647] | 254 | |
---|
[5786] | 255 | |
---|
[5000] | 256 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
[5786] | 257 | print 'min estimated number of triangles', trigs_min |
---|
| 258 | |
---|
| 259 | #------------------------------------------------------------------------------ |
---|
| 260 | # Clipping regions for export to asc and regions for clipping data |
---|
| 261 | # Final inundation maps should only be created in regions of the finest mesh |
---|
| 262 | #------------------------------------------------------------------------------ |
---|
[5000] | 263 | |
---|
[5792] | 264 | # exporting asc grid for Busselton |
---|
| 265 | xminBusselton = 340000 |
---|
| 266 | xmaxBusselton = 352000 |
---|
| 267 | yminBusselton = 6271500 |
---|
| 268 | ymaxBusselton = 6280000 |
---|
[5000] | 269 | |
---|
[5792] | 270 | # exporting asc grid for Bunbury |
---|
| 271 | xminBunbury = 369000 |
---|
| 272 | xmaxBunbury = 381000 |
---|
| 273 | yminBunbury = 6308000 |
---|
| 274 | ymaxBunbury = 6316500 |
---|
[5000] | 275 | |
---|