""" Script for building the elevation data to run a tsunami inundation scenario for geraldton, WA, Australia. Input: elevation data from project.py Output: pts file stored in project.topographies_dir The run_geraldton.py is reliant on the output of this script. """ #------------------------------------------------------------------------------ # 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.data_manager import convert_dem_from_ascii2netcdf, dem2pts 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 # Definition of file names and polygons #------------------------------------------------------------------------------ # Copy scripts to time stamped output directory and capture screen # output to file #------------------------------------------------------------------------------ copy_code_files(project.output_build_time_dir,__file__, dirname(project.__file__)+sep+ project.__name__+'.py' ) start_screen_catcher(project.output_build_time_dir) print 'USER: ', project.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.poly_all", project.poly_all print "project.combined_dir_name", project.combined_dir_name # input elevation directory filenames onshore_in_dir_name = project.onshore_in_dir_name coast_in_dir_name = project.coast_in_dir_name island_in_dir_name = project.island_in_dir_name offshore_in_dir_name = project.offshore_in_dir_name offshore_in_dir_name1 = project.offshore_in_dir_name1 offshore_in_dir_name2 = project.offshore_in_dir_name2 offshore_in_dir_name3 = project.offshore_in_dir_name3 # output elevation directory filenames onshore_dir_name = project.onshore_dir_name coast_dir_name = project.coast_dir_name island_dir_name = project.island_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 # creates DEM from asc data print "creates DEMs from asc data" convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True) convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True) # creates pts file for onshore DEM print "creates pts file for onshore DEM" dem2pts(onshore_dir_name, use_cache=True,verbose=True) # creates pts file for island DEM dem2pts(island_dir_name, use_cache=True, verbose=True) # create onshore pts files print'create Geospatial data1 objects from topographies' G1 = Geospatial_data(file_name = onshore_dir_name + '.pts') print'create Geospatial data2 objects from topographies' G2 = Geospatial_data(file_name = island_dir_name + '.pts') # create coastal and offshore pts files print'create Geospatial data6 objects from topographies' G_coast = Geospatial_data(file_name = coast_in_dir_name) print'create Geospatial data7 objects from topographies' G_off1 = Geospatial_data(file_name = offshore_in_dir_name) print'create Geospatial data8 objects from topographies' G_off2 = Geospatial_data(file_name = offshore_in_dir_name1) print'create Geospatial data9 objects from topographies' G_off3 = Geospatial_data(file_name = offshore_in_dir_name2) print'create Geospatial data10 objects from topographies' G_off4 = Geospatial_data(file_name = offshore_in_dir_name3) #------------------------------------------------------------------------------- # Combine, clip and export dataset #------------------------------------------------------------------------------- print 'clipping port data to area of significance' G_off2_clip = G_off2.clip(project.poly_buffer_20m, verbose=True) print 'add all bathymetry files' G_off = G_off1 + G_off2_clip + G_off3 + G_off4 print 'clipping data to coast' G_off_clip = G_off.clip(project.poly_ocean, verbose=True) G1_clip = G1.clip(project.poly_mainland, verbose=True) print'add all geospatial objects' G = G1_clip + G2 + G_off_clip print'clip combined geospatial object by bounding polygon' G_clipped = G.clip(project.poly_all) print'export combined DEM file' if access(project.topographies_dir,F_OK) == 0: mkdir (project.topographies_dir) G_clipped.export_points_file(project.combined_dir_name + '.pts') #G_clipped.export_points_file(project.combined_dir_name + '.txt') #Use for comparision in ARC