source: anuga_work/production/gold_coast_2009/For_DVD/build_elevation.py @ 7306

Last change on this file since 7306 was 7306, checked in by Leharne, 14 years ago

Scripts to be included on Gold Coast DVD with AGD's report

File size: 3.6 KB
Line 
1"""Build the elevation data to run a tsunami inundation scenario.
2
3Input: elevation data from project.py
4Output: pts file stored in project.topographies_dir
5The run_model.py is reliant on the output of this script.
6
7"""
8
9#------------------------------------------------------------------------------
10# Import necessary modules
11#------------------------------------------------------------------------------
12
13# Standard modules
14import os
15from os.path import join
16
17# Related major packages
18from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf
19from anuga.shallow_water.data_manager import dem2pts
20from anuga.shallow_water.data_manager import start_screen_catcher
21from anuga.shallow_water.data_manager import copy_code_files
22from anuga.geospatial_data.geospatial_data import Geospatial_data
23
24# Application specific imports
25from setup_model import project   # Definition of file names and polygons
26
27
28#------------------------------------------------------------------------------
29# Copy scripts to time stamped output directory and capture screen
30# output to file
31#------------------------------------------------------------------------------
32copy_code_files(project.output_build,__file__, 
33                os.path.dirname(project.__file__)+os.sep+\
34                project.__name__+'.py' )
35start_screen_catcher(project.output_build)
36
37
38#------------------------------------------------------------------------------
39# Preparation of topographic data
40#
41# Convert ASC 2 DEM 2 PTS using source data and store result in source data
42# Do for coarse and fine data
43# Fine pts file to be clipped to area of interest
44#------------------------------------------------------------------------------
45
46print 'project.bounding_polygon', project.bounding_polygon
47print 'project.combined_elevation_basename', project.combined_elevation_basename
48
49# Create Geospatial data from ASCII files
50geospatial_data = {}
51if not project.ascii_grid_filenames == []:
52    for filename in project.ascii_grid_filenames:
53        absolute_filename = join(project.topographies_folder, filename)
54        convert_dem_from_ascii2netcdf(absolute_filename,
55                                      basename_out=absolute_filename,
56                                      use_cache=True,
57                                      verbose=True)
58        dem2pts(absolute_filename, use_cache=True, verbose=True)
59
60        G_grid = Geospatial_data(file_name=absolute_filename+'.pts',
61                                                    verbose=True)
62        print 'Clip geospatial object'
63        geospatial_data[filename] = G_grid.clip(project.bounding_polygon)
64
65# Create Geospatial data from TXT files
66if not project.point_filenames == []:
67    for filename in project.point_filenames:
68        absolute_filename = join(project.topographies_folder, filename)
69        G_points = Geospatial_data(file_name=absolute_filename,
70                                                    verbose=True)
71        print 'Clip geospatial object'
72        geospatial_data[filename] = G_points.clip(project.bounding_polygon)
73
74#-------------------------------------------------------------------------------
75# Combine, clip and export dataset
76#-------------------------------------------------------------------------------
77
78print 'Add geospatial objects' # except', project.offshore_name5
79G = None
80for key in geospatial_data:
81   
82    G += geospatial_data[key]
83       
84print 'Export combined DEM file'
85G.export_points_file(project.combined_elevation + '.pts')
86print 'Do txt version too'
87# Use for comparision in ARC
88G.export_points_file(project.combined_elevation + '.txt')
89
Note: See TracBrowser for help on using the repository browser.