[6200] | 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 = 'australia_ph2' |
---|
| 40 | scenario_name = 'dampier_ph2' |
---|
| 41 | scenario = 'dampier' |
---|
[6217] | 42 | area = 'large_b10' #'small_b10' |
---|
[6200] | 43 | |
---|
| 44 | # Model specific parameters. One or all can be changed each time the |
---|
| 45 | # run_scenario script is executed |
---|
| 46 | tide = 0 #0.6 |
---|
| 47 | #event_number = 27283 |
---|
| 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 |
---|
| 52 | |
---|
| 53 | setup='final' # Final can be replaced with trial or basic. |
---|
| 54 | # Either will result in a coarser mesh that will allow a |
---|
| 55 | # faster, but less accurate, simulation. |
---|
| 56 | |
---|
| 57 | if setup =='trial': |
---|
| 58 | print'trial' |
---|
| 59 | res_factor=10 |
---|
| 60 | time_thinning=48 |
---|
| 61 | yieldstep=240 |
---|
| 62 | if setup =='basic': |
---|
| 63 | print'basic' |
---|
| 64 | res_factor=4 |
---|
| 65 | time_thinning=12 |
---|
| 66 | yieldstep=120 |
---|
| 67 | if setup =='final': |
---|
| 68 | print'final' |
---|
| 69 | res_factor=1 |
---|
| 70 | time_thinning=4 |
---|
| 71 | yieldstep=60 |
---|
| 72 | |
---|
| 73 | #------------------------------------------------------------------------------ |
---|
| 74 | # Output Filename |
---|
| 75 | #------------------------------------------------------------------------------ |
---|
| 76 | # Important to distinguish each run - ensure str(user) is included! |
---|
| 77 | # Note, the user is free to include as many parameters as desired |
---|
[6217] | 78 | dir_comment='_'+setup+'_'+str(tide)+'_250m_' + str(area)+'_'+str(user) |
---|
[6200] | 79 | |
---|
| 80 | #------------------------------------------------------------------------------ |
---|
| 81 | # Input Data |
---|
| 82 | #------------------------------------------------------------------------------ |
---|
| 83 | |
---|
| 84 | # elevation data used in build_perth.py |
---|
| 85 | # onshore data: format ascii grid with accompanying projection file |
---|
| 86 | onshore_name = 'grid_250m_2005' |
---|
| 87 | |
---|
| 88 | # gauges - used in get_timeseries.py |
---|
[6217] | 89 | gauge_name = 'gauges.csv' |
---|
[6200] | 90 | |
---|
| 91 | # BOUNDING POLYGON - used in build_boundary.py and run_perth.py respectively |
---|
| 92 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
| 93 | # Check the run_perth.py for boundary_tags |
---|
| 94 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
| 95 | #order_filename = 'thinned_boundary_ordering.txt' |
---|
| 96 | #landward bounding points |
---|
| 97 | #landward = 'landward_bounding_polygon.txt' |
---|
| 98 | |
---|
| 99 | #------------------------------------------------------------------------------ |
---|
| 100 | # Output Elevation Data |
---|
| 101 | #------------------------------------------------------------------------------ |
---|
| 102 | # Output filename for elevation |
---|
| 103 | # this is a combination of all the data (utilisied in build_boundary) |
---|
[6217] | 104 | combined_name = scenario_name + '_combined_elevation_250m_' + area |
---|
[6200] | 105 | |
---|
| 106 | #------------------------------------------------------------------------------ |
---|
| 107 | # Directory Structure |
---|
| 108 | #------------------------------------------------------------------------------ |
---|
| 109 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
| 110 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
| 111 | topographies_dir = anuga_dir+'topographies'+sep |
---|
| 112 | polygons_dir = anuga_dir+'polygons'+sep |
---|
| 113 | tide_dir = anuga_dir+'tide_data'+sep |
---|
| 114 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
| 115 | output_dir = anuga_dir+'outputs'+sep |
---|
| 116 | gauges_dir = anuga_dir+'gauges'+sep |
---|
| 117 | meshes_dir = anuga_dir+'meshes'+sep |
---|
| 118 | |
---|
| 119 | #------------------------------------------------------------------------------ |
---|
| 120 | # Location of input and output data |
---|
| 121 | #------------------------------------------------------------------------------ |
---|
| 122 | # where the input data sits |
---|
| 123 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
| 124 | |
---|
| 125 | # where the output data sits |
---|
| 126 | onshore_dir_name = topographies_dir + onshore_name |
---|
| 127 | |
---|
| 128 | # where the combined elevation file sits |
---|
| 129 | combined_dir_name = topographies_dir + combined_name |
---|
| 130 | |
---|
| 131 | # where the mesh sits (this is created during the run_perth.py) |
---|
[6217] | 132 | meshes_dir_name = meshes_dir + scenario_name+ '_' + area + '.msh' |
---|
[6200] | 133 | |
---|
| 134 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
| 135 | #order_filename_dir = boundaries_dir + order_filename |
---|
| 136 | |
---|
| 137 | # where the landward points of boundary extent sit (this is used within run_perth.py) |
---|
| 138 | #landward_dir = boundaries_dir + landward |
---|
| 139 | |
---|
| 140 | # where the event sts files sits (this is created during the build_boundary.py) |
---|
| 141 | ##boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
| 142 | ##boundaries_dir_mux = muxhome |
---|
| 143 | |
---|
| 144 | # where the directory of the output filename sits |
---|
| 145 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_perth.py |
---|
| 146 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_perth.py |
---|
| 147 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
| 148 | |
---|
[6217] | 149 | # where the directory of the gauges sit |
---|
| 150 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
[6200] | 151 | ##gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
| 152 | |
---|
| 153 | #------------------------------------------------------------------------------ |
---|
| 154 | # Interior region definitions |
---|
| 155 | #------------------------------------------------------------------------------ |
---|
| 156 | |
---|
| 157 | # Initial bounding polygon for data clipping |
---|
[6217] | 158 | poly_all = read_polygon(polygons_dir+'poly_all_' +area + '.csv') |
---|
[6200] | 159 | res_poly_all = 125000*res_factor |
---|
| 160 | |
---|
| 161 | interior_regions = [] |
---|
| 162 | |
---|
| 163 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
| 164 | print 'min estimated number of triangles', trigs_min |
---|
| 165 | |
---|
| 166 | |
---|