source: anuga_work/production/exmouth_2008/build_Exmouth.py @ 6929

Last change on this file since 6929 was 5809, checked in by rmleczko, 16 years ago

new Exmouth files added 2nd Oct 2008

File size: 4.1 KB
Line 
1"""
2Script for building the elevation data to run a tsunami inundation scenario
3for Exmouth, WA, Australia.
4
5Input: elevation data from project.py
6Output: pts file stored in project.topographies_dir
7The run_exmouth.py is reliant on the output of this script.
8
9"""
10
11#------------------------------------------------------------------------------
12# Import necessary modules
13#------------------------------------------------------------------------------
14
15# Standard modules
16from os import sep
17from os.path import dirname, basename
18from os import mkdir, access, F_OK
19from shutil import copy
20import time
21import sys
22
23# Related major packages
24from anuga.shallow_water import Domain
25from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
26from anuga.geospatial_data.geospatial_data import *
27from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files
28
29# Application specific imports
30import project   # Definition of file names and polygons
31
32#------------------------------------------------------------------------------
33# Copy scripts to time stamped output directory and capture screen
34# output to file
35#------------------------------------------------------------------------------
36
37copy_code_files(project.output_build_time_dir,__file__, 
38               dirname(project.__file__)+sep+ project.__name__+'.py' )
39
40start_screen_catcher(project.output_build_time_dir)
41
42print 'USER:    ', project.user
43
44#-------------------------------------------------------------------------------
45# Preparation of topographic data
46#
47# Convert ASC 2 DEM 2 PTS using source data and store result in source data
48# Do for coarse and fine data
49# Fine pts file to be clipped to area of interest
50#-------------------------------------------------------------------------------
51print "project.poly_all", project.poly_all
52print "project.combined_dir_name", project.combined_dir_name
53
54# input elevation directory filenames
55onshore_in_dir_name = project.onshore_in_dir_name
56onshore_in_dir_name1 = project.onshore_in_dir_name1
57coast_in_dir_name = project.coast_in_dir_name
58offshore_in_dir_name = project.offshore_in_dir_name
59
60# output elevation directory filenames
61onshore_dir_name = project.onshore_dir_name
62onshore_dir_name1 = project.onshore_dir_name1
63coast_dir_name = project.coast_dir_name
64offshore_dir_name = project.offshore_dir_name
65
66
67# creates DEM from asc data
68print "creates DEMs from asc data"
69convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
70convert_dem_from_ascii2netcdf(onshore_in_dir_name1, basename_out=onshore_dir_name1, use_cache=True, verbose=True)
71
72# creates pts file for onshore DEM
73print "creates pts file for onshore DEM"
74dem2pts(onshore_dir_name ,use_cache=True,verbose=True)
75dem2pts(onshore_dir_name1 ,use_cache=True,verbose=True)
76
77# creates pts file for island DEM
78#dem2pts(island_dir_name, use_cache=True, verbose=True)
79
80
81# create onshore pts files
82print'create Geospatial data1 objects from topographies'
83G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
84print'create Geospatial data2 objects from topographies'
85G2 = Geospatial_data(file_name = onshore_dir_name1 + '.pts')
86
87# create coastal and offshore pts files
88print'create Geospatial data6 objects from topographies'
89G_coast = Geospatial_data(file_name = coast_in_dir_name)
90print'create Geospatial data7 objects from topographies'
91G_off = Geospatial_data(file_name = offshore_in_dir_name)
92
93
94#-------------------------------------------------------------------------------
95# Combine, clip and export dataset
96#-------------------------------------------------------------------------------
97
98print'add all geospatial objects'
99G = G1 + G2 + G_coast + G_off
100
101print'clip combined geospatial object by bounding polygon'
102G_clipped = G.clip(project.poly_all)
103
104print'export combined DEM file'
105if access(project.topographies_dir,F_OK) == 0:
106    mkdir (project.topographies_dir)
107G_clipped.export_points_file(project.combined_dir_name + '.pts')
108#G_clipped.export_points_file(project.combined_dir_name + '.txt') #Use for comparision in ARC
109
Note: See TracBrowser for help on using the repository browser.