[5810] | 1 | """Common filenames and locations for elevation, meshes and outputs. |
---|
| 2 | This script is the heart of all scripts in 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 | ##time stuff |
---|
| 28 | time = strftime('%Y%m%d_%H%M%S',localtime()) #gets time for new dir |
---|
| 29 | gtime = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
| 30 | build_time = time+'_build' |
---|
| 31 | run_time = time+'_run' |
---|
| 32 | print 'gtime: ', gtime |
---|
| 33 | |
---|
| 34 | #------------------------------------------------------------------------------ |
---|
| 35 | # Initial Conditions |
---|
| 36 | #------------------------------------------------------------------------------ |
---|
| 37 | |
---|
| 38 | ##Changed to reflect the modeled community (also sets up the directory system) |
---|
| 39 | state = 'western_australia' |
---|
| 40 | scenario_name = 'broome' |
---|
| 41 | scenario = 'broome_tsunami_scenario_2008' |
---|
| 42 | ##One or all can be changed each time the run_scenario script is excuted |
---|
| 43 | tide = 0.6 |
---|
| 44 | event_number = 27255 |
---|
| 45 | #event_number = 27283 |
---|
| 46 | alpha = 0.1 |
---|
| 47 | friction=0.01 |
---|
| 48 | starttime=0 |
---|
| 49 | finaltime=80000 |
---|
| 50 | |
---|
| 51 | setup='final' ## Can replace with trial or basic, this action will thin the mesh |
---|
| 52 | ## so that the run script will take less time (hence less acurate) |
---|
| 53 | |
---|
| 54 | if setup =='trial': |
---|
| 55 | print'trial' |
---|
| 56 | res_factor=10 |
---|
| 57 | time_thinning=48 |
---|
| 58 | yieldstep=240 |
---|
| 59 | if setup =='basic': |
---|
| 60 | print'basic' |
---|
| 61 | res_factor=4 |
---|
| 62 | time_thinning=12 |
---|
| 63 | yieldstep=120 |
---|
| 64 | if setup =='final': |
---|
| 65 | print'final' |
---|
| 66 | res_factor=1 |
---|
| 67 | time_thinning=4 |
---|
| 68 | yieldstep=60 |
---|
| 69 | |
---|
| 70 | #------------------------------------------------------------------------------ |
---|
| 71 | # Output Filename |
---|
| 72 | #------------------------------------------------------------------------------ |
---|
| 73 | ##Important to distiquish each run |
---|
| 74 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(event_number)+'_'+ 'alpha' +str(alpha)+'_'+str(user) |
---|
| 75 | |
---|
| 76 | #------------------------------------------------------------------------------ |
---|
| 77 | # INPUT DATA |
---|
| 78 | #------------------------------------------------------------------------------ |
---|
| 79 | |
---|
| 80 | ##ELEVATION DATA## - used in build_broome.py |
---|
| 81 | ## onshore data: format ascii grid with accompaning projection file |
---|
| 82 | onshore_name = 'town_topo_10m' |
---|
| 83 | ## island: format ascii grid with accompaning projection file |
---|
| 84 | #island_name = 'rott_dli_ext' |
---|
| 85 | #island_name1 = 'gard_dli_ext' |
---|
| 86 | #island_name2 = 'carnac_island_dli_ext' |
---|
| 87 | #island_name3 = 'penguin_dli_ext' |
---|
| 88 | ## coastline: format x,y,elevation (with title) |
---|
| 89 | coast_name = 'Broome_coastline.txt' |
---|
| 90 | ## bathymetry: format x,y,elevation (with title) |
---|
| 91 | offshore_name = 'Broome_Bathymetry.txt' |
---|
| 92 | offshore_name1 = 'cable_250m' |
---|
| 93 | offshore_name2 = 'inferred_north' |
---|
| 94 | offshore_name3 = 'inferred_south' |
---|
| 95 | offshore_name4 = 'north_250m' |
---|
| 96 | offshore_name5 = 'other_topo_250m' |
---|
| 97 | offshore_name6 = 'south_250m' |
---|
| 98 | |
---|
| 99 | ##GAUGES## - used in get_timeseries.py |
---|
| 100 | #gauge_name = 'Broome.csv' |
---|
| 101 | #gauge_name2 = 'thinned_MGA50.csv' |
---|
| 102 | |
---|
| 103 | ##BOUNDING POLYGON## -used in build_boundary.py and run_broome.py respectively |
---|
| 104 | #NOTE: when files are put together must be in sequence - for ease go clockwise! |
---|
| 105 | #Check the run_broome.py for boundary_tags |
---|
| 106 | ##thinned ordering file from Hazard Map: format index,latitude,longitude (with title) |
---|
| 107 | order_filename = 'thinned_boundary_ordering.csv' |
---|
| 108 | ##landward bounding points |
---|
| 109 | landward = 'landward_bounding_polygon.csv' |
---|
| 110 | |
---|
| 111 | #------------------------------------------------------------------------------ |
---|
| 112 | # OUTPUT ELEVATION DATA |
---|
| 113 | #------------------------------------------------------------------------------ |
---|
| 114 | ##Output filename for elevation |
---|
| 115 | ## its a combination of all the data put together (utilisied in build_boundary) |
---|
| 116 | combined_name ='broome_combined_elevation' |
---|
| 117 | combined_smaller_name = 'broome_combined_elevation_smaller' |
---|
| 118 | |
---|
| 119 | #------------------------------------------------------------------------------ |
---|
| 120 | # Directory Structure |
---|
| 121 | #------------------------------------------------------------------------------ |
---|
| 122 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
| 123 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep |
---|
| 124 | topographies_dir = anuga_dir+'topographies'+sep |
---|
| 125 | polygons_dir = anuga_dir+'polygons'+sep |
---|
| 126 | tide_dir = anuga_dir+'tide_data'+sep |
---|
| 127 | boundaries_dir = anuga_dir+'boundaries'+ sep |
---|
| 128 | output_dir = anuga_dir+'outputs'+sep |
---|
| 129 | gauges_dir = anuga_dir+'gauges'+sep |
---|
| 130 | meshes_dir = anuga_dir+'meshes'+sep |
---|
| 131 | |
---|
| 132 | #------------------------------------------------------------------------------ |
---|
| 133 | # Location of input and output Data |
---|
| 134 | #------------------------------------------------------------------------------ |
---|
| 135 | ##where the input data sits |
---|
| 136 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
| 137 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
| 138 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
| 139 | offshore_in_dir_name1 = topographies_in_dir + offshore_name1 |
---|
| 140 | offshore_in_dir_name2 = topographies_in_dir + offshore_name2 |
---|
| 141 | offshore_in_dir_name3 = topographies_in_dir + offshore_name3 |
---|
| 142 | offshore_in_dir_name4 = topographies_in_dir + offshore_name4 |
---|
| 143 | offshore_in_dir_name5 = topographies_in_dir + offshore_name5 |
---|
| 144 | offshore_in_dir_name6 = topographies_in_dir + offshore_name6 |
---|
| 145 | |
---|
| 146 | ##where the output data sits |
---|
| 147 | onshore_dir_name = topographies_dir + onshore_name |
---|
| 148 | coast_dir_name = topographies_dir + coast_name |
---|
| 149 | offshore_dir_name = topographies_dir + offshore_name |
---|
| 150 | offshore_dir_name1 = topographies_dir + offshore_name1 |
---|
| 151 | offshore_dir_name2 = topographies_dir + offshore_name2 |
---|
| 152 | offshore_dir_name3 = topographies_dir + offshore_name3 |
---|
| 153 | offshore_dir_name4 = topographies_dir + offshore_name4 |
---|
| 154 | offshore_dir_name5 = topographies_dir + offshore_name5 |
---|
| 155 | offshore_dir_name6 = topographies_dir + offshore_name6 |
---|
| 156 | |
---|
| 157 | ##where the combined file sits |
---|
| 158 | combined_dir_name = topographies_dir + combined_name |
---|
| 159 | combined_smaller_name_dir = topographies_dir + combined_smaller_name |
---|
| 160 | |
---|
| 161 | ##where the mesh sits (this is created during the run_broome.py) |
---|
| 162 | meshes_dir_name = meshes_dir + scenario_name+'.msh' |
---|
| 163 | |
---|
| 164 | #where the boundary order files sit (this is used within build_boundary.py) |
---|
| 165 | order_filename_dir = boundaries_dir + order_filename |
---|
| 166 | |
---|
| 167 | #where the landward points of boundary extent sit (this is used within run_broome.py) |
---|
| 168 | landward_dir = boundaries_dir + landward |
---|
| 169 | |
---|
| 170 | #where the event sts files sits (this is created during the build_boundary.py) |
---|
| 171 | boundaries_dir_event = boundaries_dir + str(event_number) + sep |
---|
| 172 | boundaries_dir_mux = muxhome |
---|
| 173 | |
---|
| 174 | #where the directory of the output filename sits |
---|
| 175 | output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_broome.py |
---|
| 176 | output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_broome.py |
---|
| 177 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
| 178 | |
---|
| 179 | #where the directory of the gauges sit |
---|
| 180 | #gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py |
---|
| 181 | #gauges_dir_name2 = gauges_dir + gauge_name2 #used for get_timeseries.py |
---|
| 182 | |
---|
| 183 | #------------------------------------------------------------------------------ |
---|
| 184 | # Interior region definitions |
---|
| 185 | #------------------------------------------------------------------------------ |
---|
| 186 | |
---|
| 187 | #Land, to set the stage/water to be offcoast only |
---|
| 188 | poly_mainland = read_polygon(polygons_dir+'initial_conditions_mainland.csv') |
---|
| 189 | |
---|
| 190 | #Initial bounding polygon for data clipping |
---|
| 191 | poly_all = read_polygon(polygons_dir+'poly_all.csv') |
---|
| 192 | res_poly_all = 100000*res_factor |
---|
| 193 | |
---|
| 194 | #Area of Interest 1 (Broome) |
---|
| 195 | poly_aoi1 = read_polygon(polygons_dir+'Area_Of_Interest.csv') |
---|
| 196 | res_aoi1 = 500*res_factor |
---|
| 197 | |
---|
| 198 | #Area of Significance 1 (Broome) |
---|
| 199 | poly_aos1 = read_polygon(polygons_dir+'Area_Of_Significance.csv') |
---|
| 200 | res_aos1 = 1000*res_factor |
---|
| 201 | |
---|
| 202 | #Shallow water 1 |
---|
| 203 | poly_sw1 = read_polygon(polygons_dir+'Shallow_Water.csv') |
---|
| 204 | res_sw1 = 25000*res_factor |
---|
| 205 | |
---|
| 206 | ##Deep water (land of Rottnest, ANUGA does not do donuts!) |
---|
| 207 | #poly_dw1 = read_polygon(polygons_dir+'rottnest_internal.csv') |
---|
| 208 | #res_dw1 = 100000*res_factor |
---|
| 209 | |
---|
| 210 | # Combined all regions, must check that all are included! |
---|
| 211 | interior_regions = [[poly_aoi1,res_aoi1], |
---|
| 212 | [poly_aos1,res_aos1], |
---|
| 213 | [poly_sw1,res_sw1]] |
---|
| 214 | |
---|
| 215 | |
---|
| 216 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
| 217 | print 'min estimated number of triangles', trigs_min |
---|
| 218 | |
---|
| 219 | |
---|
| 220 | ###------------------------------------------------------------------------------ |
---|
| 221 | ### Clipping regions for export to asc and regions for clipping data |
---|
| 222 | ###------------------------------------------------------------------------------ |
---|
| 223 | ## |
---|
| 224 | ###Geordie Bay extract ascii grid |
---|
| 225 | ##xminGeordie = 358000 |
---|
| 226 | ##xmaxGeordie = 362000 |
---|
| 227 | ##yminGeordie = 6458500 |
---|
| 228 | ##ymaxGeordie = 6461000 |
---|
| 229 | ## |
---|
| 230 | ###Sorrento extract ascii grid |
---|
| 231 | ##xminSorrento = 379000 |
---|
| 232 | ##xmaxSorrento = 382500 |
---|
| 233 | ##yminSorrento = 6477000 |
---|
| 234 | ##ymaxSorrento = 6480000 |
---|
| 235 | ## |
---|
| 236 | ###Fremantle extract ascii grid |
---|
| 237 | ##xminFremantle = 376000 |
---|
| 238 | ##xmaxFremantle = 388000 |
---|
| 239 | ##yminFremantle = 6449000 |
---|
| 240 | ##ymaxFremantle = 6461000 |
---|
| 241 | ## |
---|
| 242 | ###Rockingham extract ascii grid |
---|
| 243 | ##xminRockingham = 373500 |
---|
| 244 | ##xmaxRockingham = 385500 |
---|
| 245 | ##yminRockingham = 6424000 |
---|
| 246 | ##ymaxRockingham = 6433000 |
---|
| 247 | ## |
---|
| 248 | ## |
---|