source: anuga_work/development/cocos/grid_data.py @ 4832

Last change on this file since 4832 was 4832, checked in by nick, 16 years ago

add cocos island interpolation test

File size: 7.4 KB
Line 
1
2
3from anuga.geospatial_data.geospatial_data import *
4from anuga.pmesh.mesh_interface import create_mesh_from_regions
5from anuga.shallow_water import Domain
6from anuga.shallow_water import Reflective_boundary
7from anuga.shallow_water.data_manager import export_grid
8from math import sqrt
9
10data_dir='/d/ehn/4/ehn/tsunami/data/bathymetry/Cocos/bathymetry/'
11data_dir_name = data_dir + 'new_edited_cocos_final'
12
13data_dir_name_small=data_dir_name+'_small'
14data_dir_name_smaller=data_dir_name+'_smaller'
15data_dir_name_small_clip=data_dir_name+'_small_clip'
16data_dir_name_clip=data_dir_name+'_clip'
17#print'create Geospatial data2 objects from coast'
18#G = Geospatial_data(file_name = data_dir_name + '.txt')
19#print'start split'
20#G_small, G_other = G.split(factor=0.1, verbose=True)
21#print'start export'
22#G_small.export_points_file(data_dir_name_smaller + '.txt')
23
24mesh_file=data_dir+'cocos.msh'
25sww_file='test_final'
26
27#grid1_north_max=8783110.00
28#grid1_north_min=8565314.80
29#grid1_east_max=439850.00
30#grid1_east_min=156494.00
31#
32#grid2_north_max=8713178.04
33#grid2_north_min=8625096.92
34#grid2_east_max=294652.80
35#grid2_east_min=224424.96
36#
37#grid3_north_max=274295.91
38#grid3_north_min=266767.44
39#grid3_east_max=8665112.56
40#grid3_east_min=8657346.91
41#
42#grid4_north_max=270900.24
43#grid4_north_min=269701.45
44#grid4_east_max=8659120.05
45#grid4_east_min=8659120.05
46
47poly1 = [[439850.00,8565314.80],[439850.00, 8783110.00],
48        [156494.00,8783110.00],[156494.00,8565314.80]]
49#        68450m2
50
51poly2 = [[294652.80,8625096.92],[294652.80,8713178.04],
52         [224424.96,8713178.04],[224424.96,8625096.92]]
53#        2738m2
54
55poly3 = [[274295.91,8657346.91],[274295.91,8665112.56],
56         [266767.44,8665112.56],[266767.44,8657346.91]]
57#        110m2
58       
59poly4 = [[270900.24,8659120.05],[270900.24,8660170.84],
60         [269701.45,8660170.84],[269701.45,8659120.05]]
61#        4.3m2
62
63res = 1
64#G = Geospatial_data(file_name = data_dir_name + '.txt')
65#G1=G.clip(poly1)
66#G1.export_points_file(data_dir_name_clip + '.txt')
67
68
69interior_polys = [[poly2,2740*res],[poly3,110*res],[poly4,4.3*res]]
70#interior_polys = [[poly4,4.3*res]]
71
72#create_mesh_from_regions(poly1,
73#                         boundary_tags={'side': [0,1,2,3]},
74#                         maximum_triangle_area=68500*res,
75#                         interior_regions=interior_polys,
76#                         filename=mesh_file,
77#                         use_cache=True,
78#                         verbose=True)
79create_mesh_from_regions(poly1,
80#create_mesh_from_regions(poly3,
81                         boundary_tags={'side': [0,1,2,3]},
82                         maximum_triangle_area=68500*res,
83#                         maximum_triangle_area=110*res,
84                         interior_regions=interior_polys,
85                         filename=mesh_file,
86                         use_cache=True,
87                         verbose=True)
88                         
89                         
90value, alpha = find_optimal_smoothing_parameter(data_file=data_dir_name_clip + '.txt', 
91                                             alpha_list=[0.0001,0.001,0.01,0.1,1.0],
92#                                             alpha_list=[0.01],
93                                             boundary_poly=poly3,
94                                             mesh_file=mesh_file,
95                                             plot_name=None,
96                                             cache=True,
97                                             verbose=True)
98                                             
99print 'Setup computational domain', value, alpha
100
101    #domain = cache(Domain, (meshes_dir_name), {'use_cache':True, 'verbose':True}, verbose=True)
102    #above don't work
103domain = Domain(mesh_file, use_cache=True, verbose=True)
104
105print 'Start Set quantity'
106
107domain.set_quantity('elevation', 
108                            filename = data_dir_name_clip + '.txt',
109                            use_cache = True,
110                            verbose = True,
111                            alpha = alpha)
112print 'Finished Set quantity'
113
114domain.set_name(sww_file)
115domain.set_datadir(data_dir)
116domain.set_default_order(2) # Apply second order scheme
117domain.set_minimum_storable_height(0.01) # Don't store anything less than 1cm
118domain.set_store_vertices_uniquely(False)
119domain.set_quantities_to_be_stored(['stage', 'xmomentum', 'ymomentum'])
120#    domain.set_maximum_allowed_speed(0.1) # Allow a little runoff (0.1 is OK)
121domain.beta_h = 0
122Br = Reflective_boundary(domain)
123
124
125domain.set_boundary({'side': Br})
126
127for t in domain.evolve(yieldstep = 1,finaltime =1): 
128        domain.write_time()
129        domain.write_boundary_statistics(tags = 'side') 
130
131export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid4',
132                    quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
133                    timestep = None,
134                    reduction = max,
135                    cellsize = 2.96*sqrt(res),
136                    NODATA_value = -9999,
137                    easting_min = 269701.45,
138                    easting_max = 270900.24,
139                    northing_min = 8659120.05,
140                    northing_max = 8660170.84,
141                    verbose = True,
142                    origin = None,
143                    datum = 'WGS84',
144                    format = 'asc')
145                         
146export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid3',
147                    quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
148                    timestep = None,
149                    reduction = max,
150                    cellsize = 14.82*sqrt(res),
151                    NODATA_value = -9999,
152                    easting_min = 266767.44,
153                    easting_max = 274295.91,
154                    northing_min = 8657346.91,
155                    northing_max = 8665112.56,
156                    verbose = True,
157                    origin = None,
158                    datum = 'WGS84',
159                    format = 'asc')
160
161export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid2',
162                    quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
163                    timestep = None,
164                    reduction = max,
165                    cellsize = 74.08*sqrt(res),
166                    NODATA_value = -9999,
167                    easting_min = 224424.96,
168                    easting_max = 294652.80,
169                    northing_min = 8625096.92,
170                    northing_max = 8713178.04,
171                    verbose = True,
172                    origin = None,
173                    datum = 'WGS84',
174                    format = 'asc')
175
176export_grid(data_dir+sww_file+".sww", extra_name_out = 'grid1',
177                    quantities = ['elevation'], # '(xmomentum**2 + ymomentum**2)**0.5' defaults to elevation
178                    timestep = None,
179                    reduction = max,
180                    cellsize = 370.4*sqrt(res),
181                    NODATA_value = -9999,
182                    easting_min = 156494.00,
183                    easting_max = 439850.00,
184                    northing_min = 8565314.80,
185                    northing_max = 8783110.00,
186                    verbose = True,
187                    origin = None,
188                    datum = 'WGS84',
189                    format = 'asc')
190
191
192
193
Note: See TracBrowser for help on using the repository browser.