"""Common filenames and locations for elevation, meshes and outputs. This script is the heart of all scripts in the folder """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ from os import sep, environ, getenv, getcwd from os.path import expanduser import sys from time import localtime, strftime, gmtime from anuga.utilities.polygon import read_polygon, plot_polygons, is_inside_polygon, number_mesh_triangles from anuga.utilities.system_tools import get_user_name, get_host_name from anuga.shallow_water.data_manager import urs2sts,create_sts_boundary from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon #------------------------------------------------------------------------------ # Directory setup #------------------------------------------------------------------------------ # Note: INUNDATIONHOME is the inundation directory, not the data directory. home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name() user = get_user_name() host = get_host_name() # determines time for setting up output directories time = strftime('%Y%m%d_%H%M%S',localtime()) gtime = strftime('%Y%m%d_%H%M%S',gmtime()) build_time = time+'_build' run_time = time+'_run' #------------------------------------------------------------------------------ # Initial Conditions #------------------------------------------------------------------------------ # this section needs to be updated to reflect the modelled community. # Note, the user needs to set up the directory system accordingly state = 'thailand' scenario_name = 'patong' scenario = 'patong_tsunami_scenario' # Model specific parameters. One or all can be changed each time the # run_scenario script is executed tide = 0.8 #0.8 alpha = 0.1 # smoothing parameter for mesh friction=0.01 # manning's friction coefficient starttime=0 finaltime=15000 # final time for simulation 15000 setup='final' # Final can be replaced with trial or basic. # Either will result in a coarser mesh that will allow a # faster, but less accurate, simulation. if setup =='trial': print'trial' res_factor=10 time_thinning=48 yieldstep=240 if setup =='basic': print'basic' res_factor=4 time_thinning=24 yieldstep=120 if setup =='final': print'final' res_factor=1 time_thinning=4 yieldstep=5 use_buildings = True #------------------------------------------------------------------------------ # Output Filename #------------------------------------------------------------------------------ # Important to distinguish each run - ensure str(user) is included! # Note, the user is free to include as many parameters as desired if use_buildings: dir_comment='_'+setup+'_'+str(tide)+'_buildings_'+str(user) else: dir_comment='_'+setup+'_'+str(tide)+'_nobuildings_'+str(user) #------------------------------------------------------------------------------ # Input Data #------------------------------------------------------------------------------ # elevation data used in build_patong.py # four textfiles, with different resolutions elevation1 = 'patong_10m_grid_msl_Project.txt' elevation2 = 'patong_10m_small_grid_for_anuga_sub_Project.txt' elevation3 = 'patong_bay_1s_grid_Project.txt' elevation4 = 'andaman_3s_grid_Clip2_Project.txt' # gauges - used in get_timeseries.py gauge_name = 'gauges.csv' # BOUNDING POLYGON - used in build_boundary.py and run_patong.py respectively # NOTE: when files are put together the points must be in sequence - for ease go clockwise! # Check the run_patong.py for boundary_tags # thinned ordering file from Hazard Map: format is index,latitude,longitude (with title) order_filename = 'urs_order.csv' #landward bounding points landward = 'landward_bounding_polygon2.csv' #------------------------------------------------------------------------------ # Output Elevation Data #------------------------------------------------------------------------------ # Output filename for elevation # this is a combination of all the data (utilisied in build_boundary) combined_name ='patong_combined_elevation_large' combined_smaller_name = 'patong_combined_elevation_smaller' #------------------------------------------------------------------------------ # Directory Structure #------------------------------------------------------------------------------ anuga_dir = home+state+sep+scenario+sep+'anuga'+sep topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep topographies_dir = anuga_dir+'topographies'+sep polygons_dir = anuga_dir+'polygons'+sep tide_dir = anuga_dir+'tide_data'+sep boundaries_dir = anuga_dir+'boundaries'+ sep output_dir = anuga_dir+'outputs'+sep gauges_dir = anuga_dir+'gauges'+sep meshes_dir = anuga_dir+'meshes'+sep #------------------------------------------------------------------------------ # Location of input and output data #------------------------------------------------------------------------------ # where the input data sits elevation_in_dir_name1 = topographies_in_dir + elevation1 elevation_in_dir_name2 = topographies_in_dir + elevation2 elevation_in_dir_name3 = topographies_in_dir + elevation3 elevation_in_dir_name4 = topographies_in_dir + elevation4 # where the output data sits elevation_dir_name1 = topographies_dir + elevation1 elevation_dir_name2 = topographies_dir + elevation2 elevation_dir_name3 = topographies_dir + elevation3 elevation_dir_name4 = topographies_dir + elevation4 # where the combined elevation file sits combined_dir_name = topographies_dir + combined_name + '_data' combined_smaller_name_dir = topographies_dir + combined_smaller_name # where the mesh sits (this is created during the run_patong.py) meshes_dir_name = meshes_dir + scenario_name+'_poly.msh' # where the boundary ordering files sit (this is used within build_boundary.py) order_filename_dir = boundaries_dir + order_filename # where the landward points of boundary extent sit (this is used within run_patong.py) landward_dir = boundaries_dir + landward # where the directory of the output filename sits output_build_time_dir = output_dir+build_time+dir_comment+sep #used for build_patong.py output_run_time_dir = output_dir+run_time+dir_comment+sep #used for run_patong.py output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing # where the directory of the gauges sit gauges_dir_name = gauges_dir + gauge_name #used for get_timeseries.py #------------------------------------------------------------------------------ # Interior region definitions #------------------------------------------------------------------------------ # extents of elevation datasets extent_elev_dir1 = read_polygon(polygons_dir + 'patong_10m.txt') extent_elev_dir2 = read_polygon(polygons_dir + 'saddle_10m.txt') extent_elev_dir3 = read_polygon(polygons_dir + 'patong_1s.txt') extent_elev_dir4 = read_polygon(polygons_dir + 'patong_10m_aos.txt') #Land, to set the initial stage/water to be offcoast only poly_mainland = read_polygon(polygons_dir+'initial_conditions.csv') # Initial bounding polygon for data clipping poly_all = read_polygon(polygons_dir+'bounding_polygon.csv') res_poly_all = 160000*res_factor # Inundation area poly_ia = read_polygon(polygons_dir+'inundation_area.csv') res_ia = 75*res_factor poly_saddle = read_polygon(polygons_dir+'saddle_10m.txt') # Area of Interest 1 elevation from -10m to 20m poly_aoi1 = read_polygon(polygons_dir+'aoi.csv') res_aoi1 = 200*res_factor # Area of Significance 1 elevation from -20m to a 200m buffer of the 20m contour poly_aos1 = read_polygon(polygons_dir+'aos.csv') res_aos1 = 900*res_factor # Area of Shallow water and coastal land that needs a finer res than 1000000 poly_sw = read_polygon(polygons_dir+'sw.csv') res_sw = 7000*res_factor # Area of buildings building_main = read_polygon(polygons_dir+'building_main.csv') building_main_small = read_polygon(polygons_dir+'building_main_small.csv') building_main_south = read_polygon(polygons_dir+'building_main_south.csv') building_saddle = read_polygon(polygons_dir+'building_saddle.csv') building_area_polygons = [building_main, building_main_small, building_main_south, building_saddle] bld_res = 20*res_factor # Combined all regions, must check that all are included! interior_regions = [[poly_ia, res_ia], #[poly_saddle, res_ia], [poly_aoi1,res_aoi1], [poly_aos1,res_aos1], [poly_sw,res_sw], [building_main, bld_res], [building_main_small, bld_res], [building_main_south, bld_res], [building_saddle, bld_res]] trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) print 'min estimated number of triangles', trigs_min #------------------------------------------------------------------------------ # Building polygons #------------------------------------------------------------------------------ building_polygon_file = polygons_dir+'buildings.csv' #------------------------------------------------------------------------------ # Clipping regions for export to asc and regions for clipping data # Final inundation maps should only be created in regions of the finest mesh #------------------------------------------------------------------------------ #CBD extract ascii grid - coordinates from patong_1s extent xminCBD = 417445.1119 xmaxCBD = 425601.7881 yminCBD = 870663.4547 ymaxCBD = 876965.3856