source: anuga_work/production/broome/build_broome.py @ 5162

Last change on this file since 5162 was 5001, checked in by nick, 17 years ago

update broome with new structure

File size: 7.1 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_urs.py
5The output sww file is stored in project_urs.output_time_dir
6
7The scenario is defined by a triangular mesh created from project_urs.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.shallow_water.data_manager import start_screen_catcher, copy_code_files
30from anuga_parallel.parallel_abstraction import get_processor_name
31
32# Application specific imports
33import 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
40copy_code_files(project_urs.output_build_time_dir,__file__, 
41               dirname(project_urs.__file__)+sep+ project_urs.__name__+'.py' )
42
43start_screen_catcher(project_urs.output_build_time_dir)
44
45print '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#-------------------------------------------------------------------------------
54print"project_urs.combined_dir_name",project_urs.combined_dir_name
55
56# topography directory filenames
57onshore_in_dir_name = project_urs.onshore_in_dir_name
58onshore_in_dir_name1 = project_urs.onshore_in_dir_name1
59coast_in_dir_name = project_urs.coast_in_dir_name
60#island_in_dir_name = project_urs.island_in_dir_name
61offshore_in_dir_name = project_urs.offshore_in_dir_name
62offshore_in_dir_name1 = project_urs.offshore_in_dir_name1
63offshore_in_dir_name2 = project_urs.offshore_in_dir_name2
64offshore_in_dir_name3 = project_urs.offshore_in_dir_name3
65
66onshore_dir_name = project_urs.onshore_dir_name
67onshore_dir_name1 = project_urs.onshore_dir_name1
68coast_dir_name = project_urs.coast_dir_name
69#island_dir_name = project_urs.island_dir_name
70offshore_dir_name = project_urs.offshore_dir_name
71offshore_dir_name1 = project_urs.offshore_dir_name1
72offshore_dir_name2 = project_urs.offshore_dir_name2
73offshore_dir_name3 = project_urs.offshore_dir_name3
74
75# creates DEM from asc data
76print "creates DEMs from asc data"
77convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
78convert_dem_from_ascii2netcdf(onshore_in_dir_name1, basename_out=onshore_dir_name1, use_cache=True, verbose=True)
79convert_dem_from_ascii2netcdf(offshore_in_dir_name1, basename_out=offshore_dir_name1, use_cache=True, verbose=True)
80convert_dem_from_ascii2netcdf(offshore_in_dir_name2, basename_out=offshore_dir_name2, use_cache=True, verbose=True)
81convert_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
84print "creates pts file for onshore DEM"
85dem2pts(onshore_dir_name,
86        use_cache=True, 
87        verbose=True)
88dem2pts(onshore_dir_name1, use_cache=True, verbose=True)
89#creates pts file for island DEM
90dem2pts(offshore_dir_name1, use_cache=True, verbose=True)
91dem2pts(offshore_dir_name2, use_cache=True, verbose=True)
92dem2pts(offshore_dir_name3, use_cache=True, verbose=True)
93
94print'create Geospatial data1 objects from topographies',onshore_dir_name + '.pts'
95G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
96print'create Geospatial data1a objects from topographies',onshore_dir_name1 + '.pts'
97G1a = Geospatial_data(file_name = onshore_dir_name1 + '.pts')
98print'create Geospatial data2 objects from coast', coast_in_dir_name + '.txt'
99G2 = 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')
102print'create Geospatial data3 objects from offshore',offshore_in_dir_name + '.txt'
103G_off = Geospatial_data(file_name = offshore_in_dir_name + '.txt')
104print'create Geospatial data4 objects from offshore1',offshore_dir_name1 + '.pts'
105G_off1 = Geospatial_data(file_name = offshore_dir_name1 + '.pts')
106print'create Geospatial data4 objects from offshore2',offshore_dir_name2 + '.pts'
107G_off2 = Geospatial_data(file_name = offshore_dir_name2 + '.pts')
108print'create Geospatial data objects from offshore3',offshore_dir_name3 + '.pts'
109G_off3 = Geospatial_data(file_name = offshore_dir_name3 + '.pts')
110
111print'add all geospatial objects'
112G = G1 + G1a + G2 + G_off + G_off1 + G_off2 + G_off3
113
114print'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
119print'export combined DEM file'
120if access(project_urs.topographies_dir,F_OK) == 0:
121    mkdir (project_urs.topographies_dir)
122print'export',project_urs.combined_dir_name+ '.txt'
123G.export_points_file(project_urs.combined_dir_name+ '.txt')
124
125'''
126print'split'
127G_small, G_other = G.split(.10,verbose=True)
128
129
130print 'export',project_urs.combined_dir_name + '.txt'
131G.export_points_file(project_urs.combined_dir_name + '.txt')
132print 'export', project_urs.combined_small_dir_name + '.txt'
133G_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
138print'export',project_urs.combined_dir_name+ '.txt'
139G_all=Geospatial_data(file_name = project_urs.combined_dir_name+ '.txt')
140print'split'
141G_all_1, G_all_2 = G_all.split(.10)
142print'export 1'
143G_all_1.export_points_file(project_urs.combined_dir_name+'_small' + '.xya')
144print'export 2'
145G_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#-------------------------------------------------------------------------
151print 'starting to create boundary conditions'
152from anuga.shallow_water.data_manager import urs2sww, urs_ungridded2sww
153
154print 'boundaries_in_dir_name',project_urs.boundaries_in_dir_name
155
156urs_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
Note: See TracBrowser for help on using the repository browser.