source: anuga_work/production/geraldton/build_geraldton.py @ 5012

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

update geraldton

File size: 6.6 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,start_screen_catcher, copy_code_files
28from anuga.geospatial_data.geospatial_data import *
29
30# Application specific imports
31import project   # Definition of file names and polygons
32
33#------------------------------------------------------------------------------
34# Copy scripts to time stamped output directory and capture screen
35# output to file
36#------------------------------------------------------------------------------
37
38
39print 'time stamp: ',project.build_time
40print 'USER: ', project.user
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
48
49#-------------------------------------------------------------------------------
50# Preparation of topographic data
51#
52# Convert ASC 2 DEM 2 PTS using source data and store result in source data
53# Do for coarse and fine data
54# Fine pts file to be clipped to area of interest
55#-------------------------------------------------------------------------------
56
57# topography directory filenames
58onshore_in_dir_name = project.onshore_in_dir_name
59coast_in_dir_name = project.coast_in_dir_name
60island_in_dir_name = project.island_in_dir_name
61offshore_in_dir_name = project.offshore_in_dir_name
62
63onshore_dir_name = project.onshore_dir_name
64coast_dir_name = project.coast_dir_name
65island_dir_name = project.island_dir_name
66offshore_dir_name = project.offshore_dir_name
67
68# creates DEM from asc data
69print "creates DEMs from ascii data"
70convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
71convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True)
72
73#creates pts file for onshore DEM
74print "creates pts file for onshore DEM"
75dem2pts(onshore_dir_name,
76        use_cache=True, 
77        verbose=True)
78
79#creates pts file for island DEM
80dem2pts(island_dir_name, use_cache=True, verbose=True)
81
82print'create Geospatial data1 objects from topographies'
83G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
84print'finished reading in %s.pts' %onshore_dir_name
85G2 = Geospatial_data(file_name = coast_in_dir_name + '.txt')
86G3 = Geospatial_data(file_name = island_dir_name + '.pts')
87G4 = Geospatial_data(file_name = offshore_in_dir_name + '.txt')
88print'finished reading in files'
89
90G_onshore_clip = G1.clip(project.poly_all, verbose=True)
91print 'finished clip'
92G_onshore_clip_clipout=G_onshore_clip.clip_outside(project.poly_cbd, verbose=True)
93print 'finished clipout'
94# reduce resolution by 9 time (1/9) of the original file. This was determined
95# as the resolution for this region is going to be 20000 and the asc grid cellsize is
96# 30m there (900). The sqrt of 20000 is about 140 or 150, a 150m x150m grid would contain
97# 36 points at a 30m grid spacing and we only need 4. So 4/36 is 1/9 or 0.11111
98G_onshore_clip_clipout_reduced=G_onshore_clip_clipout.split(0.111, verbose=True)
99
100G_cbd = G1.clip(projec.poly_cbd,verbose=True)
101G_cbd_reduced = G_cbd.split(0.25, verbose=True)
102
103G_bathy = G4.clip(project.poly_all)
104G_island = G3.clip(project.poly_all)
105G_coast = G2.clip(project.poly_all)
106
107print'add all geospatial objects'
108G = G_onshore_clip_clipout_reduced + G_cbd_reduced + G_bathy + G_island + G_coast
109
110print'clip combined geospatial object by bounding polygon'
111#G_clipped = G.clip(project.bounding_polygon)
112#FIXME: add a clip function to pts
113#print'shape of clipped data', G_clipped.get_data_points().shape
114
115print'export combined DEM file'
116if access(project.topographies_dir,F_OK) == 0:
117    mkdir (project.topographies_dir)
118G.export_points_file(project.combined_dir_name + '.txt')
119#G_clipped.export_points_file(project.combined_dir_name + '.xya')
120G_small, = G.split(0.1, verbose)
121G_small.export_points_file(project.combined_dir_name_small + '.txt')
122
123'''
124print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya'
125G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya')
126print'split'
127G_all_1, G_all_2 = G_all.split(.10)
128print'export 1'
129G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya')
130print'export 2'
131G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya')
132
133
134#-------------------------------------------------------------------------
135# Convert URS to SWW file for boundary conditions
136#-------------------------------------------------------------------------
137print 'starting to create boundary conditions'
138boundaries_in_dir_name = project.boundaries_in_dir_name
139
140from anuga.shallow_water.data_manager import urs2sww
141
142print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
143print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
144
145#import sys; sys.exit()
146
147#if access(project.boundaries_dir,F_OK) == 0:
148#    mkdir (project.boundaries_dir)
149
150from caching import cache
151cache(urs2sww,
152      (boundaries_in_dir_name,
153       project.boundaries_dir_name1),
154      {'verbose': True,
155       'minlat': project.south_boundary,
156       'maxlat': project.north_boundary,
157       'minlon': project.west_boundary,
158       'maxlon': project.east_boundary,
159#       'minlat': project.south,
160#       'maxlat': project.north,
161#       'minlon': project.west,
162#       'maxlon': project.east,
163       'mint': 0, 'maxt': 40000,
164#       'origin': domain.geo_reference.get_origin(),
165       'mean_stage': project.tide,
166#       'zscale': 1,                 #Enhance tsunami
167       'fail_on_NaN': False},
168       verbose = True,
169       )
170#       dependencies = source_dir + project.boundary_basename + '.sww')
171
172'''
173
174
175
176
177
178
179
Note: See TracBrowser for help on using the repository browser.