1 | """ |
---|
2 | Script for building the elevation data to run tsunami inundation scenario |
---|
3 | for Perth, WA, Australia. |
---|
4 | |
---|
5 | Input: elevation data from project_250m.py |
---|
6 | Output: pts file stored in project_250m.topographies_dir |
---|
7 | The run_perth.py is reliant on the output of this script. |
---|
8 | |
---|
9 | Ole 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 |
---|
17 | from os import sep |
---|
18 | from os.path import dirname, basename |
---|
19 | from os import mkdir, access, F_OK |
---|
20 | from shutil import copy |
---|
21 | import time |
---|
22 | import sys |
---|
23 | |
---|
24 | # Related major packages |
---|
25 | from anuga.shallow_water import Domain |
---|
26 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
27 | from anuga.geospatial_data.geospatial_data import * |
---|
28 | from anuga.shallow_water.data_manager import start_screen_catcher, copy_code_files |
---|
29 | |
---|
30 | # Application specific imports |
---|
31 | import project_250m # 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 | |
---|
38 | copy_code_files(project_250m.output_build_time_dir,__file__, |
---|
39 | dirname(project_250m.__file__)+sep+ project_250m.__name__+'.py' ) |
---|
40 | |
---|
41 | start_screen_catcher(project_250m.output_build_time_dir) |
---|
42 | |
---|
43 | print 'USER: ', project_250m.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 | #------------------------------------------------------------------------------- |
---|
52 | print"project_250m.poly_all",project_250m.poly_all |
---|
53 | print"project_250m.combined_dir_name",project_250m.combined_dir_name |
---|
54 | |
---|
55 | # input elevation directory filenames |
---|
56 | onshore_in_dir_name = project_250m.onshore_in_dir_name |
---|
57 | |
---|
58 | # output elevation directory filenames |
---|
59 | onshore_dir_name = project_250m.onshore_dir_name |
---|
60 | |
---|
61 | # creates DEM from asc data |
---|
62 | print "creates DEMs from asc data" |
---|
63 | convert_dem_from_ascii2netcdf(onshore_in_dir_name, basename_out=onshore_dir_name, use_cache=True, verbose=True) |
---|
64 | |
---|
65 | #creates pts file for onshore DEM |
---|
66 | print "creates pts file for onshore DEM" |
---|
67 | dem2pts(onshore_dir_name ,use_cache=True,verbose=True) |
---|
68 | |
---|
69 | #------------------------------------------------------------------------------- |
---|
70 | # Combine datasets into project_250m.combined_dir_name |
---|
71 | #------------------------------------------------------------------------------- |
---|
72 | |
---|
73 | print'create Geospatial data1 objects from topographies' |
---|
74 | G = Geospatial_data(file_name = onshore_dir_name + '.pts') |
---|
75 | |
---|
76 | print'clip combined geospatial object by bounding polygon' |
---|
77 | G_clipped = G.clip(project_250m.poly_all) |
---|
78 | |
---|
79 | print'export combined DEM file' |
---|
80 | if access(project_250m.topographies_dir,F_OK) == 0: |
---|
81 | mkdir (project_250m.topographies_dir) |
---|
82 | G_clipped.export_points_file(project_250m.combined_dir_name + '.pts') |
---|
83 | #G_clipped.export_points_file(project_250m.combined_dir_name + '.txt') #Use for comparision in ARC |
---|
84 | |
---|
85 | import sys |
---|
86 | sys.exit() |
---|