1 | """Script for running tsunami inundation scenario for Onslow, WA, Australia. |
---|
2 | |
---|
3 | Source data such as elevation and boundary data is assumed to be available in |
---|
4 | directories specified by project_grad_urs.py |
---|
5 | The output sww file is stored in project_grad.output_time_dir |
---|
6 | |
---|
7 | The scenario is defined by a triangular mesh created from project_grad_urs.polygon, |
---|
8 | the elevation data and a simulated tsunamigenic earthquake. |
---|
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 import Dirichlet_boundary |
---|
28 | from anuga.shallow_water import File_boundary |
---|
29 | from anuga.shallow_water import Reflective_boundary |
---|
30 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf |
---|
31 | from anuga.shallow_water.data_manager import dem2pts |
---|
32 | from anuga.pmesh.mesh_interface import create_mesh_from_regions |
---|
33 | from anuga.geospatial_data.geospatial_data import Geospatial_data |
---|
34 | from anuga.shallow_water.data_manager import start_screen_catcher |
---|
35 | from anuga.shallow_water.data_manager import copy_code_files |
---|
36 | from anuga.shallow_water.data_manager import urs_ungridded2sww |
---|
37 | from anuga_parallel.parallel_abstraction import get_processor_name |
---|
38 | |
---|
39 | # Application specific imports |
---|
40 | import project_grad # Definition of file names and polygons |
---|
41 | |
---|
42 | |
---|
43 | #------------------------------------------------------------------------------ |
---|
44 | # Copy scripts to time stamped output directory and capture screen |
---|
45 | # output to file |
---|
46 | #------------------------------------------------------------------------------ |
---|
47 | |
---|
48 | copy_code_files(project_grad.output_build_time_dir,__file__, |
---|
49 | dirname(project_grad.__file__)+sep+ project_grad.__name__+'.py' )# |
---|
50 | |
---|
51 | start_screen_catcher(project_grad.output_build_time_dir) |
---|
52 | |
---|
53 | print 'Processor Name:', get_processor_name() |
---|
54 | print 'User: ', project_grad.user |
---|
55 | |
---|
56 | |
---|
57 | #------------------------------------------------------------------------------- |
---|
58 | # Preparation of topographic data |
---|
59 | # |
---|
60 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
61 | # Do for coarse and fine data |
---|
62 | # Fine pts file to be clipped to area of interest |
---|
63 | #------------------------------------------------------------------------------- |
---|
64 | |
---|
65 | print 'project_grad.combined_dir_name', project_grad.combined_dir_name |
---|
66 | |
---|
67 | |
---|
68 | geospatial_data = None |
---|
69 | # create DEMs from asc data |
---|
70 | |
---|
71 | # FIXME (Ole): Clip data by interior regions if possible |
---|
72 | |
---|
73 | print 'creating geospatial data objects from asc data (via dem and pts formats)' |
---|
74 | for filename in project_grad.ascii_grid_filenames: |
---|
75 | convert_dem_from_ascii2netcdf(filename, |
---|
76 | basename_out=filename, |
---|
77 | use_cache=True, verbose=True) |
---|
78 | dem2pts(filename, use_cache=True, verbose=True) |
---|
79 | |
---|
80 | geospatial_data += Geospatial_data(file_name=filename + '.pts', |
---|
81 | verbose=True) |
---|
82 | |
---|
83 | |
---|
84 | print 'creating geospatial data objects from txt data' |
---|
85 | for filename in project_grad.point_filenames: |
---|
86 | geospatial_data += Geospatial_data(file_name=filename + '.txt', |
---|
87 | verbose=True) |
---|
88 | |
---|
89 | |
---|
90 | print 'clip combined geospatial object by bounding polygon' |
---|
91 | G = geospatial_data.clip(project_grad.bounding_polygon) |
---|
92 | |
---|
93 | |
---|
94 | print 'export combined geospatial data' |
---|
95 | if access(project_grad.topographies_dir, F_OK) == 0: |
---|
96 | mkdir (project_grad.topographies_dir) |
---|
97 | G.export_points_file(project_grad.combined_dir_name + '.pts') |
---|
98 | |
---|
99 | #------------------------------------------------------------------------- |
---|
100 | # Convert URS to SWW file for boundary conditions |
---|
101 | #------------------------------------------------------------------------- |
---|
102 | print 'converting boundary conditions to sww format' |
---|
103 | |
---|
104 | print 'boundary_dir', project_grad.boundaries_in_dir |
---|
105 | |
---|
106 | maxt = 40000 |
---|
107 | urs_ungridded2sww(project_grad.boundaries_in_dir+sep+project_grad.boundaries_name, |
---|
108 | project_grad.boundaries_in_dir+sep+project_grad.boundaries_name+'_'+ str(maxt), |
---|
109 | verbose=True, |
---|
110 | mint=0, maxt=maxt, zscale=1) |
---|
111 | |
---|
112 | print 'Finished building the %s scenario' %project_grad.scenario_name |
---|
113 | |
---|
114 | |
---|