source: anuga_work/production/tonga/build_tonga.py @ 5212

Last change on this file since 5212 was 5194, checked in by herve, 16 years ago

run scripts for tonga

File size: 6.0 KB
Line 
1"""Script for running tsunami inundation scenario for Perth, 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
27#from anuga.shallow_water import Dirichlet_boundary
28#from anuga.shallow_water import File_boundary
29#from anuga.shallow_water import Reflective_boundary
30from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
31#from anuga.pmesh.mesh_interface import create_mesh_from_regions
32from anuga.geospatial_data.geospatial_data import *
33from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files
34
35# Application specific imports
36import project   # Definition of file names and polygons
37
38#------------------------------------------------------------------------------
39# Copy scripts to time stamped output directory and capture screen
40# output to file
41#------------------------------------------------------------------------------
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_dir_name = project.onshore_dir_name
61#island_in_dir_name = project_urs.island_in_dir_name
62Multibeam_dir_name = project.Multibeam_dir_name
63Singlebeam_dir_name = project.Singlebeam_dir_name
64Chart_dir_name = project.Chart_dir_name
65Derived_bath_dir_name = project.Derived_bath_dir_name
66added_data_dir_name =project.added_data_dir_name
67
68
69print'create Geospatial data1 objects from topographies',onshore_dir_name + '.txt'
70G1 = Geospatial_data(file_name = onshore_dir_name + '.txt')
71print'create Geospatial data2 objects from multibeam', Multibeam_dir_name + '.txt'
72G_off = Geospatial_data(file_name = Multibeam_dir_name + '.txt')
73#print'create Geospatial data3 objects from island'
74#G3 = Geospatial_data(file_name = island_dir_name + '.pts')
75print'create Geospatial data3 objects from singlebeam',Singlebeam_dir_name + '.txt'
76G_off1 = Geospatial_data(file_name = Singlebeam_dir_name + '.txt')
77print'create Geospatial data4 objects from chart',Chart_dir_name + '.txt'
78G_off2 = Geospatial_data(file_name = Chart_dir_name + '.txt')
79print'create Geospatial data4 objects from derived bathymetry',Derived_bath_dir_name + '.txt'
80G_off3 = Geospatial_data(file_name = Derived_bath_dir_name + '.txt')
81print'create Geospatial data objects from added data',added_data_dir_name + '.txt'
82G_off4 = Geospatial_data(file_name = added_data_dir_name + '.txt')
83
84print'add all geospatial objects'
85G = G1 + G_off + G_off1 + G_off2 + G_off3+ G_off4
86
87print'clip combined geospatial object by bounding polygon'
88#G_clipped = G.clip(project_urs.poly_all)
89#FIXME: add a clip function to pts
90#print'shape of clipped data', G_clipped.get_data_points().shape
91
92print'export combined DEM file'
93if access(project.topographies_dir,F_OK) == 0:
94    mkdir (project.topographies_dir)
95print'export',project.combined_dir_name+ '.txt'
96G.export_points_file(project.combined_dir_name+ '.txt')
97
98
99
100'''
101print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya'
102G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya')
103print'split'
104G_all_1, G_all_2 = G_all.split(.10)
105print'export 1'
106G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya')
107print'export 2'
108G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya')
109
110
111#-------------------------------------------------------------------------
112# Convert URS to SWW file for boundary conditions
113#-------------------------------------------------------------------------
114print 'starting to create boundary conditions'
115boundaries_in_dir_name = project.boundaries_in_dir_name
116
117from anuga.shallow_water.data_manager import urs2sww
118
119print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
120print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
121
122#import sys; sys.exit()
123
124#if access(project.boundaries_dir,F_OK) == 0:
125#    mkdir (project.boundaries_dir)
126
127from caching import cache
128cache(urs2sww,
129      (boundaries_in_dir_name,
130       project.boundaries_dir_name1),
131      {'verbose': True,
132       'minlat': project.south_boundary,
133       'maxlat': project.north_boundary,
134       'minlon': project.west_boundary,
135       'maxlon': project.east_boundary,
136#       'minlat': project.south,
137#       'maxlat': project.north,
138#       'minlon': project.west,
139#       'maxlon': project.east,
140       'mint': 0, 'maxt': 40000,
141#       'origin': domain.geo_reference.get_origin(),
142       'mean_stage': project.tide,
143#       'zscale': 1,                 #Enhance tsunami
144       'fail_on_NaN': False},
145       verbose = True,
146       )
147#       dependencies = source_dir + project.boundary_basename + '.sww')
148
149'''
150
151
152
153
154
155
156
Note: See TracBrowser for help on using the repository browser.