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,urs_ungridded2sww |
---|
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 "Processor Name:",get_processor_name() |
---|
46 | print 'USER: ', project_urs.user |
---|
47 | |
---|
48 | #------------------------------------------------------------------------------- |
---|
49 | # Preparation of topographic data |
---|
50 | # |
---|
51 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
52 | # Do for coarse and fine data |
---|
53 | # Fine pts file to be clipped to area of interest |
---|
54 | #------------------------------------------------------------------------------- |
---|
55 | print"project_urs.combined_dir_name",project_urs.combined_dir_name |
---|
56 | |
---|
57 | # topography directory filenames |
---|
58 | onshore_in_dir_name = project_urs.onshore_in_dir_name |
---|
59 | coast_in_dir_name = project_urs.coast_in_dir_name |
---|
60 | offshore_in_dir_name = project_urs.offshore_in_dir_name |
---|
61 | offshore1_in_dir_name = project_urs.offshore1_in_dir_name |
---|
62 | offshore2_in_dir_name = project_urs.offshore2_in_dir_name |
---|
63 | |
---|
64 | onshore_dir_name = project_urs.onshore_dir_name |
---|
65 | coast_dir_name = project_urs.coast_dir_name |
---|
66 | offshore_dir_name = project_urs.offshore_dir_name |
---|
67 | offshore1_dir_name = project_urs.offshore1_dir_name |
---|
68 | offshore2_dir_name = project_urs.offshore2_dir_name |
---|
69 | ''' |
---|
70 | ## creates DEM from asc data |
---|
71 | #print "creates DEMs from asc data" |
---|
72 | #convert_dem_from_ascii2netcdf(onshore_in_dir_name, |
---|
73 | # basename_out=onshore_dir_name, |
---|
74 | # use_cache=True, verbose=True) |
---|
75 | ##creates pts file for onshore DEM |
---|
76 | #print "creates pts file for onshore DEM" |
---|
77 | #dem2pts(onshore_dir_name, use_cache=True, verbose=True) |
---|
78 | |
---|
79 | print'create Geospatial onshore objects from topographies' |
---|
80 | G = Geospatial_data(file_name = onshore_dir_name + '.pts') +\ |
---|
81 | Geospatial_data(file_name = coast_in_dir_name + '.txt') +\ |
---|
82 | Geospatial_data(file_name = offshore_in_dir_name + '.txt') |
---|
83 | |
---|
84 | |
---|
85 | print'clip combined geospatial object by bounding polygon' |
---|
86 | G_clipped = G.clip(project_urs.poly_all) |
---|
87 | |
---|
88 | print'export combined DEM file' |
---|
89 | if access(project_urs.topographies_dir,F_OK) == 0: |
---|
90 | mkdir (project_urs.topographies_dir) |
---|
91 | G.export_points_file(project_urs.combined_dir_name + '.txt') |
---|
92 | |
---|
93 | print'split combined data set' |
---|
94 | G_small, G_other = G_clipped.split(0.1, True) |
---|
95 | |
---|
96 | print'export split DEM file' |
---|
97 | G_small.export_points_file(project_urs.combined_dir_name + '_small' + '.txt') |
---|
98 | #G_other.export_points_file(project_urs.combined_dir_name + '_other' + '.pts') |
---|
99 | |
---|
100 | ''' |
---|
101 | print 'start reading:',project_urs.combined_dir_name + '.txt' |
---|
102 | G = Geospatial_data(file_name = (project_urs.combined_dir_name + '.txt')) |
---|
103 | print 'start writing',project_urs.combined_dir_name + '.pts' |
---|
104 | G.export_points_file(project_urs.combined_dir_name + '.pts') |
---|
105 | ''' |
---|
106 | G_clipped = G.clip(project_urs.poly_topo_clip) |
---|
107 | |
---|
108 | print 'start split' |
---|
109 | #G_smallest, G_other = G.split(0.1,True) |
---|
110 | |
---|
111 | print 'start export',project_urs.combined_smallest_dir_name + '.txt' |
---|
112 | #G.export_points_file(project_urs.combined_smaller_dir_name + '.txt') |
---|
113 | G_clipped.export_points_file(project_urs.combined_smallest_dir_name + '.txt') |
---|
114 | |
---|
115 | #------------------------------------------------------------------------- |
---|
116 | # Convert URS to SWW file for boundary conditions |
---|
117 | #------------------------------------------------------------------------- |
---|
118 | print 'starting to create boundary conditions' |
---|
119 | |
---|
120 | print 'boundaries_in_dir_name',project_urs.boundaries_in_dir_name |
---|
121 | |
---|
122 | urs_ungridded2sww(project_urs.boundaries_in_dir_name, project_urs.boundaries_in_dir_name, |
---|
123 | verbose=True, mint=5000, maxt=35000, zscale=1) |
---|
124 | |
---|
125 | ''' |
---|
126 | |
---|
127 | |
---|
128 | |
---|