source: anuga_work/production/dampier_2006/build_dampier.py @ 4212

Last change on this file since 4212 was 4212, checked in by nick, 18 years ago

update to dampier

File size: 5.3 KB
Line 
1"""Script for running tsunami inundation scenario for Dampier, WA, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project.py
5The output sww file is stored in project.output_time_dir
6
7The scenario is defined by a triangular mesh created from project.polygon,
8the elevation data and a simulated submarine landslide.
9
10Ole 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
18from os import sep
19from os.path import dirname, basename
20from os import mkdir, access, F_OK
21from shutil import copy
22import time
23import sys
24
25
26# Related major packages
27from anuga.shallow_water import Domain
28from anuga.shallow_water import Dirichlet_boundary
29from anuga.shallow_water import File_boundary
30from anuga.shallow_water import Reflective_boundary
31from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
32from anuga.pmesh.mesh_interface import create_mesh_from_regions
33from anuga.geospatial_data.geospatial_data import *
34from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
35
36# Application specific imports
37import project   # Definition of file names and polygons
38
39#------------------------------------------------------------------------------
40# Copy scripts to time stamped output directory and capture screen
41# output to file
42#------------------------------------------------------------------------------
43copy_code_files(project.output_build_time_dir,__file__, 
44               dirname(project.__file__)+sep+ project.__name__+'.py' )
45
46start_screen_catcher(project.output_build_time_dir)
47
48print 'USER:    ', project.user
49
50#-------------------------------------------------------------------------------
51# Preparation of topographic data
52#
53# Convert ASC 2 DEM 2 PTS using source data and store result in source data
54# Do for coarse and fine data
55# Fine pts file to be clipped to area of interest
56#-------------------------------------------------------------------------------
57print"project.combined_dir_name",project.combined_dir_name
58
59# topography directory filenames
60onshore_in_dir_name = project.onshore_in_dir_name
61coast_in_dir_name = project.coast_in_dir_name
62offshore_in_dir_name = project.offshore_in_dir_name
63offshore1_in_dir_name = project.offshore1_in_dir_name
64offshore2_in_dir_name = project.offshore2_in_dir_name
65
66onshore_dir_name = project.onshore_dir_name
67coast_dir_name = project.coast_dir_name
68offshore_dir_name = project.offshore_dir_name
69offshore1_dir_name = project.offshore1_dir_name
70offshore2_dir_name = project.offshore2_dir_name
71'''
72# creates DEM from asc data
73print "creates DEMs from asc data"
74convert_dem_from_ascii2netcdf(onshore_in_dir_name,
75                              basename_out=onshore_dir_name,
76                              use_cache=True, verbose=True)
77
78convert_dem_from_ascii2netcdf(offshore1_in_dir_name,
79                              basename_out=offshore1_dir_name,
80                              use_cache=True, verbose=True)
81convert_dem_from_ascii2netcdf(offshore2_in_dir_name,
82                              basename_out=offshore2_dir_name,
83                              use_cache=True, verbose=True)
84
85#creates pts file for onshore DEM
86print "creates pts file for onshore DEM"
87dem2pts(onshore_dir_name, use_cache=True, verbose=True)
88
89#creates pts file for clipped DEMs
90dem2pts(offshore1_dir_name,
91        basename_out=offshore1_dir_name,
92        use_cache=True, verbose=True)
93dem2pts(offshore2_dir_name,
94        basename_out=offshore2_dir_name,
95        use_cache=True, verbose=True)
96
97print'create Geospatial onshore objects from topographies'
98#print'create Geospatial coastal objects from topographies'
99#print'create Geospatial nickel bay objects from topographies'
100#print'create Geospatial clipped TIN offshore objects from topographies'
101#print'create Geospatial offshore objects from topographies'
102G = Geospatial_data(file_name = onshore_dir_name + '.pts') +\
103    Geospatial_data(file_name = coast_in_dir_name + '.txt') +\
104    Geospatial_data(file_name = offshore_in_dir_name + '.txt') +\
105    Geospatial_data(file_name = offshore1_dir_name + '.pts') +\
106    Geospatial_data(file_name = offshore2_dir_name + '.pts')
107     
108
109print'add all geospatial objects'
110#G = G1 + G2 + G3 + G4 + G_off
111
112print'clip combined geospatial object by bounding polygon'
113G_clipped = G.clip(project.poly_all)
114#FIXME: add a clip function to pts
115#print'shape of clipped data', G_clipped.get_data_points().shape
116
117print'export combined DEM file'
118if access(project.topographies_dir,F_OK) == 0:
119    mkdir (project.topographies_dir)
120G_clipped.export_points_file(project.combined_dir_name + '.pts')
121#G_clipped.export_points_file(project.combined_dir_name + '.txt')
122
123print'split combined data set'
124G_small, G_other = G_clipped.split(0.1, True)
125
126print'export split DEM file'
127G_small.export_points_file(project.combined_dir_name + '_small' + '.pts')
128G_other.export_points_file(project.combined_dir_name + '_other' + '.pts')
129'''
130print 'start reading:',project.combined_dir_name + '.pts'
131G = Geospatial_data(file_name = project.combined_dir_name + '.pts')
132print 'start export',project.combined_dir_name + '.txt'
133G.export_points_file(project.combined_dir_name + '.txt')
134
135
136
137
138
Note: See TracBrowser for help on using the repository browser.