"""Script for running tsunami inundation scenario for Perth, 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 * from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files # Application specific imports import project_fangauta # Definition of file names and polygons #------------------------------------------------------------------------------ # Copy scripts to time stamped output directory and capture screen # output to file #------------------------------------------------------------------------------ copy_code_files(project_fangauta.output_build_time_dir,__file__, dirname(project_fangauta.__file__)+sep+ project_fangauta.__name__+'.py' ) start_screen_catcher(project_fangauta.output_build_time_dir) print 'USER: ', project_fangauta.user #------------------------------------------------------------------------------- # 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 #------------------------------------------------------------------------------- print"project.combined_dir_name",project_fangauta.combined_dir_name # topography directory filenames onshore_dir_name = project_fangauta.onshore_dir_name onshore_dir_name1 = project_fangauta.onshore_dir_name1 #island_in_dir_name = project_urs.island_in_dir_name #Multibeam_dir_name = project.Multibeam_dir_name Singlebeam_dir_name = project_fangauta.Singlebeam_dir_name addedpoint_dir_name = project_fangauta.addedpoint_dir_name #Chart_dir_name = project.Chart_dir_name #Derived_bath_dir_name = project.Derived_bath_dir_name #added_data_dir_name =project.added_data_dir_name print'create Geospatial data1 objects from topographies',onshore_dir_name + '.txt' G1 = Geospatial_data(file_name = onshore_dir_name + '.txt') #print'create Geospatial data2 objects from multibeam', Multibeam_dir_name + '.txt' #G_off = Geospatial_data(file_name = Multibeam_dir_name + '.txt') #print'create Geospatial data3 objects from island' #G3 = Geospatial_data(file_name = island_dir_name + '.pts') print'create Geospatial data3 objects from singlebeam',Singlebeam_dir_name + '.txt' G_off1 = Geospatial_data(file_name = Singlebeam_dir_name + '.txt') print'create Geospatial data1 objects from topographies',addedpoint_dir_name + '.txt' G2 = Geospatial_data(file_name = addedpoint_dir_name + '.txt') print'create Geospatial data1 objects from topographies',onshore_dir_name1 + '.txt' Goff2=Geospatial_data(file_name = onshore_dir_name1 + '.txt') #print'create Geospatial data4 objects from chart',Chart_dir_name + '.txt' #G_off2 = Geospatial_data(file_name = Chart_dir_name + '.txt') #print'create Geospatial data4 objects from derived bathymetry',Derived_bath_dir_name + '.txt' #G_off3 = Geospatial_data(file_name = Derived_bath_dir_name + '.txt') #print'create Geospatial data objects from added data',added_data_dir_name + '.txt' #G_off4 = Geospatial_data(file_name = added_data_dir_name + '.txt') Gislands=Goff2.clip(Geospatial_data(project_fangauta.poly_island_Pea))+Goff2.clip(Geospatial_data(project_fangauta.poly_island_Mua)) print'add all geospatial objects' G = G1 + G_off1+G2+Gislands #print'clip combined geospatial object by bounding polygon' #G_clipped = G.clip(project_urs.poly_all) #FIXME: add a clip function to pts #print'shape of clipped data', G_clipped.get_data_points().shape print'export combined DEM file' if access(project_fangauta.topographies_dir,F_OK) == 0: mkdir (project_fangauta.topographies_dir) print'export',project_fangauta.combined_dir_name+ '.txt' G.export_points_file(project_fangauta.combined_dir_name+ '.txt') ''' print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya' G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya') print'split' G_all_1, G_all_2 = G_all.split(.10) print'export 1' G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya') print'export 2' G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya') #------------------------------------------------------------------------- # Convert URS to SWW file for boundary conditions #------------------------------------------------------------------------- print 'starting to create boundary conditions' boundaries_in_dir_name = project.boundaries_in_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() #if access(project.boundaries_dir,F_OK) == 0: # mkdir (project.boundaries_dir) from caching import cache cache(urs2sww, (boundaries_in_dir_name, project.boundaries_dir_name1), {'verbose': True, 'minlat': project.south_boundary, 'maxlat': project.north_boundary, 'minlon': project.west_boundary, 'maxlon': project.east_boundary, # 'minlat': project.south, # 'maxlat': project.north, # 'minlon': project.west, # 'maxlon': project.east, 'mint': 0, 'maxt': 40000, # 'origin': domain.geo_reference.get_origin(), 'mean_stage': project.tide, # 'zscale': 1, #Enhance tsunami 'fail_on_NaN': False}, verbose = True, ) # dependencies = source_dir + project.boundary_basename + '.sww') '''