source: anuga_work/production/perth_2006/build_perth.py @ 4077

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

start perth scenario

File size: 5.9 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
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
31from anuga.pmesh.mesh_interface import create_mesh_from_regions
32from anuga.geospatial_data.geospatial_data import *
33from anuga.abstract_2d_finite_volumes.util 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#-------------------------------------------------------------------------------
57
58
59# topography directory filenames
60onshore_dir_name = project.onshore_dir_name
61coast_dir_name = project.coast_dir_name
62islands_dir_name = project.islands_dir_name
63islands_dir_name1 = project.islands_dir_name1
64islands_dir_name1 = project.islands_dir_name2
65offshore_dir_name = project.offshore_dir_name
66
67# creates DEM from asc data
68convert_dem_from_ascii2netcdf(onshore_dir_name, use_cache=True, verbose=True)
69convert_dem_from_ascii2netcdf(islands_dir_name, use_cache=True, verbose=True)
70convert_dem_from_ascii2netcdf(islands_dir_name1, use_cache=True, verbose=True)
71convert_dem_from_ascii2netcdf(islands_dir_name2, use_cache=True, verbose=True)
72
73#creates pts file for onshore DEM
74dem2pts(onshore_dir_name,
75#        easting_min=project.eastingmin,
76#        easting_max=project.eastingmax,
77#        northing_min=project.northingmin,
78#        northing_max= project.northingmax,
79        use_cache=True, 
80        verbose=True)
81
82#creates pts file for islands DEM
83dem2pts(islands_dir_name, use_cache=True, verbose=True)
84dem2pts(islands_dir_name1, use_cache=True, verbose=True)
85dem2pts(islands_dir_name2, use_cache=True, verbose=True)
86
87print'create Geospatial data objects from topographies'
88G1 = Geospatial_data(file_name = project.onshore_dir_name + '.pts')
89G2 = Geospatial_data(file_name = project.coast_dir_name + '.xya')
90G3 = Geospatial_data(file_name = project.islands_dir_name + '.pts')
91G4 = Geospatial_data(file_name = project.islands_dir_name1 + '.pts')
92G5 = Geospatial_data(file_name = project.islands_dir_name2 + '.pts')
93G_off = Geospatial_data(file_name = project.offshore_dir_name + '.xya')
94
95
96
97
98
99print 'G_offshore_data_old_e'#, G_offshore_old_e.get_data_points()
100print'add all geospatial objects'
101G = G1 + G2 + G3 + G4 + G5 + G_off
102
103#print'clip combined geospatial object by bounding polygon'
104G_clipped = G.clip(project.bounding_polygon)
105#FIXME: add a clip function to pts
106print'shape of clipped data', G_clipped.get_data_points().shape
107
108print'export combined DEM file'
109if access(project.topographies_dir,F_OK) == 0:
110    mkdir (project.topographies_dir)
111#G_clipped.export_points_file(project.combined_dir_name + '.pts')
112G_clipped.export_points_file(project.combined_dir_name + '.xya')
113
114
115'''
116#-------------------------------------------------------------------------
117# Convert URS to SWW file for boundary conditions
118#-------------------------------------------------------------------------
119print 'starting to create boundary conditions'
120boundaries_in_dir_name = project.boundaries_in_dir_name
121
122from anuga.shallow_water.data_manager import urs2sww
123
124print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
125print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
126
127#import sys; sys.exit()
128
129#if access(project.boundaries_dir,F_OK) == 0:
130#    mkdir (project.boundaries_dir)
131
132from caching import cache
133cache(urs2sww,
134      (boundaries_in_dir_name,
135       project.boundaries_dir_name1),
136      {'verbose': True,
137       'minlat': project.south_boundary,
138       'maxlat': project.north_boundary,
139       'minlon': project.west_boundary,
140       'maxlon': project.east_boundary,
141#       'minlat': project.south,
142#       'maxlat': project.north,
143#       'minlon': project.west,
144#       'maxlon': project.east,
145       'mint': 0, 'maxt': 40000,
146#       'origin': domain.geo_reference.get_origin(),
147       'mean_stage': project.tide,
148#       'zscale': 1,                 #Enhance tsunami
149       'fail_on_NaN': False},
150       verbose = True,
151       )
152#       dependencies = source_dir + project.boundary_basename + '.sww')
153
154'''
155
156
157
158
159
160
161
Note: See TracBrowser for help on using the repository browser.