"""Script for running tsunami inundation scenario for Dampier, WA, Australia. Source data such as elevation and boundary data is assumed to be available in directories specified by project.py The output sww file is stored in project.output_time_dir The scenario is defined by a triangular mesh created from project.polygon, the elevation data and a simulated submarine landslide. Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006 """ #------------------------------------------------------------------------------ # Import necessary modules #------------------------------------------------------------------------------ # Standard modules from os import sep from os.path import dirname, basename from os import mkdir, access, F_OK from shutil import copy import time import sys # Related major packages from anuga.shallow_water import Domain from anuga.shallow_water import Dirichlet_boundary from anuga.shallow_water import File_boundary from anuga.shallow_water import Reflective_boundary from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts from anuga.pmesh.mesh_interface import create_mesh_from_regions from anuga.geospatial_data.geospatial_data import * # Application specific imports import project # Definition of file names and polygons #------------------------------------------------------------------------------ # Copy scripts to time stamped output directory and capture screen # output to file #------------------------------------------------------------------------------ # creates copy of code in output dir if dir doesn't exist if access(project.output_time_dir,F_OK) == 0: mkdir (project.output_time_dir) copy (dirname(project.__file__) +sep+ project.__name__+'.py', project.output_time_dir + project.__name__+'.py') #copies project.py copy (__file__, project.output_time_dir + basename(__file__)) print 'project.output_time_dir',project.output_time_dir #copies this file boundary_dir_name = project.boundary_dir_name from anuga.shallow_water.data_manager import urs2sww print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary #import sys; sys.exit() urs2sww(boundary_dir_name, # minlat=project.north_boundary, maxlat=project.south_boundary, # minlon= project.west_boundary, maxlon=project.east_boundary, verbose='true') import sys; sys.exit() #------------------------------------------------------------------------------- # Preparation of topographic data # # Convert ASC 2 DEM 2 PTS using source data and store result in source data # Do for coarse and fine data # Fine pts file to be clipped to area of interest #------------------------------------------------------------------------------- # topography directory filenames onshore_dir_name = project.onshore_dir_name coast_dir_name = project.coast_dir_name islands_dir_name = project.islands_dir_name offshore_dir_name = project.offshore_dir_name offshore_dir_name1 = project.offshore_dir_name1 offshore_dir_name2 = project.offshore_dir_name2 offshore_dir_name3 = project.offshore_dir_name3 offshore_dir_name4 = project.offshore_dir_name4 offshore_dir_name5 = project.offshore_dir_name5 offshore_dir_name6 = project.offshore_dir_name6 offshore_dir_name7 = project.offshore_dir_name7 offshore_dir_name8 = project.offshore_dir_name8 offshore_dir_name9 = project.offshore_dir_name9 offshore_dir_name10 = project.offshore_dir_name10 offshore_dir_name11 = project.offshore_dir_name11 offshore_dir_name12 = project.offshore_dir_name12 offshore_dir_name13 = project.offshore_dir_name13 offshore_dir_name14 = project.offshore_dir_name14 # files to be used #file_used = [] # creates DEM from asc data convert_dem_from_ascii2netcdf(onshore_dir_name, use_cache=True, verbose=True) convert_dem_from_ascii2netcdf(islands_dir_name, use_cache=True, verbose=True) #creates pts file for onshore DEM dem2pts(onshore_dir_name, # easting_min=project.eastingmin, # easting_max=project.eastingmax, # northing_min=project.northingmin, # northing_max= project.northingmax, use_cache=True, verbose=True) #creates pts file for islands DEM dem2pts(islands_dir_name, use_cache=True, verbose=True) print'create G1' G1 = Geospatial_data(file_name = project.onshore_dir_name + '.pts') G2 = Geospatial_data(file_name = project.coast_dir_name + '.xya') G3 = Geospatial_data(file_name = project.islands_dir_name + '.pts') G_off = Geospatial_data(file_name = project.offshore_dir_name + '.xya') G_off1 = Geospatial_data(file_name = project.offshore_dir_name1 + '.xya') G_off2 = Geospatial_data(file_name = project.offshore_dir_name2 + '.xya') G_off3 = Geospatial_data(file_name = project.offshore_dir_name3 + '.xya') G_off4 = Geospatial_data(file_name = project.offshore_dir_name4 + '.xya') G_off5 = Geospatial_data(file_name = project.offshore_dir_name5 + '.xya') G_off6 = Geospatial_data(file_name = project.offshore_dir_name6 + '.xya') G_off7 = Geospatial_data(file_name = project.offshore_dir_name7 + '.xya') G_off8 = Geospatial_data(file_name = project.offshore_dir_name8 + '.xya') G_off9 = Geospatial_data(file_name = project.offshore_dir_name9 + '.xya') G_off10 = Geospatial_data(file_name = project.offshore_dir_name10 + '.xya') G_off11 = Geospatial_data(file_name = project.offshore_dir_name11 + '.xya') G_off12 = Geospatial_data(file_name = project.offshore_dir_name12 + '.xya') G_off13 = Geospatial_data(file_name = project.offshore_dir_name13 + '.xya') G_off14 = Geospatial_data(file_name = project.offshore_dir_name14 + '.xya') print'add G1+G2+G3+all offshore data' G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4 + G_off5 \ + G_off6 + G_off7 + G_off8 + G_off9 + G_off10 + G_off11 + G_off12 \ + G_off13 + G_off14 G.clip(project.bounding_polygon) #FIXME: add a clip function to pts print'export G' G.export_points_file(project.combined_dir_name + '.pts') import sys; sys.exit() #------------------------------------------------------------------------- # Convert URS to SWW file for boundary conditions #------------------------------------------------------------------------- # filenames meshname = project.mesh_name+'.msh' source_dir = project.boundarydir boundary_file = project.boundaryname print 'Available boundary tags', domain.get_boundary_tags() from anuga.shallow_water.data_manager import urs2sww urs2sww(boundary_file, minlat=project.north_boundary, maxlat=project.south_boundary, minlon= project.west_boundary, maxlon=project.east_boundary, verbose='true')