1 | """ |
---|
2 | |
---|
3 | Source data such as elevation and boundary data is assumed to be available in |
---|
4 | directories specified by project.py |
---|
5 | The output sww file is stored in project.output_time_dir |
---|
6 | |
---|
7 | The scenario is defined by a triangular mesh created from project.polygon, |
---|
8 | the elevation data and a simulated submarine landslide. |
---|
9 | |
---|
10 | Ole 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 |
---|
18 | from os import sep |
---|
19 | from os.path import dirname, basename |
---|
20 | from os import mkdir, access, F_OK |
---|
21 | from shutil import copy |
---|
22 | import time |
---|
23 | import sys |
---|
24 | |
---|
25 | # Related major packages |
---|
26 | from anuga.shallow_water import Domain |
---|
27 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
28 | from anuga.geospatial_data.geospatial_data import * |
---|
29 | from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, copy_code_files |
---|
30 | |
---|
31 | # Application specific imports |
---|
32 | import project # Definition of file names and polygons |
---|
33 | |
---|
34 | #------------------------------------------------------------------------------ |
---|
35 | # Copy scripts to time stamped output directory and capture screen |
---|
36 | # output to file |
---|
37 | #------------------------------------------------------------------------------ |
---|
38 | |
---|
39 | copy_code_files(project.output_build_time_dir,__file__, |
---|
40 | dirname(project.__file__)+sep+ project.__name__+'.py' ) |
---|
41 | |
---|
42 | #start_screen_catcher(project.output_build_time_dir) |
---|
43 | |
---|
44 | print 'USER: ', project.user |
---|
45 | |
---|
46 | #------------------------------------------------------------------------------- |
---|
47 | # Preparation of topographic data |
---|
48 | # |
---|
49 | # Convert ASC 2 DEM 2 PTS using source data and store result in source data |
---|
50 | # Do for coarse and fine data |
---|
51 | # Fine pts file to be clipped to area of interest |
---|
52 | #------------------------------------------------------------------------------- |
---|
53 | # Create DEM from asc data |
---|
54 | ''' |
---|
55 | convert_dem_from_ascii2netcdf(galle_dem_name, use_cache=True, verbose=True) |
---|
56 | convert_dem_from_ascii2netcdf(hikka_dem_name, use_cache=True, verbose=True) |
---|
57 | convert_dem_from_ascii2netcdf(topo_dem_name, use_cache=True, verbose=True) |
---|
58 | convert_dem_from_ascii2netcdf(bathycoa_dem_name, use_cache=True, verbose=True) |
---|
59 | #convert_dem_from_ascii2netcdf(bathyfine_dem_name, use_cache=True, verbose=True) |
---|
60 | |
---|
61 | # Create pts file for onshore DEM |
---|
62 | dem2pts(galle_dem_name, use_cache=True, verbose=True) |
---|
63 | dem2pts(hikka_dem_name, use_cache=True, verbose=True) |
---|
64 | dem2pts(topo_dem_name, use_cache=True, verbose=True) |
---|
65 | dem2pts(bathycoa_dem_name, use_cache=True, verbose=True) |
---|
66 | #dem2pts(bathyfine_dem_name, use_cache=True, verbose=True) |
---|
67 | |
---|
68 | # DEM |
---|
69 | G1 = Geospatial_data(file_name = project.galle_dem_name + '.pts') |
---|
70 | print 'loading fine bathy data' |
---|
71 | G2 = Geospatial_data(file_name = project.hikka_dem_name + '.pts') |
---|
72 | print 'loading fine bathy data' |
---|
73 | G3 = Geospatial_data(file_name = project.topo_dem_name + '.pts') |
---|
74 | G6 = Geospatial_data(file_name = project.coast_name + '.txt') |
---|
75 | print 'loading fine bathy data' |
---|
76 | G4 = Geospatial_data(file_name = project.bathyfine_dem_name + '.pts') |
---|
77 | G5 = Geospatial_data(file_name = project.bathycoa_dem_name + '.pts') |
---|
78 | G7 = Geospatial_data(file_name = project.canal_dem_name + '.txt') |
---|
79 | G8 = Geospatial_data(file_name = project.fort_dem_name+'.txt') |
---|
80 | |
---|
81 | # coastline |
---|
82 | #G4.export_points_file(project.bathyfine_dem_name + '.txt') |
---|
83 | |
---|
84 | print 'clip G5' |
---|
85 | G5_clip = G5.clip_outside(Geospatial_data(project.poly_clip)) |
---|
86 | print 'adding data files together' |
---|
87 | #G = G1 + G2 + G3 + G4 + G6 + G5_clip |
---|
88 | G = G1 + G2 + G3 + G4 + G6 + G5 + G7 + G8 |
---|
89 | #G = G1 + G2 + G3 + G4 + G6 + G5 + G7 |
---|
90 | #G = G1 + G2 + G3 + G5 + G6 |
---|
91 | print 'exporting elevation file' |
---|
92 | G.export_points_file(project.combined_canal_fort_dem_name + '.txt') |
---|
93 | |
---|
94 | |
---|
95 | print'load data' |
---|
96 | G = Geospatial_data(file_name = project.coast_name + '.txt') |
---|
97 | #G = Geospatial_data(file_name = project.combined_canal_dem_name + '.txt') |
---|
98 | print'split combined data set' |
---|
99 | G_small, G_other = G.split(0.1, True) |
---|
100 | G_small.export_points_file(project.combined_small_dem_name+ '1.txt') |
---|
101 | ''' |
---|
102 | # if you would like to look at your points file in GIS environment |
---|
103 | # use this line and then change extension to txt for import into ArcGIS |
---|
104 | #G.export_points_file(combined_dem_name + '.xya') |
---|
105 | |
---|
106 | |
---|
107 | print 'start ferret2sww' |
---|
108 | from anuga.shallow_water.data_manager import ferret2sww |
---|
109 | |
---|
110 | #note only need to do when an SWW file for the MOST boundary doesn't exist |
---|
111 | |
---|
112 | ferret2sww(project.boundaries_in_dir_name, |
---|
113 | project.boundaries_dir_name, |
---|
114 | verbose = True, |
---|
115 | # minlat = project.south_source, |
---|
116 | # maxlat = project.north_source, |
---|
117 | # minlon = project.west_source, |
---|
118 | # maxlon = project.east_source, |
---|
119 | mint = None, maxt = None, |
---|
120 | zscale = 1, |
---|
121 | fail_on_NaN = False, |
---|
122 | ) |
---|
123 | |
---|
124 | |
---|