Changeset 6308
- Timestamp:
- Feb 10, 2009, 2:27:54 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/production/busselton/standardised_version/project.py
r6284 r6308 1 """Common filenames and locations for elevation, meshes and outputs. 1 """ 2 Common filenames and locations for elevation, meshes and outputs. 2 3 This script is the heart of all scripts in the folder 3 4 """ 4 #------------------------------------------------------------------------------ 5 # Import necessary modules 6 #------------------------------------------------------------------------------ 7 5 6 import sys 8 7 import os 9 from os.path import join 10 from os import sep, getenv 8 from os.path import join, exists 11 9 from time import localtime, strftime, gmtime 12 10 from anuga.utilities.polygon import read_polygon, number_mesh_triangles 13 11 from anuga.utilities.system_tools import get_user_name, get_host_name 14 12 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') 13 14 #----- 15 # Get system data - don't fiddle with this. 16 #----- 17 22 18 user = get_user_name() 23 19 host = get_host_name() 24 20 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' 21 #------------------------------------------------------------------------------- 22 # Directory setup 23 #------------------------------------------------------------------------------- 30 24 31 25 # this section needs to be updated to reflect the modelled community. … … 35 29 scenario_folder = 'busselton_tsunami_scenario' 36 30 37 #------------------------------------------------------------------------------ 31 #------------------------------------------------------------------------------- 38 32 # 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 = 27255 # Java 9.3 worst case for Perth 44 #event_number = 68693 # Sumatra 9.2 45 #event_number = 27283 # Java 9.3 original 46 tide = 0 #0.6 47 #event_number = 27255 # Java 9.3 worst case for Perth 48 #event_number = 68693 # Sumatra 9.2 49 event_number = 27283 # Java 9.3 original 33 #------------------------------------------------------------------------------- 34 35 # Model specific parameters. 36 # One or all can be changed each time the run_model script is executed 37 tide = 0 # ?? 38 event_number = 27283 # the event number 50 39 alpha = 0.1 # smoothing parameter for mesh 51 40 friction=0.01 # manning's friction coefficient 52 starttime=0 41 starttime=0 # start time for simulation 53 42 finaltime=80000 # final time for simulation 54 43 55 setup='final' # Final can be replaced with trial or basic. 56 # Either will result in a coarser mesh that will allow a 57 # faster, but less accurate, simulation. 58 59 if setup =='trial': 60 print'trial' 61 scale_factor=100 62 time_thinning=96 63 yieldstep=240 64 if setup =='basic': 65 print'basic' 66 scale_factor=4 67 time_thinning=12 68 yieldstep=120 69 if setup =='final': 70 print'final' 71 scale_factor=1 72 time_thinning=4 73 yieldstep=60 74 75 76 #------------------------------------------------------------------------------ 44 setup = 'final' # Final can be replaced with trial or basic. 45 # Either will result in a coarser mesh that will 46 # allow a faster, but less accurate, simulation. 47 48 #------------------------------------------------------------------------------- 77 49 # Output Filename 78 #------------------------------------------------------------------------------ 50 #------------------------------------------------------------------------------- 51 79 52 # Important to distinguish each run - ensure str(user) is included! 80 53 # Note, the user is free to include as many parameters as desired 81 output_comment= ('_' + setup + '_' + str(tide)+ '_' + str(event_number) + 82 '_' + str(user)) 83 84 #------------------------------------------------------------------------------ 54 output_comment = '_'.join([setup, str(tide), str(event_number), str(user)]) 55 56 #------------------------------------------------------------------------------- 85 57 # Input Data 86 #------------------------------------------------------------------------------ 58 #------------------------------------------------------------------------------- 59 87 60 # ELEVATION DATA 88 61 # Used in build_elevation.py … … 92 65 93 66 # Format for point is x,y,elevation (with header) 94 point_filenames = ['Busselton_Contour0.txt', # Coastline 95 'Busselton_BeachSurvey.txt', # Beach survey 96 'Busselton_NavyFinal.txt', # Bathymetry 97 'Busselton_Chart.txt', # Bathymetry Charts 98 'Busselton_Digitised.txt', # Digitised Fairsheet 99 'Busselton_250m.txt', # 250m 100 'Bunbury_TIN.txt', # Bunbury aoi TIN'd in ArcGIS 101 'Busselton_TIN.txt', # Busselton aoi TIN'd in ArcGIS 102 'XYAHD_clip.txt'] # To extend boundary 103 104 105 # LAND - used to set the initial stage/water to be offcoast only 106 # Used in run_model,py 107 # Format for points easting,northing (no header) 108 land_initial_conditions_filename = [['initial_condition_extend.csv', 0], 109 ['initial_condition_marina.csv', 0]] 67 point_filenames = ['Busselton_Contour0.txt', # Coastline 68 'Busselton_BeachSurvey.txt', # Beach survey 69 'Busselton_NavyFinal.txt', # Bathymetry 70 'Busselton_Chart.txt', # Bathymetry Charts 71 'Busselton_Digitised.txt', # Digitised Fairsheet 72 'Busselton_250m.txt', # 250m 73 'Bunbury_TIN.txt', # Bunbury aoi TIN'd in ArcGIS 74 'Busselton_TIN.txt', # Busselton aoi TIN'd in ArcGIS 75 'XYAHD_clip.txt'] # To extend boundary 110 76 111 77 # BOUNDING POLYGON - for data clipping and estimate of triangles in mesh … … 125 91 ['coast_5km_d20m.csv', 40000]] 126 92 93 # LAND - used to set the initial stage/water to be offcoast only 94 # Used in run_model.py. Format for points easting,northing (no header) 95 land_initial_conditions_filename = [['initial_condition_extend.csv', 0], 96 ['initial_condition_marina.csv', 0]] 97 127 98 # GAUGES - for creating timeseries at a specific point 128 # Used in get_timeseries.py 99 # Used in get_timeseries.py. 129 100 # Format easting,northing,name,elevation (with header) 130 101 gauges_filename = 'gauges.csv' … … 135 106 building_exposure_filename = 'busselton_res_clip.csv' #from NEXIS 136 107 137 # BOUNDING POLYGON 138 # used in build_boundary.py and run_model.py respectively 108 # BOUNDING POLYGON - used in build_boundary.py and run_model.py respectively 139 109 # NOTE: when files are put together the points must be in sequence 140 110 # For ease go clockwise! … … 149 119 landward_boundary_filename = 'landward_boundary_extend.csv' 150 120 151 #------------------------------------------------------------------------------ 121 # MUX input filename 122 # Must exist in $MUXHOME/mux directory. 123 # If MUX file not used, do "mux_input_file = None". 124 mux_input_file = 'event_031451.list' # File produced by EventSelection 125 126 #------------------------------------------------------------------------------- 152 127 # Clipping regions for export to asc and regions for clipping data 153 128 # Final inundation maps should only be created in regions of the finest mesh 154 #------------------------------------------------------------------------------ 129 #------------------------------------------------------------------------------- 155 130 156 131 # ASCII export grid for Busselton … … 167 142 168 143 169 #------------------------------------------------------------------------------ 144 ################################################################################ 145 ################################################################################ 146 #### NOTE: NOTHING SHOULD CHANGE BELOW THIS POINT. #### 147 ################################################################################ 148 ################################################################################ 149 150 #------------------------------------------------------------------------------- 151 # Sanity checks 152 #------------------------------------------------------------------------------- 153 154 # Test that environment variables are defined. 155 # A little late, but better here than up in user-changeable data. 156 157 # Environment variable names. 158 # The inundation directory, not the data directory. 159 ENV_INUNDATIONHOME = 'INUNDATIONHOME' 160 161 # Path to MUX data 162 ENV_MUXHOME = 'MUXHOME' 163 164 # Check we have required environment variables set 165 sanity_error = False # checked at bottom of this file 166 167 if os.getenv(ENV_INUNDATIONHOME) is None: 168 print "Environment variable '%s' is not set" % ENV_INUNDATIONHOME 169 sanity_error = True 170 171 if os.getenv(ENV_MUXHOME) is None: 172 print "Environment variable '%s' is not set" % ENV_MUXHOME 173 sanity_error = True 174 175 # check for errors detected so far 176 if sanity_error: 177 print 'You must fix the above errors before continuing.' 178 sys.exit(10) 179 180 #------------------------------------------------------------------------------- 170 181 # Output Elevation Data 171 #------------------------------------------------------------------------------ 182 #------------------------------------------------------------------------------- 183 172 184 # Output filename for elevation 173 185 # this is a combination of all the data generated in build_elevation.py 174 186 combined_elevation_basename = scenario_name + '_combined_elevation' 175 187 176 #------------------------------------------------------------------------------ 188 #------------------------------------------------------------------------------- 177 189 # Directory Structure 178 #------------------------------------------------------------------------------ 190 #------------------------------------------------------------------------------- 191 192 # determines time for setting up output directories 193 time = strftime('%Y%m%d_%H%M%S', localtime()) 194 gtime = strftime('%Y%m%d_%H%M%S', gmtime()) 195 build_time = time + '_build' 196 run_time = time + '_run' 197 198 # create paths generated from environment variables. 199 home = join(os.getenv(ENV_INUNDATIONHOME), 'data') # Absolute path for data folder 200 if not exists(home): 201 print "Sorry, data directory '%s' doesn't exist" % home 202 sanity_error = True 203 204 muxhome = os.getenv(ENV_MUXHOME) 205 if not exists(muxhome): 206 print "Sorry, MUX directory '%s' doesn't exist" % muxhome 207 sanity_error = True 208 209 # if mux_input_file has been defined, check if file exists 210 if mux_input_file: 211 if not exists(join(muxhome, mux_input_file)): 212 print ("Sorry, MUX input file '%s' doesn't exist" 213 % join(muxhome, mux_input_file)) 214 sanity_error = True 215 216 # check various directories that must exist 179 217 anuga_folder = join(home, state, scenario_folder, 'anuga') 218 if not exists(anuga_folder): 219 print "Sorry, ANUGA directory '%s' doesn't exist" % anuga_folder 220 sanity_error = True 221 180 222 topographies_folder = join(anuga_folder, 'topographies') 223 if not exists(topographies_folder): 224 print "Sorry, topo directory '%s' doesn't exist" % topographies_folder 225 sanity_error = True 226 181 227 polygons_folder = join(anuga_folder, 'polygons') 228 if not exists(polygons_folder): 229 print "Sorry, polygon directory '%s' doesn't exist" % polygons_folder 230 sanity_error = True 231 182 232 boundaries_folder = join(anuga_folder, 'boundaries') 233 if not exists(boundaries_folder): 234 print "Sorry, boundaries directory '%s' doesn't exist" % boundaries_folder 235 sanity_error = True 236 183 237 output_folder = join(anuga_folder, 'outputs') 184 gauges_folder = join(anuga_folder,'gauges') 238 if not exists(output_folder): 239 print "Sorry, outputs directory '%s' doesn't exist" % output_folder 240 sanity_error = True 241 242 gauges_folder = join(anuga_folder, 'gauges') 243 if not exists(gauges_folder): 244 print "Sorry, gauges directory '%s' doesn't exist" % gauges_folder 245 sanity_error = True 246 185 247 meshes_folder = join(anuga_folder, 'meshes') 186 187 #------------------------------------------------------------------------------ 248 if not exists(meshes_folder): 249 print "Sorry, meshes directory '%s' doesn't exist" % meshes_folder 250 sanity_error = True 251 252 253 #------------------------------------------------------------------------------- 188 254 # Location of input and output data 189 #------------------------------------------------------------------------------ 255 #------------------------------------------------------------------------------- 190 256 191 257 # The absolute pathname of the all elevation, generated in build_elevation.py 192 258 combined_elevation = join(topographies_folder, combined_elevation_basename) 193 194 259 195 260 # The absolute pathname of the mesh, generated in run_model.py … … 222 287 building_exposure = join(gauges_folder, building_exposure_filename) 223 288 224 #------------------------------------------------------------------------------ 289 #------------------------------------------------------------------------------- 290 # Determine type of run 291 #------------------------------------------------------------------------------- 292 293 if setup == 'trial': 294 print 'trial' 295 scale_factor = 100 296 time_thinning = 96 297 yieldstep = 240 298 elif setup == 'basic': 299 print 'basic' 300 scale_factor = 4 301 time_thinning = 12 302 yieldstep = 120 303 elif setup == 'final': 304 print 'final' 305 scale_factor = 1 306 time_thinning = 4 307 yieldstep = 60 308 else: 309 print ("Sorry, you must set the 'setup' variable to one of 'trial', " 310 "'basic' or 'final'. I found '%s'" % str(setup)) 311 sanity_error = True 312 313 #------------------------------------------------------------------------------- 225 314 # Reading polygons and creating interior regions 226 #------------------------------------------------------------------------------ 315 #------------------------------------------------------------------------------- 227 316 228 317 # Create list of land polygons with initial conditions … … 246 335 trigs_min = number_mesh_triangles(interior_regions, 247 336 bounding_polygon, bounding_maxarea) 337 338 #------------------------------------------------------------------------------- 339 # Check for errors detected above. 340 #------------------------------------------------------------------------------- 341 342 if sanity_error: 343 print 'You must fix the above errors before continuing.' 344 sys.exit(10) 345 346 248 347 print 'min estimated number of triangles', trigs_min 249 250
Note: See TracChangeset
for help on using the changeset viewer.