1 | # -*- coding: cp1252 -*- |
---|
2 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
3 | Also includes origin for slump scenario. |
---|
4 | """ |
---|
5 | |
---|
6 | from os import sep, environ, getenv, getcwd,umask |
---|
7 | from os.path import expanduser, basename |
---|
8 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon, number_mesh_triangles |
---|
9 | import sys |
---|
10 | from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees |
---|
11 | from time import localtime, strftime, gmtime |
---|
12 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
13 | |
---|
14 | codename = 'project.py' |
---|
15 | |
---|
16 | home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent dir |
---|
17 | user = get_user_name() |
---|
18 | host = get_host_name() |
---|
19 | #needed when running using mpirun, mpirun doesn't inherit umask from .bashrc |
---|
20 | umask(002) |
---|
21 | |
---|
22 | |
---|
23 | #Making assumptions about the location of scenario data |
---|
24 | state = 'western_australia' |
---|
25 | scenario_name = 'broome' |
---|
26 | scenario = 'broome_tsunami_scenario_2006' |
---|
27 | |
---|
28 | #time stuff |
---|
29 | time = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
30 | build_time = time+'_build' |
---|
31 | run_time = time+'_run' |
---|
32 | |
---|
33 | #tide = -5.3 |
---|
34 | #tide = 0 |
---|
35 | tide = 4.9 |
---|
36 | |
---|
37 | #Maybe will try to make project a class to allow these parameters to be passed in. |
---|
38 | alpha = 0.1 |
---|
39 | friction=0.01 |
---|
40 | starttime=3600 |
---|
41 | finaltime=25000 |
---|
42 | setup='trial' |
---|
43 | source='dampier' |
---|
44 | |
---|
45 | if setup =='trial': |
---|
46 | print'trial' |
---|
47 | res_factor=10 |
---|
48 | time_thinning=48 |
---|
49 | yieldstep=240 |
---|
50 | if setup =='basic': |
---|
51 | print'basic' |
---|
52 | res_factor=4 |
---|
53 | time_thinning=12 |
---|
54 | yieldstep=120 |
---|
55 | if setup =='final': |
---|
56 | print'final' |
---|
57 | res_factor=1 |
---|
58 | time_thinning=4 |
---|
59 | yieldstep=60 |
---|
60 | |
---|
61 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(source)+'_'+str(user) |
---|
62 | |
---|
63 | # onshore data from 30m DTED level 2 |
---|
64 | #onshore_name = 'Broome_topography_DLI' # original |
---|
65 | onshore_name = 'town_topo_10m' # original |
---|
66 | onshore_name1 = 'other_topo_250m' # original |
---|
67 | |
---|
68 | # offshore |
---|
69 | offshore_name = 'Broome_Bathymetry' |
---|
70 | #offshore_name1 = 'inferred_north' |
---|
71 | #offshore_name2 = 'inferred_south' |
---|
72 | offshore_name1 = 'north_250m' |
---|
73 | offshore_name2 = 'south_250m' |
---|
74 | offshore_name3 = 'cable_250m' |
---|
75 | coast_name = 'Broome_coastline' |
---|
76 | |
---|
77 | #final topo name |
---|
78 | combined_name ='broome_combined_elevation' |
---|
79 | combined_name1 ='broome_combined_elevation1' |
---|
80 | combined_name_unclipped1 ='broome_combined_elevation_unclipped1' |
---|
81 | combined_small_name = 'broome_combined_elevation_z51_reduced' |
---|
82 | |
---|
83 | anuga_dir = home+state+sep+scenario+sep+'anuga'+sep |
---|
84 | |
---|
85 | topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep+'Feb07'+sep |
---|
86 | topographies_dir = anuga_dir+'topographies'+sep |
---|
87 | |
---|
88 | # input topo file location |
---|
89 | onshore_in_dir_name = topographies_in_dir + onshore_name |
---|
90 | onshore_in_dir_name1 = topographies_in_dir + onshore_name1 |
---|
91 | coast_in_dir_name = topographies_in_dir + coast_name |
---|
92 | offshore_in_dir_name = topographies_in_dir + offshore_name |
---|
93 | offshore_in_dir_name1 = topographies_in_dir + offshore_name1 |
---|
94 | offshore_in_dir_name2 = topographies_in_dir + offshore_name2 |
---|
95 | offshore_in_dir_name3 = topographies_in_dir + offshore_name3 |
---|
96 | |
---|
97 | onshore_dir_name = topographies_dir + onshore_name |
---|
98 | onshore_dir_name1 = topographies_dir + onshore_name1 |
---|
99 | coast_dir_name = topographies_dir + coast_name |
---|
100 | offshore_dir_name = topographies_dir + offshore_name |
---|
101 | offshore_dir_name1 = topographies_dir + offshore_name1 |
---|
102 | offshore_dir_name2 = topographies_dir + offshore_name2 |
---|
103 | offshore_dir_name3 = topographies_dir + offshore_name3 |
---|
104 | |
---|
105 | #final topo files |
---|
106 | combined_dir_name = topographies_dir + combined_name |
---|
107 | combined_dir_name_unclipped1 = topographies_dir + combined_name_unclipped1 |
---|
108 | combined_dir_name1 = topographies_dir + combined_name1 |
---|
109 | combined_small_name_dir = topographies_dir + combined_small_name |
---|
110 | |
---|
111 | meshes_dir = anuga_dir+'meshes'+sep |
---|
112 | meshes_dir_name = meshes_dir + scenario_name |
---|
113 | |
---|
114 | polygons_dir = anuga_dir+'polygons'+sep |
---|
115 | tide_dir = anuga_dir+'tide_data'+sep |
---|
116 | |
---|
117 | if source =='dampier': |
---|
118 | boundaries_name = 'broome_3854_17042007' #Dampier gun |
---|
119 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'dampier'+sep+'1_10000'+sep |
---|
120 | |
---|
121 | if source=='onslow': |
---|
122 | boundaries_name = 'broome_3859_16052007' #onslow_hedland_broome gun |
---|
123 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'onslow_hedland_broome'+sep+'1_10000'+sep |
---|
124 | |
---|
125 | if source=='exmouth': |
---|
126 | boundaries_name = 'broome_3103_18052007' #exmouth gun |
---|
127 | boundaries_in_dir = anuga_dir+'boundaries'+sep+'urs'+sep+'exmouth'+sep+'1_10000'+sep |
---|
128 | |
---|
129 | boundaries_in_dir_name = boundaries_in_dir + boundaries_name |
---|
130 | boundaries_dir = anuga_dir+'boundaries'+sep |
---|
131 | boundaries_dir_name = boundaries_dir + boundaries_name |
---|
132 | |
---|
133 | #output locations |
---|
134 | output_dir = anuga_dir+'outputs'+sep |
---|
135 | output_build_time_dir = output_dir+build_time+'_'+source+sep |
---|
136 | output_run_time_dir = output_dir +run_time+dir_comment+sep |
---|
137 | #output_run_time_dir = output_dir +'20070703_062312_run_final_4.9_dampier_nbartzis'+sep |
---|
138 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
139 | |
---|
140 | #gauges |
---|
141 | gauge_name = 'broome_gauges.csv' |
---|
142 | gauges_dir = home+sep+state+sep+scenario+sep+'anuga'+sep+'gauges'+sep |
---|
143 | gauges_dir_name = gauges_dir + gauge_name |
---|
144 | |
---|
145 | community_filename = gauges_dir + 'CHINS_v2.csv' |
---|
146 | community_broome = gauges_dir + 'community_broome.csv' |
---|
147 | |
---|
148 | buildings_filename = gauges_dir + 'Broome_res_Project.csv' |
---|
149 | buildings_filename_out = output_run_time_dir+'Broome_res_Project_modified.csv' |
---|
150 | |
---|
151 | ############################### |
---|
152 | # Domain definitions |
---|
153 | ############################### |
---|
154 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon |
---|
155 | |
---|
156 | poly_all = read_polygon(polygons_dir+'extent_small.csv') |
---|
157 | # to test update of plot_polygons - now allows points and polygon to be |
---|
158 | # plotted together |
---|
159 | #point = read_polygon(polygons_dir+'neg20_coast_contour_pts.csv') |
---|
160 | #p2 = read_polygon(polygons_dir+'broome_north_coast_inside_extent.csv') |
---|
161 | #label=None |
---|
162 | #plot_polygons([poly_all,point,p2],['line','point','outside'],figname='test',label=label) |
---|
163 | #plot_polygons([poly_all,point],figname='test') |
---|
164 | #poly_all = read_polygon(polygons_dir+'extent.csv') |
---|
165 | res_poly_all = 150000*res_factor |
---|
166 | |
---|
167 | ############################### |
---|
168 | # Interior region definitions |
---|
169 | ############################### |
---|
170 | |
---|
171 | poly_0 = read_polygon(polygons_dir+'neg20_coast_contour_pts.csv') |
---|
172 | res_0 = 20000*res_factor |
---|
173 | |
---|
174 | poly_1 = read_polygon(polygons_dir+'broome_north_coast_inside_extent.csv') |
---|
175 | res_1 = 5000*res_factor |
---|
176 | |
---|
177 | #poly_2 = read_polygon(polygons_dir+'broome_south_coast_inside_extent.csv') |
---|
178 | poly_2 = read_polygon(polygons_dir+'broome_south_coast_not_town_pts_new.csv') |
---|
179 | res_2 = 5000*res_factor |
---|
180 | |
---|
181 | #poly_3 = read_polygon(polygons_dir+'Broome_town_pts.csv') |
---|
182 | poly_3 = read_polygon(polygons_dir+'broome_town_new_ptsa.csv') |
---|
183 | res_3 = 2000*res_factor |
---|
184 | |
---|
185 | #poly_4 = read_polygon(polygons_dir+'Broome_inner_town_pts.csv') |
---|
186 | poly_4 = read_polygon(polygons_dir+'broome_inner_town_new_ptsa.csv') |
---|
187 | res_4 = 500*res_factor |
---|
188 | |
---|
189 | interior_regions = [[poly_0,res_0],[poly_1,res_1],[poly_2,res_2] |
---|
190 | ,[poly_3,res_3],[poly_4,res_4]] |
---|
191 | |
---|
192 | boundary_tags={'back': [1, 2], |
---|
193 | 'side': [0,3], |
---|
194 | 'ocean': [4]} |
---|
195 | |
---|
196 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
197 | |
---|
198 | print 'min number triangles', trigs_min |
---|
199 | |
---|
200 | poly_mainland = read_polygon(polygons_dir+'Initial_Condition.csv') |
---|
201 | |
---|
202 | ################################################################### |
---|
203 | # Clipping regions for export to asc and regions for clipping data |
---|
204 | ################################################################### |
---|
205 | |
---|
206 | # exporting asc grid |
---|
207 | eastingmin = 412000.0 |
---|
208 | eastingmax = 423000.0 |
---|
209 | northingmin = 8007000.0 |
---|
210 | northingmax = 8022000.0 |
---|
211 | |
---|
212 | # exporting asc grid for speed |
---|
213 | #eastingmin = 412900.0 |
---|
214 | #eastingmax = 422700.0 |
---|
215 | #northingmin = 8008555.0 |
---|
216 | #northingmax = 8021350.0 |
---|