[6291] | 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 |
---|
[6293] | 33 | state = 'australia_ph2' |
---|
| 34 | scenario_name = 'ceduna' |
---|
[6291] | 35 | |
---|
| 36 | #------------------------------------------------------------------------------ |
---|
| 37 | # Initial Conditions |
---|
| 38 | #------------------------------------------------------------------------------ |
---|
| 39 | # Model specific parameters. One or all can be changed each time the |
---|
| 40 | # run_scenario script is executed |
---|
[6293] | 41 | tide = 0 |
---|
[6398] | 42 | #event_number = 27255 # Java 9.3 worst case for Perth |
---|
| 43 | event_number = 64468 # event for SA coast |
---|
[6291] | 44 | alpha = 0.1 # smoothing parameter for mesh |
---|
[6293] | 45 | friction = 0.01 # manning's friction coefficient |
---|
| 46 | starttime = 0 |
---|
[6342] | 47 | finaltime = 1000 #80000 # final time for simulation |
---|
[6291] | 48 | |
---|
[6359] | 49 | setup = 'trial' # Final can be replaced with trial or basic. |
---|
[6291] | 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_elevation.py |
---|
| 83 | # Format for ascii grids, as produced in ArcGIS + a projection file |
---|
[6359] | 84 | #ascii_grid_filenames = ['grid250m'] # 250m grid 2005 |
---|
[6291] | 85 | |
---|
| 86 | # Format for point is x,y,elevation (with header) |
---|
[6359] | 87 | point_filenames = ['grid250m.txt'] |
---|
| 88 | |
---|
[6291] | 89 | # BOUNDING POLYGON - for data clipping and estimate of triangles in mesh |
---|
| 90 | # Used in build_elevation.py |
---|
| 91 | # Format for points easting,northing (no header) |
---|
| 92 | bounding_polygon_filename = 'bounding_polygon.csv' |
---|
| 93 | |
---|
| 94 | # GAUGES - for creating timeseries at a specific point |
---|
| 95 | # Used in get_timeseries.py |
---|
| 96 | # Format easting,northing,name,elevation (with header) |
---|
[6293] | 97 | ##gauges_filename = 'gauges.csv' |
---|
[6291] | 98 | |
---|
| 99 | # BOUNDING POLYGON |
---|
| 100 | # used in build_boundary.py and run_model.py respectively |
---|
| 101 | # NOTE: when files are put together the points must be in sequence |
---|
| 102 | # For ease go clockwise! |
---|
| 103 | # Check the run_model.py for boundary_tags |
---|
| 104 | |
---|
| 105 | # Thinned ordering file from Hazard Map (geographic) |
---|
| 106 | # Format is index,latitude,longitude (with header) |
---|
[6398] | 107 | urs_order_filename = 'urs_order_austtg.csv' |
---|
[6291] | 108 | |
---|
| 109 | # Landward bounding points |
---|
| 110 | # Format easting,northing (no header) |
---|
[6293] | 111 | landward_boundary_filename = 'landward_boundary.csv' |
---|
[6291] | 112 | |
---|
| 113 | #------------------------------------------------------------------------------ |
---|
| 114 | # Output Elevation Data |
---|
| 115 | #------------------------------------------------------------------------------ |
---|
| 116 | # Output filename for elevation |
---|
| 117 | # this is a combination of all the data generated in build_elevation.py |
---|
| 118 | combined_elevation_basename = scenario_name + '_combined_elevation' |
---|
| 119 | |
---|
| 120 | #------------------------------------------------------------------------------ |
---|
| 121 | # Directory Structure |
---|
| 122 | #------------------------------------------------------------------------------ |
---|
[6293] | 123 | anuga_folder = join(home, state, scenario_name, 'anuga') |
---|
[6291] | 124 | topographies_folder = join(anuga_folder, 'topographies') |
---|
| 125 | polygons_folder = join(anuga_folder, 'polygons') |
---|
| 126 | boundaries_folder = join(anuga_folder, 'boundaries') |
---|
| 127 | output_folder = join(anuga_folder, 'outputs') |
---|
| 128 | gauges_folder = join(anuga_folder,'gauges') |
---|
| 129 | meshes_folder = join(anuga_folder, 'meshes') |
---|
| 130 | |
---|
| 131 | #------------------------------------------------------------------------------ |
---|
| 132 | # Location of input and output data |
---|
| 133 | #------------------------------------------------------------------------------ |
---|
| 134 | |
---|
| 135 | # The absolute pathname of the all elevation, generated in build_elevation.py |
---|
| 136 | combined_elevation = join(topographies_folder, combined_elevation_basename) |
---|
| 137 | |
---|
| 138 | # The absolute pathname of the mesh, generated in run_model.py |
---|
| 139 | meshes = join(meshes_folder, scenario_name) + '.msh' |
---|
| 140 | |
---|
| 141 | # The absolute pathname for the urs order points, used within build_boundary.py |
---|
| 142 | urs_order = join(boundaries_folder, urs_order_filename) |
---|
| 143 | |
---|
| 144 | # The absolute pathname for the landward points of the bounding polygon, |
---|
| 145 | # Used within run_model.py) |
---|
| 146 | landward_boundary = join(boundaries_folder, landward_boundary_filename) |
---|
| 147 | |
---|
| 148 | # The absolute pathname for the .sts file, generated in build_boundary.py |
---|
| 149 | event_sts = join(boundaries_folder, str(event_number), scenario_name) |
---|
| 150 | |
---|
[6342] | 151 | # The absolute pathname of the event folder |
---|
| 152 | event_folder = join(boundaries_folder, str(event_number)) |
---|
| 153 | |
---|
[6291] | 154 | # The absolute pathname for the output folder names |
---|
| 155 | # Used for build_elevation.py |
---|
| 156 | output_build = join(output_folder, build_time) + '_' + str(user) |
---|
| 157 | # Used for run_model.py |
---|
| 158 | output_run = join(output_folder, run_time) + output_comment |
---|
| 159 | # Used by post processing |
---|
| 160 | output_run_time = join(output_run, scenario_name) |
---|
| 161 | |
---|
| 162 | # The absolute pathname for the gauges file |
---|
| 163 | # Used for get_timeseries.py |
---|
[6293] | 164 | ##gauges = join(gauges_folder, gauges_filename) |
---|
[6291] | 165 | |
---|
| 166 | #------------------------------------------------------------------------------ |
---|
| 167 | # Reading polygons and creating interior regions |
---|
| 168 | #------------------------------------------------------------------------------ |
---|
| 169 | |
---|
| 170 | # Initial bounding polygon for data clipping |
---|
| 171 | bounding_polygon = read_polygon(join(polygons_folder, |
---|
| 172 | bounding_polygon_filename)) |
---|
| 173 | bounding_maxarea = 100000*scale_factor |
---|
| 174 | |
---|
[6293] | 175 | interior_regions = [] |
---|
| 176 | |
---|
[6291] | 177 | # Estimate the number of triangles |
---|
| 178 | trigs_min = number_mesh_triangles(interior_regions, |
---|
| 179 | bounding_polygon, bounding_maxarea) |
---|
| 180 | print 'min estimated number of triangles', trigs_min |
---|
| 181 | |
---|
| 182 | |
---|