[6461] | 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 | import os |
---|
| 9 | from os.path import join |
---|
| 10 | from os import sep, getenv |
---|
| 11 | from time import localtime, strftime, gmtime |
---|
| 12 | from anuga.utilities.polygon import read_polygon, number_mesh_triangles |
---|
| 13 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
| 14 | |
---|
| 15 | #------------------------------------------------------------------------------ |
---|
| 16 | # Directory setup |
---|
| 17 | #------------------------------------------------------------------------------ |
---|
| 18 | # Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
| 19 | |
---|
| 20 | home = getenv('INUNDATIONHOME')+sep+'data'+sep # Absolute path for data folder |
---|
| 21 | muxhome = getenv('MUXHOME') |
---|
| 22 | user = get_user_name() |
---|
| 23 | host = get_host_name() |
---|
| 24 | |
---|
| 25 | # determines time for setting up output directories |
---|
| 26 | time = strftime('%Y%m%d_%H%M%S',localtime()) |
---|
| 27 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) |
---|
| 28 | build_time = time+'_build' |
---|
| 29 | run_time = time+'_run' |
---|
| 30 | |
---|
| 31 | # this section needs to be updated to reflect the modelled community. |
---|
| 32 | # Note, the user needs to set up the directory system accordingly |
---|
| 33 | state = 'australia_ph2' |
---|
| 34 | scenario_name = 'sydney' |
---|
| 35 | scenario_folder = 'sydney' |
---|
| 36 | |
---|
| 37 | #------------------------------------------------------------------------------ |
---|
| 38 | # Initial Conditions |
---|
| 39 | #------------------------------------------------------------------------------ |
---|
| 40 | # Model specific parameters. One or all can be changed each time the |
---|
| 41 | # run_scenario script is executed |
---|
| 42 | tide = 0 #0.6 |
---|
| 43 | event_number = 7875 # Java 9.3 original |
---|
| 44 | alpha = 0.1 # smoothing parameter for mesh |
---|
| 45 | friction=0.01 # manning's friction coefficient |
---|
| 46 | starttime=0 |
---|
| 47 | finaltime=1000 # final time for simulation |
---|
| 48 | |
---|
| 49 | setup='trial' # Final can be replaced with trial or basic. |
---|
| 50 | # Either will result in a coarser mesh that will allow a |
---|
| 51 | # faster, but less accurate, simulation. |
---|
| 52 | |
---|
| 53 | if setup =='trial': |
---|
| 54 | print'trial' |
---|
| 55 | scale_factor=100 |
---|
| 56 | time_thinning=96 |
---|
| 57 | yieldstep=240 |
---|
| 58 | if setup =='basic': |
---|
| 59 | print'basic' |
---|
| 60 | scale_factor=4 |
---|
| 61 | time_thinning=12 |
---|
| 62 | yieldstep=120 |
---|
| 63 | if setup =='final': |
---|
| 64 | print'final' |
---|
| 65 | scale_factor=1 |
---|
| 66 | time_thinning=4 |
---|
| 67 | yieldstep=60 |
---|
| 68 | |
---|
| 69 | |
---|
| 70 | #------------------------------------------------------------------------------ |
---|
| 71 | # Output Filename |
---|
| 72 | #------------------------------------------------------------------------------ |
---|
| 73 | # Important to distinguish each run - ensure str(user) is included! |
---|
| 74 | # Note, the user is free to include as many parameters as desired |
---|
| 75 | output_comment= ('_' + setup + '_' + str(tide)+ '_' + str(event_number) + |
---|
| 76 | '_' + str(user)) |
---|
| 77 | |
---|
| 78 | #------------------------------------------------------------------------------ |
---|
| 79 | # Input Data |
---|
| 80 | #------------------------------------------------------------------------------ |
---|
| 81 | # ELEVATION DATA |
---|
| 82 | # Used in build_busselton.py |
---|
| 83 | # Format for ascii grids, as produced in ArcGIS + a projection file |
---|
| 84 | #ascii_grid_filenames = ['busselton_v2', # Topo |
---|
| 85 | # 'grid_250m_clip'] # Busselton Topo |
---|
| 86 | |
---|
| 87 | # Format for point is x,y,elevation (with header) |
---|
| 88 | point_filenames = ['sydney_elevation.txt', |
---|
| 89 | 'melbourne_elevation.txt'] |
---|
| 90 | |
---|
| 91 | |
---|
| 92 | # LAND - used to set the initial stage/water to be offcoast only |
---|
| 93 | # Used in run_busselton,py |
---|
| 94 | # Format for points easting,northing (no header) |
---|
| 95 | land_initial_conditions_filename = [['initial_condition_extend.csv', 0]], |
---|
| 96 | ['initial_condition_comerong_island.csv', 0], |
---|
| 97 | ['initial_condition_gabo_island.csv', 0], |
---|
| 98 | ['initial_condition_montague_island.csv', 0]] |
---|
| 99 | |
---|
| 100 | # BOUNDING POLYGON - for data clipping and estimate of triangles in mesh |
---|
| 101 | # Used in build_busselton.py |
---|
| 102 | # Format for points easting,northing (no header) |
---|
| 103 | bounding_polygon_filename = 'bounding_polygon.csv' |
---|
| 104 | |
---|
| 105 | # INTERIOR REGIONS - for designing the mesh |
---|
| 106 | # Used in run_model.py |
---|
| 107 | # Format for points easting,northing (no header) |
---|
| 108 | ##interior_regions_data = [['coast_3km_buffer.csv', 50000]] |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | # BOUNDING POLYGON |
---|
| 112 | # used in build_boundary.py and run_busselton.py respectively |
---|
| 113 | # NOTE: when files are put together the points must be in sequence |
---|
| 114 | # For ease go clockwise! |
---|
| 115 | # Check the run_busselton.py for boundary_tags |
---|
| 116 | |
---|
| 117 | # Thinned ordering file from Hazard Map (geographic) |
---|
| 118 | # Format is index,latitude,longitude (with header) |
---|
| 119 | urs_order_filename = 'thinned_boundary_ordering_extend.csv' |
---|
| 120 | |
---|
| 121 | # Landward bounding points |
---|
| 122 | # Format easting,northing (no header) |
---|
| 123 | landward_boundary_filename = 'landward_boundary_extend.csv' |
---|
| 124 | |
---|
| 125 | |
---|
| 126 | |
---|
| 127 | |
---|
| 128 | |
---|
| 129 | #------------------------------------------------------------------------------ |
---|
| 130 | # Output Elevation Data |
---|
| 131 | #------------------------------------------------------------------------------ |
---|
| 132 | # Output filename for elevation |
---|
| 133 | # this is a combination of all the data generated in build_busselton.py |
---|
| 134 | combined_elevation_basename = scenario_name + '_combined_elevation' |
---|
| 135 | |
---|
| 136 | #------------------------------------------------------------------------------ |
---|
| 137 | # Directory Structure |
---|
| 138 | #------------------------------------------------------------------------------ |
---|
| 139 | anuga_folder = join(home, state, scenario_folder, 'anuga') |
---|
| 140 | topographies_folder = join(anuga_folder, 'topographies') |
---|
| 141 | polygons_folder = join(anuga_folder, 'polygons') |
---|
| 142 | boundaries_folder = join(anuga_folder, 'boundaries') |
---|
| 143 | output_folder = join(anuga_folder, 'outputs') |
---|
| 144 | gauges_folder = join(anuga_folder,'gauges') |
---|
| 145 | meshes_folder = join(anuga_folder, 'meshes') |
---|
| 146 | |
---|
| 147 | #------------------------------------------------------------------------------ |
---|
| 148 | # Location of input and output data |
---|
| 149 | #------------------------------------------------------------------------------ |
---|
| 150 | |
---|
| 151 | # The absolute pathname of the all elevation, generated in build_busselton.py |
---|
| 152 | combined_elevation = join(topographies_folder, combined_elevation_basename) |
---|
| 153 | |
---|
| 154 | # The absolute pathname of the mesh, generated in run_busselton.py |
---|
| 155 | meshes = meshes_folder + sep + scenario_name + '.msh' |
---|
| 156 | |
---|
| 157 | # The absolute pathname for the urs order points, used within build_boundary.py |
---|
| 158 | urs_order = join(boundaries_folder, urs_order_filename) |
---|
| 159 | |
---|
| 160 | # The absolute pathname for the landward points of the bounding polygon, |
---|
| 161 | # Used within run_busselton.py) |
---|
| 162 | landward_boundary = join(boundaries_folder, landward_boundary_filename) |
---|
| 163 | |
---|
| 164 | # The absolute pathname for the .sts file, generated in build_boundary.py |
---|
| 165 | event_sts = join(boundaries_folder, str(event_number)) |
---|
| 166 | |
---|
| 167 | # The absolute pathname for the output folder names |
---|
| 168 | # Used for build_busselton.py |
---|
| 169 | output_build = output_folder + sep + build_time + '_' + str(user) |
---|
| 170 | # Used for run_busselton.py |
---|
| 171 | output_run = output_folder + sep + run_time + output_comment |
---|
| 172 | # Used by post processing |
---|
| 173 | output_run_time = join(output_run, scenario_name) |
---|
| 174 | |
---|
| 175 | |
---|
| 176 | #------------------------------------------------------------------------------ |
---|
| 177 | # Reading polygons and creating interior regions |
---|
| 178 | #------------------------------------------------------------------------------ |
---|
| 179 | |
---|
| 180 | # Create list of land polygons with initial conditions |
---|
| 181 | land_initial_conditions = [] |
---|
| 182 | for filename, MSL in land_initial_conditions_filename: |
---|
| 183 | polygon = read_polygon(join(polygons_folder, filename)) |
---|
| 184 | land_initial_conditions.append([filename, MSL]) |
---|
| 185 | |
---|
| 186 | ### Create list of interior polygons with scaling factor |
---|
| 187 | interior_regions = [] |
---|
| 188 | ##for filename, maxarea in interior_regions_data: |
---|
| 189 | ## polygon = read_polygon(join(polygons_folder, filename)) |
---|
| 190 | ## interior_regions.append([polygon, maxarea*scale_factor]) |
---|
| 191 | |
---|
| 192 | # Initial bounding polygon for data clipping |
---|
| 193 | bounding_polygon = read_polygon(join(polygons_folder, |
---|
| 194 | bounding_polygon_filename)) |
---|
| 195 | bounding_maxarea = 125000*scale_factor |
---|
| 196 | |
---|
| 197 | # Estimate the number of triangles |
---|
| 198 | trigs_min = number_mesh_triangles(interior_regions, |
---|
| 199 | bounding_polygon, bounding_maxarea) |
---|
| 200 | print 'min estimated number of triangles', trigs_min |
---|
| 201 | |
---|
| 202 | |
---|