1 | """Common filenames and locations for topographic data, meshes and outputs. |
---|
2 | Also includes origin for slump scenario. |
---|
3 | |
---|
4 | All filenames are given without extension |
---|
5 | """ |
---|
6 | |
---|
7 | from os import sep, environ, getenv, getcwd, umask |
---|
8 | from os.path import expanduser, basename, join |
---|
9 | from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon, number_mesh_triangles |
---|
10 | import sys |
---|
11 | from anuga.coordinate_transforms.redfearn import degminsec2decimal_degrees |
---|
12 | from time import localtime, strftime, gmtime |
---|
13 | from anuga.utilities.system_tools import get_user_name, get_host_name |
---|
14 | |
---|
15 | codename = 'project.py' # FIXME can be obtained automatically as __file__ |
---|
16 | |
---|
17 | home = join(getenv('INUNDATIONHOME'), 'data') # Location of Data |
---|
18 | user = get_user_name() |
---|
19 | host = get_host_name() |
---|
20 | #needed when running using mpirun, mpirun doesn't inherit umask from .bashrc |
---|
21 | umask(002) |
---|
22 | |
---|
23 | #Making assumptions about the location of scenario data |
---|
24 | state = 'western_australia' |
---|
25 | scenario_name = 'shark_bay' |
---|
26 | scenario = 'shark_bay_tsunami_scenario' |
---|
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 = -3.9 |
---|
34 | #tide = 0.0 |
---|
35 | tide = 3.6 |
---|
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 | finaltime=25000 |
---|
41 | starttime=3600 |
---|
42 | setup='final' |
---|
43 | source='shark_bay' |
---|
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.1 |
---|
58 | time_thinning=4 |
---|
59 | yieldstep=60 |
---|
60 | |
---|
61 | |
---|
62 | dir_comment='_'+setup+'_'+str(tide)+'_'+str(source)+'_'+str(user) |
---|
63 | |
---|
64 | # elevation data filenames |
---|
65 | ascii_grid_filenames = ['10m_dem_without_survey', '50m_dem_without_10m_dem'] |
---|
66 | point_filenames = ['field_survey_north', 'field_survey_south', |
---|
67 | 'clipped_bathymetry_final', 'coast_points_final'] |
---|
68 | |
---|
69 | #final topo name |
---|
70 | combined_name ='shark_bay_combined_elevation' |
---|
71 | combined_small_name = 'shark_bay_combined_elevation_small' |
---|
72 | |
---|
73 | |
---|
74 | anuga_dir = join(home, state, scenario, 'anuga') |
---|
75 | |
---|
76 | topographies_in_dir = join(home, state, scenario, 'elevation_final', 'test_area') |
---|
77 | topographies_dir = join(anuga_dir, 'topographies') # Output dir for ANUGA |
---|
78 | |
---|
79 | # Convert topo file locations into absolute pathnames |
---|
80 | for filename_list in [ascii_grid_filenames, point_filenames]: |
---|
81 | for i, filename in enumerate(filename_list): |
---|
82 | filename_list[i] = join(topographies_in_dir, filename) |
---|
83 | |
---|
84 | #final topo files |
---|
85 | combined_dir_name = join(topographies_dir, combined_name) |
---|
86 | combined_small_dir_name = join(topographies_dir, combined_small_name) |
---|
87 | |
---|
88 | |
---|
89 | meshes_dir = join(anuga_dir, 'meshes') |
---|
90 | meshes_dir_name = join(meshes_dir, scenario_name) |
---|
91 | |
---|
92 | |
---|
93 | polygons_dir = join(anuga_dir, 'polygons') # Created with ArcGIS (csv files) |
---|
94 | tide_dir = join(anuga_dir, 'tide_data') |
---|
95 | |
---|
96 | |
---|
97 | # locations for boundary conditions |
---|
98 | if source=='shark_bay': |
---|
99 | boundaries_file_name = 'shark_bay_3867_18052007' |
---|
100 | boundaries_dir = join(anuga_dir, 'boundaries', 'shark_bay', '1_10000') |
---|
101 | |
---|
102 | boundaries_name = join(boundaries_dir, boundaries_file_name) |
---|
103 | |
---|
104 | #output locations |
---|
105 | output_dir = join(anuga_dir, 'outputs') |
---|
106 | output_build_time_dir = output_dir+build_time+sep |
---|
107 | output_run_time_dir = output_dir +run_time+dir_comment+sep |
---|
108 | output_run_time_dir_name = output_run_time_dir + scenario_name #Used by post processing |
---|
109 | |
---|
110 | #gauges |
---|
111 | #gauge_name = 'gauge_location_port_hedland.csv' |
---|
112 | #gauge_name_test = 'gauge_checking_test.csv' |
---|
113 | #gauges_dir = anuga_dir+'gauges'+sep |
---|
114 | #gauges_dir_name = gauges_dir + gauge_name |
---|
115 | #gauges_dir_name_test = gauges_dir + gauge_name_test |
---|
116 | |
---|
117 | #tide_dir = anuga_dir+'tide_data'+sep |
---|
118 | |
---|
119 | #buildings_filename = gauges_dir + 'pt_hedland_res.csv' |
---|
120 | #buildings_filename_out = 'pt_hedland_res_modified.csv' |
---|
121 | #buildings_filename_damage_out = 'pt_hedland_res_modified_damage.csv' |
---|
122 | #tidal_filename = tide_dir + 'pt_hedland_tide.txt' |
---|
123 | #community_filename = gauges_dir + 'CHINS_v2.csv' |
---|
124 | #community_scenario = gauges_dir + 'community_pt_hedland.csv' |
---|
125 | |
---|
126 | # clipping region to make DEM (pts file) from onshore data |
---|
127 | #eastingmin = 594000 |
---|
128 | #eastingmax = 715000 |
---|
129 | #northingmin = 7720000 |
---|
130 | #northingmax = 7880000 |
---|
131 | |
---|
132 | # for ferret2sww |
---|
133 | south = degminsec2decimal_degrees(-20,30,0) |
---|
134 | north = degminsec2decimal_degrees(-17,10,0) |
---|
135 | west = degminsec2decimal_degrees(117,00,0) |
---|
136 | east = degminsec2decimal_degrees(120,00,0) |
---|
137 | |
---|
138 | # region to export (used from export_results.py) |
---|
139 | #e_min_area = 648000 # Eastings min |
---|
140 | #e_max_area = 675000 |
---|
141 | #n_min_area = 7745000 |
---|
142 | #n_max_area = 7761000 |
---|
143 | |
---|
144 | #export_region = [[e_min_area,n_min_area],[e_min_area,n_max_area], |
---|
145 | # [e_max_area,n_max_area],[e_max_area,n_min_area]] |
---|
146 | |
---|
147 | |
---|
148 | #from anuga.coordinate_transforms.redfearn import redfearn |
---|
149 | poly_all = read_polygon(join(polygons_dir, 'boundary_extent.csv')) |
---|
150 | res_poly_all = 250000*res_factor |
---|
151 | |
---|
152 | #Interior regions |
---|
153 | poly_inundated_area = read_polygon(join(polygons_dir, 'inundated_area.csv')) |
---|
154 | res_inundated_area = 50000*res_factor |
---|
155 | |
---|
156 | poly_bay_area = read_polygon(join(polygons_dir, 'bay_area.csv')) |
---|
157 | res_bay_area = 100000*res_factor |
---|
158 | |
---|
159 | interior_regions = [[poly_bay_area, res_bay_area], [poly_inundated_area, res_inundated_area]] |
---|
160 | |
---|
161 | trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all) |
---|
162 | |
---|
163 | print 'min number triangles', trigs_min |
---|
164 | |
---|
165 | |
---|