""" Script for building the elevation data to run a tsunami inundation scenario for busselton, WA, Australia. Input: elevation data from project.py Output: pts file stored in project.topographies_dir The run_busselton.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 coast_in_dir_name1 = project.coast_in_dir_name1 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 offshore_in_dir_name4 = project.offshore_in_dir_name4 offshore_in_dir_name5 = project.offshore_in_dir_name5 offshore_in_dir_name6 = project.offshore_in_dir_name6 offshore_in_dir_name7 = project.offshore_in_dir_name7 # output elevation directory filenames onshore_dir_name = project.onshore_dir_name coast_dir_name = project.coast_dir_name coast_dir_name1 = project.coast_dir_name1 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 # 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(offshore_in_dir_name7, basename_out=offshore_dir_name7, 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) dem2pts(offshore_dir_name7 ,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') # create coastal and offshore pts files print'create Geospatial data2 objects from topographies' G2 = Geospatial_data(file_name = coast_in_dir_name) print'create Geospatial data3 objects from topographies' G3 = Geospatial_data(file_name = coast_in_dir_name1) print'create Geospatial data4 objects from topographies' G_off = Geospatial_data(file_name = offshore_in_dir_name) print'create Geospatial data5 objects from topographies' G_off1 = Geospatial_data(file_name = offshore_in_dir_name1) print'create Geospatial data6 objects from topographies' G_off2 = Geospatial_data(file_name = offshore_in_dir_name2) print'create Geospatial data7 objects from topographies' G_off3 = Geospatial_data(file_name = offshore_in_dir_name3) print'create Geospatial data8 objects from topographies' G_off4 = Geospatial_data(file_name = offshore_in_dir_name4) print'create Geospatial data9 objects from topographies' G_off5 = Geospatial_data(file_name = offshore_in_dir_name5) print'create Geospatial data9 objects from topographies' G_off6 = Geospatial_data(file_name = offshore_in_dir_name6) print'create Geospatial data9 objects from topographies' G_off7 = Geospatial_data(file_name = offshore_dir_name7 + '.pts') #------------------------------------------------------------------------------- # Combine, clip and export dataset #------------------------------------------------------------------------------- print'add all geospatial objects' G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4 print'clip combined geospatial object by bounding polygon' G_clip = G.clip_outside(project.poly_aoi1) G_all = G_clip + G_off5 + G_off6 + G_off7 G_clipped = G_all.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