[5001] | 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_urs.py |
---|
| 5 | The output sww file is stored in project_urs.output_time_dir |
---|
| 6 | |
---|
| 7 | The scenario is defined by a triangular mesh created from project_urs.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 |
---|
| 27 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
| 28 | from anuga.geospatial_data.geospatial_data import * |
---|
| 29 | from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files |
---|
| 30 | from anuga_parallel.parallel_abstraction import get_processor_name |
---|
| 31 | |
---|
| 32 | # Application specific imports |
---|
| 33 | import project_urs # Definition of file names and polygons |
---|
| 34 | |
---|
| 35 | #------------------------------------------------------------------------------ |
---|
| 36 | # Copy scripts to time stamped output directory and capture screen |
---|
| 37 | # output to file |
---|
| 38 | #------------------------------------------------------------------------------ |
---|
| 39 | |
---|
| 40 | copy_code_files(project_urs.output_build_time_dir,__file__, |
---|
| 41 | dirname(project_urs.__file__)+sep+ project_urs.__name__+'.py' ) |
---|
| 42 | |
---|
| 43 | start_screen_catcher(project_urs.output_build_time_dir) |
---|
| 44 | |
---|
| 45 | print 'USER: ', project_urs.user |
---|
| 46 | |
---|
| 47 | #------------------------------------------------------------------------------- |
---|
| 48 | # Preparation of topographic data |
---|
| 49 | # |
---|
| 50 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
| 51 | # Do for coarse and fine data |
---|
| 52 | # Fine pts file to be clipped to area of interest |
---|
| 53 | #------------------------------------------------------------------------------- |
---|
| 54 | print"project_urs.combined_dir_name",project_urs.combined_dir_name |
---|
| 55 | |
---|
| 56 | # topography directory filenames |
---|
| 57 | onshore_in_dir_name = project_urs.onshore_in_dir_name |
---|
| 58 | onshore_in_dir_name1 = project_urs.onshore_in_dir_name1 |
---|
| 59 | coast_in_dir_name = project_urs.coast_in_dir_name |
---|
| 60 | #island_in_dir_name = project_urs.island_in_dir_name |
---|
| 61 | offshore_in_dir_name = project_urs.offshore_in_dir_name |
---|
| 62 | offshore_in_dir_name1 = project_urs.offshore_in_dir_name1 |
---|
| 63 | offshore_in_dir_name2 = project_urs.offshore_in_dir_name2 |
---|
| 64 | offshore_in_dir_name3 = project_urs.offshore_in_dir_name3 |
---|
| 65 | |
---|
| 66 | onshore_dir_name = project_urs.onshore_dir_name |
---|
| 67 | onshore_dir_name1 = project_urs.onshore_dir_name1 |
---|
| 68 | coast_dir_name = project_urs.coast_dir_name |
---|
| 69 | #island_dir_name = project_urs.island_dir_name |
---|
| 70 | offshore_dir_name = project_urs.offshore_dir_name |
---|
| 71 | offshore_dir_name1 = project_urs.offshore_dir_name1 |
---|
| 72 | offshore_dir_name2 = project_urs.offshore_dir_name2 |
---|
| 73 | offshore_dir_name3 = project_urs.offshore_dir_name3 |
---|
| 74 | |
---|
| 75 | # creates DEM from asc data |
---|
| 76 | print "creates DEMs from asc data" |
---|
| 77 | convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True) |
---|
| 78 | convert_dem_from_ascii2netcdf(onshore_in_dir_name1, basename_out=onshore_dir_name1, use_cache=True, verbose=True) |
---|
| 79 | convert_dem_from_ascii2netcdf(offshore_in_dir_name1, basename_out=offshore_dir_name1, use_cache=True, verbose=True) |
---|
| 80 | convert_dem_from_ascii2netcdf(offshore_in_dir_name2, basename_out=offshore_dir_name2, use_cache=True, verbose=True) |
---|
| 81 | convert_dem_from_ascii2netcdf(offshore_in_dir_name3, basename_out=offshore_dir_name3, use_cache=True, verbose=True) |
---|
| 82 | |
---|
| 83 | #creates pts file for onshore DEM |
---|
| 84 | print "creates pts file for onshore DEM" |
---|
| 85 | dem2pts(onshore_dir_name, |
---|
| 86 | use_cache=True, |
---|
| 87 | verbose=True) |
---|
| 88 | dem2pts(onshore_dir_name1, use_cache=True, verbose=True) |
---|
| 89 | #creates pts file for island DEM |
---|
| 90 | dem2pts(offshore_dir_name1, use_cache=True, verbose=True) |
---|
| 91 | dem2pts(offshore_dir_name2, use_cache=True, verbose=True) |
---|
| 92 | dem2pts(offshore_dir_name3, use_cache=True, verbose=True) |
---|
| 93 | |
---|
| 94 | print'create Geospatial data1 objects from topographies',onshore_dir_name + '.pts' |
---|
| 95 | G1 = Geospatial_data(file_name = onshore_dir_name + '.pts') |
---|
| 96 | print'create Geospatial data1a objects from topographies',onshore_dir_name1 + '.pts' |
---|
| 97 | G1a = Geospatial_data(file_name = onshore_dir_name1 + '.pts') |
---|
| 98 | print'create Geospatial data2 objects from coast', coast_in_dir_name + '.txt' |
---|
| 99 | G2 = Geospatial_data(file_name = coast_in_dir_name + '.txt') |
---|
| 100 | #print'create Geospatial data3 objects from island' |
---|
| 101 | #G3 = Geospatial_data(file_name = island_dir_name + '.pts') |
---|
| 102 | print'create Geospatial data3 objects from offshore',offshore_in_dir_name + '.txt' |
---|
| 103 | G_off = Geospatial_data(file_name = offshore_in_dir_name + '.txt') |
---|
| 104 | print'create Geospatial data4 objects from offshore1',offshore_dir_name1 + '.pts' |
---|
| 105 | G_off1 = Geospatial_data(file_name = offshore_dir_name1 + '.pts') |
---|
| 106 | print'create Geospatial data4 objects from offshore2',offshore_dir_name2 + '.pts' |
---|
| 107 | G_off2 = Geospatial_data(file_name = offshore_dir_name2 + '.pts') |
---|
| 108 | print'create Geospatial data objects from offshore3',offshore_dir_name3 + '.pts' |
---|
| 109 | G_off3 = Geospatial_data(file_name = offshore_dir_name3 + '.pts') |
---|
| 110 | |
---|
| 111 | print'add all geospatial objects' |
---|
| 112 | G = G1 + G1a + G2 + G_off + G_off1 + G_off2 + G_off3 |
---|
| 113 | |
---|
| 114 | print'clip combined geospatial object by bounding polygon' |
---|
| 115 | #G_clipped = G.clip(project_urs.poly_all) |
---|
| 116 | #FIXME: add a clip function to pts |
---|
| 117 | #print'shape of clipped data', G_clipped.get_data_points().shape |
---|
| 118 | |
---|
| 119 | print'export combined DEM file' |
---|
| 120 | if access(project_urs.topographies_dir,F_OK) == 0: |
---|
| 121 | mkdir (project_urs.topographies_dir) |
---|
| 122 | print'export',project_urs.combined_dir_name+ '.txt' |
---|
| 123 | G.export_points_file(project_urs.combined_dir_name+ '.txt') |
---|
| 124 | |
---|
| 125 | ''' |
---|
| 126 | print'split' |
---|
| 127 | G_small, G_other = G.split(.10,verbose=True) |
---|
| 128 | |
---|
| 129 | |
---|
| 130 | print 'export',project_urs.combined_dir_name + '.txt' |
---|
| 131 | G.export_points_file(project_urs.combined_dir_name + '.txt') |
---|
| 132 | print 'export', project_urs.combined_small_dir_name + '.txt' |
---|
| 133 | G_small.export_points_file(project_urs.combined_small_dir_name + '.txt') |
---|
| 134 | #G_clipped.export_points_file(project_urs.combined_dir_name + '.xya') |
---|
| 135 | |
---|
| 136 | |
---|
| 137 | |
---|
| 138 | print'export',project_urs.combined_dir_name+ '.txt' |
---|
| 139 | G_all=Geospatial_data(file_name = project_urs.combined_dir_name+ '.txt') |
---|
| 140 | print'split' |
---|
| 141 | G_all_1, G_all_2 = G_all.split(.10) |
---|
| 142 | print'export 1' |
---|
| 143 | G_all_1.export_points_file(project_urs.combined_dir_name+'_small' + '.xya') |
---|
| 144 | print'export 2' |
---|
| 145 | G_all_2.export_points_file(project_urs.combined_dir_name+'_other1' + '.xya') |
---|
| 146 | |
---|
| 147 | |
---|
| 148 | #------------------------------------------------------------------------- |
---|
| 149 | # Convert URS to SWW file for boundary conditions |
---|
| 150 | #------------------------------------------------------------------------- |
---|
| 151 | print 'starting to create boundary conditions' |
---|
| 152 | from anuga.shallow_water.data_manager import urs2sww, urs_ungridded2sww |
---|
| 153 | |
---|
| 154 | print 'boundaries_in_dir_name',project_urs.boundaries_in_dir_name |
---|
| 155 | |
---|
| 156 | urs_ungridded2sww(project_urs.boundaries_in_dir_name, project_urs.boundaries_in_dir_name, |
---|
| 157 | verbose=True, mint=4000, maxt=35000, zscale=1) |
---|
| 158 | |
---|
| 159 | |
---|
| 160 | ''' |
---|
| 161 | |
---|
| 162 | |
---|
| 163 | |
---|