source: anuga_work/production/perth/build_perth.py @ 5781

Last change on this file since 5781 was 5781, checked in by kristy, 15 years ago
File size: 5.9 KB
Line 
1"""
2Script for building the elevation data to run tsunami inundation scenario
3for Perth, WA, Australia.
4
5Input: elevation data from project.py
6Output: pts file stored in project.topographies_dir
7The run_perth.py is reliant on the output of this script.
8
9Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
10"""
11
12#------------------------------------------------------------------------------
13# Import necessary modules
14#------------------------------------------------------------------------------
15
16# Standard modules
17from os import sep
18from os.path import dirname, basename
19from os import mkdir, access, F_OK
20from shutil import copy
21import time
22import sys
23
24# Related major packages
25from anuga.shallow_water import Domain
26from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
27from anuga.geospatial_data.geospatial_data import *
28from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files
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
38copy_code_files(project.output_build_time_dir,__file__, 
39               dirname(project.__file__)+sep+ project.__name__+'.py' )
40
41start_screen_catcher(project.output_build_time_dir)
42
43print 'USER:    ', project.user
44
45#-------------------------------------------------------------------------------
46# Preparation of topographic data
47#
48# Convert ASC 2 DEM 2 PTS using source data and store result in source data
49# Do for coarse and fine data
50# Fine pts file to be clipped to area of interest
51#-------------------------------------------------------------------------------
52print"project.poly_all",project.poly_all
53print"project.combined_dir_name",project.combined_dir_name
54
55# input elevation directory filenames
56onshore_in_dir_name = project.onshore_in_dir_name
57coast_in_dir_name = project.coast_in_dir_name
58island_in_dir_name = project.island_in_dir_name
59island_in_dir_name1 = project.island_in_dir_name1
60island_in_dir_name2 = project.island_in_dir_name2
61island_in_dir_name3 = project.island_in_dir_name3
62offshore_in_dir_name = project.offshore_in_dir_name
63offshore_in_dir_name1 = project.offshore_in_dir_name1
64offshore_in_dir_name2 = project.offshore_in_dir_name2
65offshore_in_dir_name3 = project.offshore_in_dir_name3
66
67# output elevation directory filenames
68onshore_dir_name = project.onshore_dir_name
69coast_dir_name = project.coast_dir_name
70island_dir_name = project.island_dir_name
71island_dir_name1 = project.island_dir_name1
72island_dir_name2 = project.island_dir_name2
73island_dir_name3 = project.island_dir_name3
74offshore_dir_name = project.offshore_dir_name
75offshore_dir_name1 = project.offshore_dir_name1
76offshore_dir_name2 = project.offshore_dir_name2
77offshore_dir_name3 = project.offshore_dir_name3
78
79# creates DEM from asc data
80print "creates DEMs from asc data"
81convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
82convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True)
83convert_dem_from_ascii2netcdf(island_in_dir_name1, basename_out=island_dir_name1, use_cache=True, verbose=True)
84convert_dem_from_ascii2netcdf(island_in_dir_name2, basename_out=island_dir_name2, use_cache=True, verbose=True)
85convert_dem_from_ascii2netcdf(island_in_dir_name3, basename_out=island_dir_name3, use_cache=True, verbose=True)
86
87#creates pts file for onshore DEM
88print "creates pts file for onshore DEM"
89dem2pts(onshore_dir_name ,use_cache=True,verbose=True)
90
91#creates pts file for island DEM
92dem2pts(island_dir_name, use_cache=True, verbose=True)
93dem2pts(island_dir_name1, use_cache=True, verbose=True)
94dem2pts(island_dir_name2, use_cache=True, verbose=True)
95dem2pts(island_dir_name3, use_cache=True, verbose=True)
96
97#-------------------------------------------------------------------------------
98# Combine datasets into project.combined_dir_name
99#-------------------------------------------------------------------------------
100
101print'create Geospatial data1 objects from topographies'
102G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
103print'create Geospatial data2 objects from topographies'
104G2 = Geospatial_data(file_name = island_dir_name + '.pts')
105print'create Geospatial data3 objects from topographies'
106G3 = Geospatial_data(file_name = island_dir_name1 + '.pts')
107print'create Geospatial data4 objects from topographies'
108G4 = Geospatial_data(file_name = island_dir_name2 + '.pts')
109print'create Geospatial data5 objects from topographies'
110G5 = Geospatial_data(file_name = island_dir_name3 + '.pts')
111print'create Geospatial data6 objects from topographies'
112G_coast = Geospatial_data(file_name = coast_in_dir_name)
113print'create Geospatial data7 objects from topographies'
114G_off = Geospatial_data(file_name = offshore_in_dir_name)
115print'create Geospatial data8 objects from topographies'
116G_off1 = Geospatial_data(file_name = offshore_in_dir_name1)
117print'create Geospatial data9 objects from topographies'
118G_off2 = Geospatial_data(file_name = offshore_in_dir_name2)
119print'create Geospatial data10 objects from topographies'
120G_off3 = Geospatial_data(file_name = offshore_in_dir_name3)
121
122
123print'add all geospatial objects'
124G = G1 + G2 + G3 + G4 + G5 + G_coast + G_off + G_off1 + G_off2 + G_off3
125
126print'clip combined geospatial object by bounding polygon'
127G_clipped = G.clip(project.poly_all)
128
129print'export combined DEM file'
130if access(project.topographies_dir,F_OK) == 0:
131    mkdir (project.topographies_dir)
132#G_clipped.export_points_file(project.combined_dir_name + '.pts')
133G_clipped.export_points_file(project.combined_dir_name + '.txt') #Use for comparision in ARC
134
135import sys
136sys.exit()
Note: See TracBrowser for help on using the repository browser.