source: anuga_work/production/busselton/build_busselton.py @ 5786

Last change on this file since 5786 was 5786, checked in by kristy, 16 years ago

Updated all scripts to reflect Perth format. Also added 250m scripts

File size: 5.0 KB
Line 
1"""
2Script for building the elevation data to run a tsunami inundation scenario
3for busselton, WA, Australia.
4
5Input: elevation data from project.py
6Output: pts file stored in project.topographies_dir
7The run_busselton.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
56coast_in_dir_name = project.coast_in_dir_name
57coast_in_dir_name1 = project.coast_in_dir_name1
58offshore_in_dir_name = project.offshore_in_dir_name
59offshore_in_dir_name1 = project.offshore_in_dir_name1
60offshore_in_dir_name2 = project.offshore_in_dir_name2
61offshore_in_dir_name3 = project.offshore_in_dir_name3
62offshore_in_dir_name4 = project.offshore_in_dir_name4
63offshore_in_dir_name5 = project.offshore_in_dir_name5
64
65# output elevation directory filenames
66onshore_dir_name = project.onshore_dir_name
67coast_dir_name = project.coast_dir_name
68coast_dir_name1 = project.coast_dir_name1
69offshore_dir_name = project.offshore_dir_name
70offshore_dir_name1 = project.offshore_dir_name1
71offshore_dir_name2 = project.offshore_dir_name2
72offshore_dir_name3 = project.offshore_dir_name3
73offshore_dir_name4 = project.offshore_dir_name4
74offshore_dir_name5 = project.offshore_dir_name5
75# creates DEM from asc data
76print "creates DEMs from asc data"
77convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
78
79# creates pts file for onshore DEM
80print "creates pts file for onshore DEM"
81dem2pts(onshore_dir_name ,use_cache=True,verbose=True)
82
83# create onshore pts files
84print'create Geospatial data1 objects from topographies'
85G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
86
87# create coastal and offshore pts files
88print'create Geospatial data2 objects from topographies'
89G3 = Geospatial_data(file_name = coast_in_dir_name)
90print'create Geospatial data3 objects from topographies'
91G4 = Geospatial_data(file_name = coast_in_dir_name1)
92print'create Geospatial data4 objects from topographies'
93G_off = Geospatial_data(file_name = offshore_in_dir_name)
94print'create Geospatial data5 objects from topographies'
95G_off1 = Geospatial_data(file_name = offshore_in_dir_name1)
96print'create Geospatial data6 objects from topographies'
97G_off2 = Geospatial_data(file_name = offshore_in_dir_name2)
98print'create Geospatial data7 objects from topographies'
99G_off3 = Geospatial_data(file_name = offshore_in_dir_name3)
100print'create Geospatial data8 objects from topographies'
101G_off4 = Geospatial_data(file_name = offshore_in_dir_name4)
102print'create Geospatial data9 objects from topographies'
103G_off5 = Geospatial_data(file_name = offshore_in_dir_name5)
104
105
106#-------------------------------------------------------------------------------
107# Combine, clip and export dataset
108#-------------------------------------------------------------------------------
109
110print'add all geospatial objects'
111G = G1 + G2 + G3 + G_off + G_off1 + G_off2 + G_off3 + G_off4 + G_off5
112
113print'clip combined geospatial object by bounding polygon'
114G_clipped = G.clip(project.poly_all)
115
116print'export combined DEM file'
117if access(project.topographies_dir,F_OK) == 0:
118    mkdir (project.topographies_dir)
119G_clipped.export_points_file(project.combined_dir_name + '.pts')
120#G_clipped.export_points_file(project.combined_dir_name + '.txt') #Use for comparision in ARC
121
Note: See TracBrowser for help on using the repository browser.