source: anuga_work/production/broome_2006/build_broome.py @ 4228

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

update to broome

File size: 6.0 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# Related major packages
26from anuga.shallow_water import Domain
27from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
28from anuga.geospatial_data.geospatial_data import *
29from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files
30
31# Application specific imports
32import 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
39copy_code_files(project.output_build_time_dir,__file__, 
40               dirname(project.__file__)+sep+ project.__name__+'.py' )
41
42start_screen_catcher(project.output_build_time_dir)
43
44print 'USER:    ', project.user
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#-------------------------------------------------------------------------------
53print"project.bounding_polygon",project.bounding_polygon
54print"project.combined_dir_name",project.combined_dir_name
55
56# topography directory filenames
57onshore_in_dir_name = project.onshore_in_dir_name
58coast_in_dir_name = project.coast_in_dir_name
59island_in_dir_name = project.island_in_dir_name
60island_in_dir_name1 = project.island_in_dir_name1
61island_in_dir_name2 = project.island_in_dir_name2
62island_in_dir_name3 = project.island_in_dir_name3
63offshore_in_dir_name = project.offshore_in_dir_name
64offshore1_in_dir_name = project.offshore1_in_dir_name
65
66onshore_dir_name = project.onshore_dir_name
67coast_dir_name = project.coast_dir_name
68island_dir_name = project.island_dir_name
69island_dir_name1 = project.island_dir_name1
70island_dir_name2 = project.island_dir_name2
71island_dir_name3 = project.island_dir_name3
72offshore_dir_name = project.offshore_dir_name
73
74# creates DEM from asc data
75print "creates DEMs from asc data"
76convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
77convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True)
78convert_dem_from_ascii2netcdf(island_in_dir_name1, basename_out=island_dir_name1, use_cache=True, verbose=True)
79convert_dem_from_ascii2netcdf(island_in_dir_name2, basename_out=island_dir_name2, use_cache=True, verbose=True)
80convert_dem_from_ascii2netcdf(island_in_dir_name3, basename_out=island_dir_name3, use_cache=True, verbose=True)
81
82#creates pts file for onshore DEM
83print "creates pts file for onshore DEM"
84dem2pts(onshore_dir_name,
85        use_cache=True, 
86        verbose=True)
87
88#creates pts file for island DEM
89dem2pts(island_dir_name, use_cache=True, verbose=True)
90dem2pts(island_dir_name1, use_cache=True, verbose=True)
91dem2pts(island_dir_name2, use_cache=True, verbose=True)
92dem2pts(island_dir_name3, use_cache=True, verbose=True)
93
94print'create Geospatial data1 objects from topographies'
95G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
96print'create Geospatial data2 objects from topographies'
97G2 = Geospatial_data(file_name = coast_in_dir_name + '.xya')
98print'create Geospatial data3 objects from topographies'
99G3 = Geospatial_data(file_name = island_dir_name + '.pts')
100print'create Geospatial data4 objects from topographies'
101G4 = Geospatial_data(file_name = island_dir_name1 + '.pts')
102print'create Geospatial data5 objects from topographies'
103G5 = Geospatial_data(file_name = island_dir_name2 + '.pts')
104print'create Geospatial data6 objects from topographies'
105G6 = Geospatial_data(file_name = island_dir_name3 + '.pts')
106print'create Geospatial data7 objects from topographies'
107G_off = Geospatial_data(file_name = offshore_in_dir_name + '.xya')
108print'create Geospatial data8 objects from topographies'
109G_off1 = Geospatial_data(file_name = offshore1_in_dir_name + '.xya')
110
111print'add all geospatial objects'
112G = G1 + G2 + G3 + G4 + G5 + G6 + G_off + G_off1
113
114print'clip combined geospatial object by bounding polygon'
115G_clipped = G.clip(project.bounding_polygon)
116#FIXME: add a clip function to pts
117#print'shape of clipped data', G_clipped.get_data_points().shape
118
119print'export combined DEM file'
120if access(project.topographies_dir,F_OK) == 0:
121    mkdir (project.topographies_dir)
122G_clipped.export_points_file(project.combined_dir_name + '.txt')
123#G_clipped.export_points_file(project.combined_dir_name + '.xya')
124
125'''
126print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya'
127G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya')
128print'split'
129G_all_1, G_all_2 = G_all.split(.10)
130print'export 1'
131G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya')
132print'export 2'
133G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya')
134
135
136#-------------------------------------------------------------------------
137# Convert URS to SWW file for boundary conditions
138#-------------------------------------------------------------------------
139'''
140
141
142
143
144
145
146
Note: See TracBrowser for help on using the repository browser.