[5790] | 1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
| 2 | This script is the heart of all scripts in the folder |
---|
[5005] | 3 | """ |
---|
[5790] | 4 | #------------------------------------------------------------------------------ |
---|
| 5 | # Import necessary modules |
---|
| 6 | #------------------------------------------------------------------------------ |
---|
[5005] | 7 | |
---|
[5755] | 8 | from os import sep, environ, getenv, getcwd |
---|
[5005] | 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 |
---|
[5755] | 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 |
---|
[5005] | 16 | |
---|
[5790] | 17 | #------------------------------------------------------------------------------ |
---|
| 18 | # Directory setup |
---|
| 19 | #------------------------------------------------------------------------------ |
---|
| 20 | # Note: INUNDATIONHOME is the inundation directory, not the data directory. |
---|
[5005] | 21 | |
---|
[5755] | 22 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name() |
---|
| 23 | muxhome = getenv('MUXHOME') |
---|
[5005] | 24 | user = get_user_name() |
---|
| 25 | host = get_host_name() |
---|
[5755] | 26 | |
---|
[5790] | 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()) |
---|
[5005] | 30 | build_time = time+'_build' |
---|
| 31 | run_time = time+'_run' |
---|
| 32 | |
---|
[5790] | 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 |
---|
[5005] | 39 | state = 'western_australia' |
---|
[5381] | 40 | scenario_name = 'carnarvon' |
---|
| 41 | scenario = 'carnarvon_tsunami_scenario' |
---|
[5005] | 42 | |
---|
[5790] | 43 | # Model specific parameters. One or all can be changed each time the |
---|
| 44 | # run_scenario script is executed |
---|
[6064] | 45 | tide = 1 #1.0 |
---|
[5828] | 46 | #event_number = 27255 # Java 9.3 worst case for Perth |
---|
[6021] | 47 | #event_number = 68693 # Sumatra 9.2 |
---|
| 48 | event_number = 27283 # Java 9.3 original |
---|
[5790] | 49 | alpha = 0.1 # smoothing parameter for mesh |
---|
| 50 | friction=0.01 # manning's friction coefficient |
---|
| 51 | starttime=0 |
---|
[6021] | 52 | finaltime=80000 # final time for simulation |
---|
[5755] | 53 | |
---|
[5790] | 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. |
---|
[5755] | 57 | |
---|
[5005] | 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 | |
---|
[5790] | 74 | #------------------------------------------------------------------------------ |
---|
| 75 | # Output Filename |
---|
| 76 | #------------------------------------------------------------------------------ |
---|
| 77 | # Important to distinguish each run - ensure str(user) is included! |
---|
| 78 | # Note, the user is free to include as many parameters as desired |
---|
| 79 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_'+ 'alpha' +str(alpha)+'_'+str(user) |
---|
[5005] | 80 | |
---|
[5790] | 81 | #------------------------------------------------------------------------------ |
---|
| 82 | # Input Data |
---|
| 83 | #------------------------------------------------------------------------------ |
---|
[5005] | 84 | |
---|
[5790] | 85 | # elevation data used in build_carnarvon.py |
---|
| 86 | # onshore data: format ascii grid with accompanying projection file |
---|
| 87 | onshore_name = 'dem_onshore' |
---|
| 88 | # bathymetry: format x,y,elevation (with title) |
---|
[6021] | 89 | offshore_name = 'carnarvon_data.txt' |
---|
| 90 | offshore_name1 = 'makeup.txt' |
---|
| 91 | #grids made for aoi and aos as anuga interpretation was bad |
---|
| 92 | topo_aoi = 'topo_20m_aoi' |
---|
| 93 | topo_aos = 'topo_50m_aos' |
---|
[5005] | 94 | |
---|
[5790] | 95 | # gauges - used in get_timeseries.py |
---|
[6491] | 96 | gauge_name = 'MH_gauges_deep.csv' #'carnarvon.csv' |
---|
[5790] | 97 | gauge_name2 = 'thinned_MGA50.csv' |
---|
[6064] | 98 | #buildings - used in run_building_inundation.py |
---|
| 99 | building = 'carnarvon_res' |
---|
[5755] | 100 | |
---|
[5790] | 101 | # BOUNDING POLYGON - used in build_boundary.py and run_carnarvon.py respectively |
---|
| 102 | # NOTE: when files are put together the points must be in sequence - for ease go clockwise! |
---|
| 103 | # Check the run_carnarvon.py for boundary_tags |
---|
| 104 | # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) |
---|
[5796] | 105 | order_filename = 'thinned_boundary_ordering.csv' |
---|
[5790] | 106 | #landward bounding points |
---|
[5796] | 107 | landward = 'landward_bounding_polygon.csv' |
---|
[5005] | 108 | |
---|
[5790] | 109 | #------------------------------------------------------------------------------ |
---|
| 110 | # Output Elevation Data |
---|
| 111 | #------------------------------------------------------------------------------ |
---|
| 112 | # Output filename for elevation |
---|
| 113 | # this is a combination of all the data (utilisied in build_boundary) |
---|
[6064] | 114 | combined_name ='carnarvon_combined_elevation_quick' |
---|
[5790] | 115 | combined_smaller_name = 'carnarvon_combined_elevation_smaller' |
---|
| 116 | |
---|
| 117 | #------------------------------------------------------------------------------ |
---|
| 118 | # Directory Structure |
---|
| 119 | #------------------------------------------------------------------------------ |
---|
[5005] | 120 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
[5755] | 121 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
| 122 | topographies_dir = anuga_dir+'topographies'+sep |
---|
[5790] | 123 | polygons_dir = anuga_dir+'polygons'+sep |
---|
| 124 | tide_dir = anuga_dir+'tide_data'+sep |
---|
| 125 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
| 126 | output_dir = anuga_dir+'outputs'+sep |
---|
| 127 | gauges_dir = anuga_dir+'gauges'+sep |
---|
| 128 | meshes_dir = anuga_dir+'meshes'+sep |
---|
[5005] | 129 | |
---|
[5790] | 130 | #------------------------------------------------------------------------------ |
---|
| 131 | # Location of input and output data |
---|
| 132 | #------------------------------------------------------------------------------ |
---|
| 133 | # where the input data sits |
---|
[5005] | 134 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
| 135 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
[5755] | 136 | offshore_in_dir_name1 = topographies_in_dir + offshore_name1 |
---|
[6021] | 137 | offshore_in_dir_aoi = topographies_in_dir + topo_aoi |
---|
| 138 | offshore_in_dir_aos = topographies_in_dir + topo_aos |
---|
[5005] | 139 | |
---|
[5790] | 140 | # where the output data sits |
---|
[5005] | 141 | onshore_dir_name = topographies_dir + onshore_name |
---|
| 142 | offshore_dir_name = topographies_dir + offshore_name |
---|
[5755] | 143 | offshore_dir_name1 = topographies_dir + offshore_name1 |
---|
[6021] | 144 | offshore_dir_aoi = topographies_dir + topo_aoi |
---|
| 145 | offshore_dir_aos = topographies_dir + topo_aos |
---|
[5005] | 146 | |
---|
[5790] | 147 | # where the combined elevation file sits |
---|
[5005] | 148 | combined_dir_name = topographies_dir + combined_name |
---|
[5755] | 149 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
[5005] | 150 | |
---|
[5790] | 151 | # where the mesh sits (this is created during the run_carnarvon.py) |
---|
| 152 | meshes_dir_name = meshes_dir + scenario_name+'.msh' |
---|
[5005] | 153 | |
---|
[5790] | 154 | # where the boundary ordering files sit (this is used within build_boundary.py) |
---|
| 155 | order_filename_dir = boundaries_dir + order_filename |
---|
[5005] | 156 | |
---|
[5790] | 157 | # where the landward points of boundary extent sit (this is used within run_carnarvon.py) |
---|
| 158 | landward_dir = boundaries_dir + landward |
---|
[5005] | 159 | |
---|
[5790] | 160 | # where the event sts files sits (this is created during the build_boundary.py) |
---|
| 161 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
[5755] | 162 | boundaries_dir_mux = muxhome |
---|
[5005] | 163 | |
---|
[5790] | 164 | # where the directory of the output filename sits |
---|
| 165 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_carnarvon.py |
---|
| 166 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_carnarvon.py |
---|
[5005] | 167 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
| 168 | |
---|
[5790] | 169 | #w here the directory of the gauges sit |
---|
| 170 | gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
| 171 | gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
[6064] | 172 | building_in_dir_name = gauges_dir + building + '.csv' |
---|
[5790] | 173 | #------------------------------------------------------------------------------ |
---|
| 174 | # Interior region definitions |
---|
| 175 | #------------------------------------------------------------------------------ |
---|
[5755] | 176 | |
---|
[5790] | 177 | #Land, to set the initial stage/water to be offcoast only |
---|
| 178 | #Land and Ocean to clip data |
---|
| 179 | poly_mainland=read_polygon(polygons_dir +'land_initial_condition.csv') |
---|
| 180 | poly_island1=read_polygon(polygons_dir +'land_initial_condition_bernier.csv') |
---|
| 181 | poly_island2=read_polygon(polygons_dir +'land_initial_condition_dorne.csv') |
---|
| 182 | poly_ocean=read_polygon(polygons_dir +'ocean_initial_condition.csv') |
---|
[6021] | 183 | poly_aos_extract = read_polygon(polygons_dir+'extract_aos.csv') |
---|
[5005] | 184 | |
---|
[5790] | 185 | # Initial bounding polygon for data clipping |
---|
[5005] | 186 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
| 187 | res_poly_all = 100000*res_factor |
---|
| 188 | |
---|
[5790] | 189 | # Area of Interest 1 (carnarvon) |
---|
| 190 | poly_aoi1 = read_polygon(polygons_dir+'Carnarvon5m.csv') |
---|
| 191 | res_aoi1 = 500*res_factor |
---|
[5005] | 192 | |
---|
[5790] | 193 | # Area of Significance 1 (carnarvon) |
---|
| 194 | poly_aos1 = read_polygon(polygons_dir+'Carnarvon10m.csv') |
---|
| 195 | res_aos1 = 1500*res_factor |
---|
[5005] | 196 | |
---|
[5790] | 197 | # Shallow water 1 |
---|
| 198 | poly_sw1 = read_polygon(polygons_dir+'Carnarvon20m.csv') |
---|
| 199 | res_sw1 = 25000*res_factor |
---|
[5005] | 200 | |
---|
[5790] | 201 | # Shallow water 2 |
---|
| 202 | poly_sw2 = read_polygon(polygons_dir+'Island20m.csv') |
---|
| 203 | res_sw2 = 50000*res_factor |
---|
[5005] | 204 | |
---|
[5790] | 205 | # Combined all regions, must check that all are included! |
---|
| 206 | interior_regions = [[poly_aoi1,res_aoi1],[poly_aos1,res_aos1] |
---|
| 207 | ,[poly_sw1,res_sw1],[poly_sw2,res_sw2]] |
---|
[5005] | 208 | |
---|
[5755] | 209 | |
---|
[5005] | 210 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
[5790] | 211 | print 'min estimated number of triangles', trigs_min |
---|
[5755] | 212 | |
---|
[5790] | 213 | #------------------------------------------------------------------------------ |
---|
[5755] | 214 | # Clipping regions for export to asc and regions for clipping data |
---|
[5790] | 215 | # Final inundation maps should only be created in regions of the finest mesh |
---|
| 216 | #------------------------------------------------------------------------------ |
---|
[5005] | 217 | |
---|
[5790] | 218 | # carnarvon CBD extract ascii grid |
---|
[6064] | 219 | xminCBD = 763000 |
---|
| 220 | xmaxCBD = 775000 |
---|
| 221 | yminCBD = 7239000 |
---|
| 222 | ymaxCBD = 7251000 |
---|