source: anuga_work/production/geraldton/build_geraldton.py @ 7116

Last change on this file since 7116 was 6296, checked in by ole, 16 years ago

Style guide modification

File size: 5.0 KB
RevLine 
[5789]1"""
2Script for building the elevation data to run a tsunami inundation scenario
3for geraldton, WA, Australia.
[5005]4
[5789]5Input: elevation data from project.py
6Output: pts file stored in project.topographies_dir
7The run_geraldton.py is reliant on the output of this script.
[5005]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
[5789]25from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
[5005]26from anuga.geospatial_data.geospatial_data import *
[5652]27from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files
[5005]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
[5012]40start_screen_catcher(project.output_build_time_dir)
[5005]41
[5789]42print 'USER:    ', project.user
[5005]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#-------------------------------------------------------------------------------
[5789]51print "project.poly_all", project.poly_all
52print "project.combined_dir_name", project.combined_dir_name
[5005]53
[5789]54# input elevation directory filenames
[5005]55onshore_in_dir_name = project.onshore_in_dir_name
56coast_in_dir_name = project.coast_in_dir_name
[5012]57island_in_dir_name = project.island_in_dir_name
[5005]58offshore_in_dir_name = project.offshore_in_dir_name
[5652]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
[5005]62
[5789]63# output elevation directory filenames
[5005]64onshore_dir_name = project.onshore_dir_name
65coast_dir_name = project.coast_dir_name
[5012]66island_dir_name = project.island_dir_name
[5005]67offshore_dir_name = project.offshore_dir_name
[5652]68offshore_dir_name1 = project.offshore_dir_name1
69offshore_dir_name2 = project.offshore_dir_name2
70offshore_dir_name3 = project.offshore_dir_name3
[5005]71
72# creates DEM from asc data
[5789]73print "creates DEMs from asc data"
[5005]74convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True)
[5012]75convert_dem_from_ascii2netcdf(island_in_dir_name, basename_out=island_dir_name, use_cache=True, verbose=True)
[5005]76
[5789]77# creates pts file for onshore DEM
78print "creates pts file for onshore DEM"
[6296]79dem2pts(onshore_dir_name, use_cache=True,verbose=True)
[5005]80
[5789]81# creates pts file for island DEM
[5012]82dem2pts(island_dir_name, use_cache=True, verbose=True)
[5005]83
[5789]84# create onshore pts files
[5005]85print'create Geospatial data1 objects from topographies'
[5789]86G1 = Geospatial_data(file_name = onshore_dir_name + '.pts')
87print'create Geospatial data2 objects from topographies'
88G2 = Geospatial_data(file_name = island_dir_name + '.pts')
[5005]89
[5789]90# create coastal and offshore pts files
91print'create Geospatial data6 objects from topographies'
92G_coast = Geospatial_data(file_name = coast_in_dir_name)
93print'create Geospatial data7 objects from topographies'
[6027]94G_off1 = Geospatial_data(file_name = offshore_in_dir_name)
[5789]95print'create Geospatial data8 objects from topographies'
[6027]96G_off2 = Geospatial_data(file_name = offshore_in_dir_name1)
[5789]97print'create Geospatial data9 objects from topographies'
[6027]98G_off3 = Geospatial_data(file_name = offshore_in_dir_name2)
[5789]99print'create Geospatial data10 objects from topographies'
[6027]100G_off4 = Geospatial_data(file_name = offshore_in_dir_name3)
[5751]101
[5789]102#-------------------------------------------------------------------------------
103# Combine, clip and export dataset
104#-------------------------------------------------------------------------------
105
106print 'clipping port data to area of significance'
[6027]107G_off2_clip = G_off2.clip(project.poly_buffer_20m, verbose=True)
[5789]108print 'add all bathymetry files'
109G_off = G_off1 + G_off2_clip + G_off3 + G_off4
110print 'clipping data to coast'
111G_off_clip = G_off.clip(project.poly_ocean, verbose=True)
112G1_clip = G1.clip(project.poly_mainland, verbose=True)
113
[5652]114print'add all geospatial objects'
[6027]115G = G1_clip + G2 + G_off_clip
[5012]116
[5652]117print'clip combined geospatial object by bounding polygon'
[5789]118G_clipped = G.clip(project.poly_all)
[5012]119
[5005]120print'export combined DEM file'
121if access(project.topographies_dir,F_OK) == 0:
122    mkdir (project.topographies_dir)
[5789]123G_clipped.export_points_file(project.combined_dir_name + '.pts')
124#G_clipped.export_points_file(project.combined_dir_name + '.txt') #Use for comparision in ARC
[5005]125
Note: See TracBrowser for help on using the repository browser.