source: anuga_work/production/carnarvon/build_carnarvon.py @ 5212

Last change on this file since 5212 was 5005, checked in by nick, 16 years ago

add gerladton and carnarvon files and directories, they don't work yet

File size: 5.8 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
39start_screen_catcher(project.output_build_time_dir)
40
41print 'time stamp: ',project.gtime
42print 'USER: ', project.user
43
44
45copy_code_files(project.output_build_time_dir,__file__, 
46               dirname(project.__file__)+sep+ project.__name__+'.py' )
47
48
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# topography directory filenames
59onshore_in_dir_name = project.onshore_in_dir_name
60coast_in_dir_name = project.coast_in_dir_name
61#island_in_dir_name = project.island_in_dir_name
62offshore_in_dir_name = project.offshore_in_dir_name
63
64onshore_dir_name = project.onshore_dir_name
65coast_dir_name = project.coast_dir_name
66#island_dir_name = project.island_dir_name
67offshore_dir_name = project.offshore_dir_name
68
69# creates DEM from asc data
70print "creates DEMs from ascii data"
71convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
72#convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True)
73
74#creates pts file for onshore DEM
75print "creates pts file for onshore DEM"
76dem2pts(onshore_dir_name,
77#        easting_min=project.eastingmin,
78#        easting_max=project.eastingmax,
79#        northing_min=project.northingmin,
80#        northing_max= project.northingmax,
81        use_cache=True, 
82        verbose=True)
83
84#creates pts file for island DEM
85#dem2pts(island_dir_name, use_cache=True, verbose=True)
86
87print'create Geospatial data1 objects from topographies'
88G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
89G2 = Geospatial_data(file_name = coast_in_dir_name + '.xya')
90#G3 = Geospatial_data(file_name = island_dir_name + '.pts')
91G_off = Geospatial_data(file_name = offshore_in_dir_name + '.xya')
92
93print'add all geospatial objects'
94G = G1 + G2 + G_off
95
96print'clip combined geospatial object by bounding polygon'
97#G_clipped = G.clip(project.bounding_polygon)
98#FIXME: add a clip function to pts
99#print'shape of clipped data', G_clipped.get_data_points().shape
100
101print'export combined DEM file'
102if access(project.topographies_dir,F_OK) == 0:
103    mkdir (project.topographies_dir)
104G.export_points_file(project.combined_dir_name + '.xya')
105#G_clipped.export_points_file(project.combined_dir_name + '.xya')
106
107'''
108print'project.combined_dir_name + 1.xya',project.combined_dir_name + '1.xya'
109G_all=Geospatial_data(file_name = project.combined_dir_name + '1.xya')
110print'split'
111G_all_1, G_all_2 = G_all.split(.10)
112print'export 1'
113G_all_1.export_points_file(project.combined_dir_name+'_small1' + '.xya')
114print'export 2'
115G_all_2.export_points_file(project.combined_dir_name+'_other1' + '.xya')
116
117
118#-------------------------------------------------------------------------
119# Convert URS to SWW file for boundary conditions
120#-------------------------------------------------------------------------
121print 'starting to create boundary conditions'
122boundaries_in_dir_name = project.boundaries_in_dir_name
123
124from anuga.shallow_water.data_manager import urs2sww
125
126print 'minlat=project.north_boundary, maxlat=project.south_boundary',project.north_boundary, project.south_boundary
127print 'minlon= project.west_boundary, maxlon=project.east_boundary',project.west_boundary, project.east_boundary
128
129#import sys; sys.exit()
130
131#if access(project.boundaries_dir,F_OK) == 0:
132#    mkdir (project.boundaries_dir)
133
134from caching import cache
135cache(urs2sww,
136      (boundaries_in_dir_name,
137       project.boundaries_dir_name1),
138      {'verbose': True,
139       'minlat': project.south_boundary,
140       'maxlat': project.north_boundary,
141       'minlon': project.west_boundary,
142       'maxlon': project.east_boundary,
143#       'minlat': project.south,
144#       'maxlat': project.north,
145#       'minlon': project.west,
146#       'maxlon': project.east,
147       'mint': 0, 'maxt': 40000,
148#       'origin': domain.geo_reference.get_origin(),
149       'mean_stage': project.tide,
150#       'zscale': 1,                 #Enhance tsunami
151       'fail_on_NaN': False},
152       verbose = True,
153       )
154#       dependencies = source_dir + project.boundary_basename + '.sww')
155
156'''
157
158
159
160
161
162
163
Note: See TracBrowser for help on using the repository browser.