[5005] | 1 | """Script for running tsunami inundation scenario for Dampier, WA, Australia. |
---|
| 2 | |
---|
| 3 | Source data such as elevation and boundary data is assumed to be available in |
---|
| 4 | directories specified by project.py |
---|
| 5 | The output sww file is stored in project.output_time_dir |
---|
| 6 | |
---|
| 7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
| 8 | the elevation data and a simulated submarine landslide. |
---|
| 9 | |
---|
| 10 | Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006 |
---|
| 11 | """ |
---|
| 12 | |
---|
| 13 | #------------------------------------------------------------------------------ |
---|
| 14 | # Import necessary modules |
---|
| 15 | #------------------------------------------------------------------------------ |
---|
| 16 | |
---|
| 17 | # Standard modules |
---|
| 18 | from os import sep |
---|
| 19 | from os.path import dirname, basename |
---|
| 20 | from os import mkdir, access, F_OK |
---|
| 21 | from shutil import copy |
---|
| 22 | import time |
---|
| 23 | import sys |
---|
| 24 | |
---|
| 25 | # Related major packages |
---|
| 26 | from anuga.shallow_water import Domain |
---|
[5012] | 27 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts,start_screen_catcher, copy_code_files |
---|
[5005] | 28 | from anuga.geospatial_data.geospatial_data import * |
---|
[5652] | 29 | from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files |
---|
[5005] | 30 | |
---|
| 31 | # Application specific imports |
---|
| 32 | import project # Definition of file names and polygons |
---|
| 33 | |
---|
| 34 | #------------------------------------------------------------------------------ |
---|
| 35 | # Copy scripts to time stamped output directory and capture screen |
---|
| 36 | # output to file |
---|
| 37 | #------------------------------------------------------------------------------ |
---|
| 38 | |
---|
| 39 | copy_code_files(project.output_build_time_dir,__file__, |
---|
| 40 | dirname(project.__file__)+sep+ project.__name__+'.py' ) |
---|
| 41 | |
---|
[5012] | 42 | start_screen_catcher(project.output_build_time_dir) |
---|
[5005] | 43 | |
---|
[5150] | 44 | print 'USER: ', project.user, project.host |
---|
[5005] | 45 | |
---|
| 46 | #------------------------------------------------------------------------------- |
---|
| 47 | # Preparation of topographic data |
---|
| 48 | # |
---|
| 49 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
| 50 | # Do for coarse and fine data |
---|
| 51 | # Fine pts file to be clipped to area of interest |
---|
| 52 | #------------------------------------------------------------------------------- |
---|
| 53 | |
---|
| 54 | # topography directory filenames |
---|
| 55 | onshore_in_dir_name = project.onshore_in_dir_name |
---|
| 56 | coast_in_dir_name = project.coast_in_dir_name |
---|
[5012] | 57 | island_in_dir_name = project.island_in_dir_name |
---|
[5005] | 58 | offshore_in_dir_name = project.offshore_in_dir_name |
---|
[5652] | 59 | offshore_in_dir_name1 = project.offshore_in_dir_name1 |
---|
| 60 | offshore_in_dir_name2 = project.offshore_in_dir_name2 |
---|
| 61 | offshore_in_dir_name3 = project.offshore_in_dir_name3 |
---|
[5005] | 62 | |
---|
| 63 | onshore_dir_name = project.onshore_dir_name |
---|
| 64 | coast_dir_name = project.coast_dir_name |
---|
[5012] | 65 | island_dir_name = project.island_dir_name |
---|
[5005] | 66 | offshore_dir_name = project.offshore_dir_name |
---|
[5652] | 67 | offshore_dir_name1 = project.offshore_dir_name1 |
---|
| 68 | offshore_dir_name2 = project.offshore_dir_name2 |
---|
| 69 | offshore_dir_name3 = project.offshore_dir_name3 |
---|
[5005] | 70 | |
---|
| 71 | # creates DEM from asc data |
---|
| 72 | print "creates DEMs from ascii data" |
---|
| 73 | convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True) |
---|
[5012] | 74 | convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True) |
---|
[5005] | 75 | |
---|
| 76 | #creates pts file for onshore DEM |
---|
[5652] | 77 | dem2pts(onshore_dir_name, use_cache=True, verbose=True) |
---|
[5005] | 78 | |
---|
| 79 | #creates pts file for island DEM |
---|
[5012] | 80 | dem2pts(island_dir_name, use_cache=True, verbose=True) |
---|
[5005] | 81 | |
---|
| 82 | print'create Geospatial data1 objects from topographies' |
---|
[5150] | 83 | G1 = Geospatial_data(file_name = onshore_dir_name + '.pts',verbose=True) |
---|
| 84 | G2 = Geospatial_data(file_name = coast_in_dir_name + '.txt',verbose=True) |
---|
| 85 | G3 = Geospatial_data(file_name = island_dir_name + '.pts',verbose=True) |
---|
[5652] | 86 | print'create Geospatial data1 objects from bathymetry' |
---|
| 87 | G_off = Geospatial_data(file_name = offshore_in_dir_name + '.txt',verbose=True) |
---|
| 88 | G_off1 = Geospatial_data(file_name = offshore_in_dir_name1 + '.txt',verbose=True) |
---|
| 89 | G_off2 = Geospatial_data(file_name = offshore_in_dir_name2 + '.txt',verbose=True) |
---|
| 90 | G_off3 = Geospatial_data(file_name = offshore_in_dir_name3 + '.txt',verbose=True) |
---|
[5012] | 91 | print'finished reading in files' |
---|
[5005] | 92 | |
---|
[5652] | 93 | print'add all geospatial objects' |
---|
| 94 | G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4 |
---|
[5012] | 95 | |
---|
[5652] | 96 | print'clip combined geospatial object by bounding polygon' |
---|
[5150] | 97 | G_clip = G.clip(project.poly_all, verbose=True) |
---|
[5012] | 98 | |
---|
[5005] | 99 | print'export combined DEM file' |
---|
| 100 | if access(project.topographies_dir,F_OK) == 0: |
---|
| 101 | mkdir (project.topographies_dir) |
---|
[5652] | 102 | G_clip.export_points_file(project.combined_dir_name + '.pts') |
---|
[5005] | 103 | |
---|
[5652] | 104 | import sys |
---|
| 105 | sys.exit() |
---|
[5005] | 106 | |
---|
| 107 | |
---|
| 108 | |
---|
| 109 | |
---|
| 110 | |
---|
| 111 | |
---|