1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
2 | |
---|
3 | All filenames are given without extension |
---|
4 | """ |
---|
5 | |
---|
6 | from os import sep, environ, getenv, getcwd, umask |
---|
7 | from os.path import expanduser, basename, join |
---|
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_grad.py' # FIXME can be obtained automatically as __file__ |
---|
15 | |
---|
16 | home = join(getenv('INUNDATIONHOME'), 'data') # Location of Data |
---|
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 | #Making assumptions about the location of scenario data |
---|
23 | state = 'western_australia' |
---|
24 | scenario_name = 'onslow' |
---|
25 | scenario = 'onslow_tsunami_scenario_2006' |
---|
26 | |
---|
27 | #time stuff |
---|
28 | time = strftime('%Y%m%d_%H%M%S',gmtime()) #gets time for new dir |
---|
29 | build_time = time+'_build' |
---|
30 | run_time = time+'_run' |
---|
31 | |
---|
32 | #tide = 0.0 # MSL |
---|
33 | tide = 1.5 # HAT |
---|
34 | #tide = -1.5 # LAT |
---|
35 | |
---|
36 | #Maybe will try to make project a class to allow these parameters to be passed in. |
---|
37 | alpha = 0.1 |
---|
38 | friction = 0.01 |
---|
39 | finaltime = 40000 |
---|
40 | starttime = 3600 # Action starts around 9000 |
---|
41 | #setup='final' |
---|
42 | setup = 'trial' |
---|
43 | #which_data = 'original' |
---|
44 | which_data = 'revised' |
---|
45 | boundary_event = 'onslow' |
---|
46 | |
---|
47 | boundary_event = 'exmouth' |
---|
48 | #boundary_event = 'onslow' |
---|
49 | #boundary_event = 'dampier' |
---|
50 | |
---|
51 | if setup =='trial': |
---|
52 | print'trial' |
---|
53 | res_factor=10 |
---|
54 | time_thinning=48 |
---|
55 | yieldstep=240 |
---|
56 | if setup =='basic': |
---|
57 | print'basic' |
---|
58 | res_factor=4 |
---|
59 | time_thinning=12 |
---|
60 | yieldstep=120 |
---|
61 | if setup =='final': |
---|
62 | print'final' |
---|
63 | res_factor=1.0 |
---|
64 | time_thinning=4 |
---|
65 | yieldstep=60 |
---|
66 | |
---|
67 | anuga_dir = join(home, state, scenario, 'anuga') |
---|
68 | |
---|
69 | topographies_in_dir = join(anuga_dir, 'topographies') |
---|
70 | |
---|
71 | topographies_dir = join(anuga_dir, 'topographies') # Output dir for ANUGA |
---|
72 | |
---|
73 | if boundary_event =='dampier': |
---|
74 | boundaries_name = 'onslow_3854_17042007' #Dampier gun |
---|
75 | boundaries_in_dir = join(anuga_dir,'boundaries','urs','dampier','1_10000') |
---|
76 | |
---|
77 | if boundary_event=='onslow': |
---|
78 | boundaries_name = 'onslow_3859_16052007' #onslow_hedland_broome gun |
---|
79 | boundaries_in_dir = join(anuga_dir,'boundaries','urs','onslow_hedland_broome','1_10000') |
---|
80 | |
---|
81 | if boundary_event=='exmouth': |
---|
82 | boundaries_name = 'onslow_3103_18052007' #exmouth gun |
---|
83 | boundaries_in_dir = join(anuga_dir,'boundaries','urs','exmouth','1_10000') |
---|
84 | |
---|
85 | dir_comment='_'+setup+'_'+str(tide)+'_'+\ |
---|
86 | str(user)+'_'+boundary_event+'_'+which_data |
---|
87 | |
---|
88 | |
---|
89 | # elevation data filenames |
---|
90 | |
---|
91 | if which_data == 'original': |
---|
92 | ascii_grid_filenames = ['onslow_onshore_20m_dli', 'onslow_islands_dted2'] |
---|
93 | point_filenames = ['onslow_offshore_points', 'onslow_coast'] |
---|
94 | |
---|
95 | if which_data == 'revised': |
---|
96 | ascii_grid_filenames = ['revised_onshore_20m_dli', 'onslow_islands_dted2'] |
---|
97 | point_filenames = ['onslow_offshore_points', 'revised_coastline', |
---|
98 | 'beach_survey', 'ONS16FINAL', 'ONS17FINAL', 'ONS18FINAL' ] |
---|
99 | |
---|
100 | # final topo name |
---|
101 | combined_name ='onslow_combined_elevation_grad_%s' %which_data |
---|
102 | combined_small_name = 'onslow_combined_elevation_grad' |
---|
103 | |
---|
104 | |
---|
105 | # Convert topo file locations into absolute pathnames |
---|
106 | for filename_list in [ascii_grid_filenames, point_filenames]: |
---|
107 | for i, filename in enumerate(filename_list): |
---|
108 | filename_list[i] = join(topographies_in_dir, filename) |
---|
109 | |
---|
110 | #final topo files |
---|
111 | combined_dir_name = join(topographies_dir, combined_name) |
---|
112 | combined_small_dir_name = join(topographies_dir, combined_small_name) |
---|
113 | |
---|
114 | mesh_dir = join(anuga_dir, 'meshes') |
---|
115 | mesh_name = join(mesh_dir, scenario_name) |
---|
116 | |
---|
117 | polygons_dir = join(anuga_dir, 'polygons') # Created with ArcGIS (csv files) |
---|
118 | tide_dir = join(anuga_dir, 'tide_data') |
---|
119 | |
---|
120 | #output locations |
---|
121 | output_dir = join(anuga_dir, 'outputs')+sep |
---|
122 | output_build_time_dir = output_dir+build_time+sep |
---|
123 | output_run_time_dir = output_dir +run_time+dir_comment+sep |
---|
124 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
125 | |
---|
126 | #gauges |
---|
127 | gauges_dir = join(anuga_dir,'gauges') |
---|
128 | gauge_name = 'gauge_location_onslow.csv' |
---|
129 | gauges_dir_name = gauges_dir + gauge_name |
---|
130 | |
---|
131 | #buildings_filename = gauges_dir + 'Onslow_res_Project.csv' |
---|
132 | #buildings_filename_out = 'Onslow_res_Project_modified.csv' |
---|
133 | |
---|
134 | # for ferret2sww |
---|
135 | south = degminsec2decimal_degrees(-20,30,0) |
---|
136 | north = degminsec2decimal_degrees(-17,10,0) |
---|
137 | west = degminsec2decimal_degrees(117,00,0) |
---|
138 | east = degminsec2decimal_degrees(120,00,0) |
---|
139 | |
---|
140 | # region to export (used from export_results.py) |
---|
141 | e_min_area = 300000 # Eastings min |
---|
142 | e_max_area = 310000 |
---|
143 | n_min_area = 7600000 |
---|
144 | n_max_area = 7610000 |
---|
145 | # for old onslow town |
---|
146 | ##e_min_area = 300000 # Eastings min |
---|
147 | ##e_max_area = 310000 |
---|
148 | ##n_min_area = 7600000 |
---|
149 | ##n_max_area = 7610000 |
---|
150 | |
---|
151 | #FIXME (Ole): It is bad to read in polygons in project.py. If a file does not exist |
---|
152 | #project.py cannot be imported |
---|
153 | |
---|
154 | # Bounding polygon |
---|
155 | bounding_polygon = read_polygon(join(polygons_dir, 'domain.csv')) |
---|
156 | res_bounding_polygon = 500000*res_factor |
---|
157 | |
---|
158 | # Interior regions |
---|
159 | interior_regions_and_resolutions = { |
---|
160 | 'inner_region': 5000, |
---|
161 | 'region_50m': 50000, |
---|
162 | 'onslow_v2': 500, |
---|
163 | 'beach_left': 200, |
---|
164 | 'beach_right': 200} |
---|
165 | |
---|
166 | # Domain |
---|
167 | boundary_tags = {'back': [4, 5], |
---|
168 | 'side': [3, 6], |
---|
169 | 'ocean': [0, 1, 2]} |
---|
170 | |
---|
171 | interior_regions = [] # Consider using dictionary for mesh interface. |
---|
172 | for area_name in interior_regions_and_resolutions.keys(): |
---|
173 | file_name = join(polygons_dir, area_name + '.csv') |
---|
174 | |
---|
175 | print 'Reading polygon from', file_name |
---|
176 | polygon = read_polygon(file_name) |
---|
177 | base_resolution = interior_regions_and_resolutions[area_name] |
---|
178 | |
---|
179 | interior_regions.append([polygon, base_resolution*res_factor]) |
---|
180 | |
---|
181 | trigs_min = number_mesh_triangles(interior_regions, |
---|
182 | bounding_polygon, |
---|
183 | res_bounding_polygon) |
---|
184 | |
---|
185 | onshore_polygon = read_polygon(join(home, state, scenario,'elevation_final','points', |
---|
186 | 'InitialCondition_points.csv')) |
---|