source: anuga_work/production/patong/project.py @ 6321

Last change on this file since 6321 was 6321, checked in by kristy, 15 years ago

Adjusted for larger area, not running yet

File size: 9.6 KB
Line 
1"""Common filenames and locations for elevation, meshes and outputs.
2This script is the heart of all scripts in the folder
3"""
4#------------------------------------------------------------------------------
5# Import necessary modules
6#------------------------------------------------------------------------------
7
8from os import sep, environ, getenv, getcwd
9from os.path import expanduser
10import sys
11from time import localtime, strftime, gmtime
12from anuga.utilities.polygon import read_polygon, plot_polygons, is_inside_polygon, number_mesh_triangles
13from anuga.utilities.system_tools import get_user_name, get_host_name
14from anuga.shallow_water.data_manager import urs2sts,create_sts_boundary
15from anuga.utilities.polygon import read_polygon, plot_polygons, polygon_area, is_inside_polygon
16
17#------------------------------------------------------------------------------
18# Directory setup
19#------------------------------------------------------------------------------
20# Note: INUNDATIONHOME is the inundation directory, not the data directory.
21
22home = getenv('INUNDATIONHOME') + sep +'data'+sep #Sandpit's parent diruser = get_user_name()
23user = get_user_name()
24host = get_host_name()
25
26# determines time for setting up output directories
27time = strftime('%Y%m%d_%H%M%S',localtime()) 
28gtime = strftime('%Y%m%d_%H%M%S',gmtime()) 
29build_time = time+'_build'
30run_time = time+'_run'
31
32#------------------------------------------------------------------------------
33# Initial Conditions
34#------------------------------------------------------------------------------
35
36# this section needs to be updated to reflect the modelled community.
37# Note, the user needs to set up the directory system accordingly
38state = 'thailand'
39scenario_name = 'patong'
40scenario = 'patong_tsunami_scenario'
41
42# Model specific parameters. One or all can be changed each time the
43# run_scenario script is executed
44tide = 0.8               #0.8
45alpha = 0.1             # smoothing parameter for mesh
46friction=0.01           # manning's friction coefficient
47starttime=0             
48finaltime=15000         # final time for simulation 15000
49
50setup='trial'  # Final can be replaced with trial or basic.
51               # Either will result in a coarser mesh that will allow a
52               # faster, but less accurate, simulation.
53
54if setup =='trial':
55    print'trial'
56    res_factor=10
57    time_thinning=48
58    yieldstep=240
59if setup =='basic': 
60    print'basic'
61    res_factor=4
62    time_thinning=24
63    yieldstep=120
64if setup =='final': 
65    print'final'
66    res_factor=1
67    time_thinning=4
68    yieldstep=10
69
70use_buildings = True
71
72#------------------------------------------------------------------------------
73# Output Filename
74#------------------------------------------------------------------------------
75# Important to distinguish each run - ensure str(user) is included!
76# Note, the user is free to include as many parameters as desired
77if use_buildings:
78    dir_comment='_'+setup+'_'+str(tide)+'_buildings_'+str(user)
79else:
80    dir_comment='_'+setup+'_'+str(tide)+'_nobuildings_'+str(user)   
81
82#------------------------------------------------------------------------------
83# Input Data
84#------------------------------------------------------------------------------
85
86# elevation data used in build_patong.py
87# four textfiles, with different resolutions
88elevation1 = 'patong_10m_grid_msl_Project.txt' 
89elevation2 = 'patong_10m_small_grid_for_anuga_sub_Project.txt'
90elevation3 = 'patong_bay_1s_grid_Project.txt'
91elevation4 = 'andaman_3s_grid_Clip2_Project.txt'
92
93# gauges - used in get_timeseries.py
94gauge_name = 'gauges.csv'
95
96# BOUNDING POLYGON - used in build_boundary.py and run_patong.py respectively
97# NOTE: when files are put together the points must be in sequence - for ease go clockwise!
98# Check the run_patong.py for boundary_tags
99# thinned ordering file from Hazard Map: format is index,latitude,longitude (with title)
100order_filename = 'urs_order.csv'
101#landward bounding points
102landward = 'landward_bounding_polygon2.csv'
103
104#------------------------------------------------------------------------------
105# Output Elevation Data
106#------------------------------------------------------------------------------
107# Output filename for elevation
108# this is a combination of all the data (utilisied in build_boundary)
109combined_name ='patong_combined_elevation_large'
110combined_smaller_name = 'patong_combined_elevation_smaller'
111
112#------------------------------------------------------------------------------
113# Directory Structure
114#------------------------------------------------------------------------------
115anuga_dir = home+state+sep+scenario+sep+'anuga'+sep
116topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep
117topographies_dir = anuga_dir+'topographies'+sep
118polygons_dir = anuga_dir+'polygons'+sep
119tide_dir = anuga_dir+'tide_data'+sep
120boundaries_dir = anuga_dir+'boundaries'+ sep
121output_dir = anuga_dir+'outputs'+sep
122gauges_dir = anuga_dir+'gauges'+sep
123meshes_dir = anuga_dir+'meshes'+sep
124
125#------------------------------------------------------------------------------
126# Location of input and output data
127#------------------------------------------------------------------------------
128# where the input data sits
129elevation_in_dir_name1 = topographies_in_dir + elevation1
130elevation_in_dir_name2 = topographies_in_dir + elevation2
131elevation_in_dir_name3 = topographies_in_dir + elevation3
132elevation_in_dir_name4 = topographies_in_dir + elevation4
133
134# where the output data sits
135elevation_dir_name1 = topographies_dir + elevation1
136elevation_dir_name2 = topographies_dir + elevation2
137elevation_dir_name3 = topographies_dir + elevation3
138elevation_dir_name4 = topographies_dir + elevation4
139
140
141# where the combined elevation file sits
142combined_dir_name = topographies_dir + combined_name + '_data'
143combined_smaller_name_dir = topographies_dir + combined_smaller_name
144
145# where the mesh sits (this is created during the run_patong.py)
146meshes_dir_name = meshes_dir + scenario_name+'_poly.msh'
147
148# where the boundary ordering files sit (this is used within build_boundary.py)
149order_filename_dir = boundaries_dir + order_filename
150
151# where the landward points of boundary extent sit (this is used within run_patong.py)
152landward_dir = boundaries_dir + landward
153
154# where the directory of the output filename sits
155output_build_time_dir = output_dir+build_time+dir_comment+sep   #used for build_patong.py
156output_run_time_dir = output_dir+run_time+dir_comment+sep       #used for run_patong.py
157output_run_time_dir_name = output_run_time_dir + scenario_name  #Used by post processing
158
159# where the directory of the gauges sit
160gauges_dir_name = gauges_dir + gauge_name       #used for get_timeseries.py
161
162#------------------------------------------------------------------------------
163# Interior region definitions
164#------------------------------------------------------------------------------
165
166# extents of elevation datasets
167extent_elev_dir1 = read_polygon(polygons_dir + 'patong_10m.txt')
168extent_elev_dir2 = read_polygon(polygons_dir + 'saddle_10m.txt')
169extent_elev_dir3 = read_polygon(polygons_dir + 'patong_1s.txt')
170extent_elev_dir4 = read_polygon(polygons_dir + 'patong_10m_aos.txt')
171
172#Land, to set the initial stage/water to be offcoast only
173poly_mainland = read_polygon(polygons_dir+'initial_conditions.csv')
174
175# Initial bounding polygon for data clipping
176poly_all = read_polygon(polygons_dir+'bounding_polygon.csv')
177res_poly_all = 150000*res_factor
178
179
180# Inundation area
181poly_ia = read_polygon(polygons_dir+'inundation_area.csv')
182res_ia = 75*res_factor
183poly_saddle = read_polygon(polygons_dir+'saddle_10m.txt') 
184
185# Area of Interest 1 elevation from -10m to 20m
186poly_aoi1 = read_polygon(polygons_dir+'aoi.csv')
187res_aoi1 = 200*res_factor
188
189# Area of Significance 1 elevation from -20m to a 200m buffer of the 20m contour
190poly_aos1 = read_polygon(polygons_dir+'aos.csv')
191res_aos1 = 900*res_factor
192
193
194# Area of Shallow water and coastal land that needs a finer res than 1000000
195poly_sw = read_polygon(polygons_dir+'sw.csv')
196res_sw = 6000*res_factor
197
198
199
200# Area of buildings
201building_main = read_polygon(polygons_dir+'building_main.csv')
202building_main_small = read_polygon(polygons_dir+'building_main_small.csv')
203building_main_south = read_polygon(polygons_dir+'building_main_south.csv')
204building_saddle = read_polygon(polygons_dir+'building_saddle.csv')
205building_area_polygons = [building_main, building_main_small, building_main_south, building_saddle]
206bld_res = 25*res_factor
207
208
209
210
211# Combined all regions, must check that all are included!
212interior_regions = [[poly_ia, res_ia],
213                    #[poly_saddle, res_ia],
214                    [poly_aoi1,res_aoi1],
215                    [poly_aos1,res_aos1],
216                    [poly_sw,res_sw],
217                    [building_main, bld_res],
218                    [building_main_small, bld_res],                   
219                    [building_main_south, bld_res],
220                    [building_saddle, bld_res]]
221                 
222   
223trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all)
224print 'min estimated number of triangles', trigs_min
225
226#------------------------------------------------------------------------------
227# Building polygons
228#------------------------------------------------------------------------------
229
230building_polygon_file = polygons_dir+'buildings.csv'
231
232#------------------------------------------------------------------------------
233# Clipping regions for export to asc and regions for clipping data
234# Final inundation maps should only be created in regions of the finest mesh
235#------------------------------------------------------------------------------
236
237#CBD extract ascii grid - coordinates from patong_1s extent
238xminCBD = 417445.1119
239xmaxCBD = 425601.7881
240yminCBD = 870663.4547
241ymaxCBD = 876965.3856
242
243
Note: See TracBrowser for help on using the repository browser.