source: anuga_work/production/onslow_2006/build_onslow_grad.py @ 6855

Last change on this file since 6855 was 4698, checked in by sexton, 18 years ago

(i) commented matlab script from William (ii) scripts looking at grad data

File size: 4.3 KB
Line 
1"""Script for running tsunami inundation scenario for Onslow, WA, Australia.
2
3Source data such as elevation and boundary data is assumed to be available in
4directories specified by project_grad_urs.py
5The output sww file is stored in project_grad.output_time_dir
6
7The scenario is defined by a triangular mesh created from project_grad_urs.polygon,
8the elevation data and a simulated tsunamigenic earthquake.
9
10Ole Nielsen and Duncan Gray, GA - 2005 and Jane Sexton, Nick Bartzis, GA - 2006
11"""
12
13#------------------------------------------------------------------------------
14# Import necessary modules
15#------------------------------------------------------------------------------
16
17# Standard modules
18from os import sep
19from os.path import dirname, basename
20from os import mkdir, access, F_OK
21from shutil import copy
22import time
23import sys
24
25# Related major packages
26from anuga.shallow_water import Domain
27from anuga.shallow_water import Dirichlet_boundary
28from anuga.shallow_water import File_boundary
29from anuga.shallow_water import Reflective_boundary
30from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf
31from anuga.shallow_water.data_manager import dem2pts
32from anuga.pmesh.mesh_interface import create_mesh_from_regions
33from anuga.geospatial_data.geospatial_data import Geospatial_data
34from anuga.shallow_water.data_manager import start_screen_catcher
35from anuga.shallow_water.data_manager import copy_code_files
36from anuga.shallow_water.data_manager import urs_ungridded2sww
37from anuga_parallel.parallel_abstraction import get_processor_name
38
39# Application specific imports
40import project_grad   # Definition of file names and polygons
41
42
43#------------------------------------------------------------------------------
44# Copy scripts to time stamped output directory and capture screen
45# output to file
46#------------------------------------------------------------------------------
47
48copy_code_files(project_grad.output_build_time_dir,__file__, 
49               dirname(project_grad.__file__)+sep+ project_grad.__name__+'.py' )#
50
51start_screen_catcher(project_grad.output_build_time_dir)
52
53print 'Processor Name:', get_processor_name()
54print 'User: ', project_grad.user
55
56
57#-------------------------------------------------------------------------------
58# Preparation of topographic data
59#
60# Convert ASC 2 DEM 2 PTS using source data and store result in source data
61# Do for coarse and fine data
62# Fine pts file to be clipped to area of interest
63#-------------------------------------------------------------------------------
64
65print 'project_grad.combined_dir_name', project_grad.combined_dir_name
66
67
68geospatial_data = None
69# create DEMs from asc data
70
71# FIXME (Ole): Clip data by interior regions if possible
72
73print 'creating geospatial data objects from asc data (via dem and pts formats)'
74for filename in project_grad.ascii_grid_filenames:
75    convert_dem_from_ascii2netcdf(filename,
76                                  basename_out=filename,
77                                  use_cache=True, verbose=True)
78    dem2pts(filename, use_cache=True, verbose=True)
79
80    geospatial_data += Geospatial_data(file_name=filename + '.pts',
81                                       verbose=True)
82
83
84print 'creating geospatial data objects from txt data'
85for filename in project_grad.point_filenames:
86    geospatial_data += Geospatial_data(file_name=filename + '.txt',
87                                       verbose=True)
88
89
90print 'clip combined geospatial object by bounding polygon'
91G = geospatial_data.clip(project_grad.bounding_polygon)
92
93
94print 'export combined geospatial data'
95if access(project_grad.topographies_dir, F_OK) == 0:
96    mkdir (project_grad.topographies_dir)
97G.export_points_file(project_grad.combined_dir_name + '.pts')
98
99#-------------------------------------------------------------------------
100# Convert URS to SWW file for boundary conditions
101#-------------------------------------------------------------------------
102print 'converting boundary conditions to sww format'
103
104print 'boundary_dir', project_grad.boundaries_in_dir
105
106maxt = 40000
107urs_ungridded2sww(project_grad.boundaries_in_dir+sep+project_grad.boundaries_name,
108                  project_grad.boundaries_in_dir+sep+project_grad.boundaries_name+'_'+ str(maxt),
109                  verbose=True,
110                  mint=0, maxt=maxt, zscale=1)
111
112print 'Finished building the %s scenario' %project_grad.scenario_name
113
114
Note: See TracBrowser for help on using the repository browser.