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

Last change on this file since 6178 was 6178, checked in by ole, 15 years ago

Clean up of Patong script and added new function create_domain_from_regions

File size: 8.5 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=12
63    yieldstep=120
64if setup =='final': 
65    print'final'
66    res_factor=1
67    time_thinning=4
68    yieldstep=60
69
70#------------------------------------------------------------------------------
71# Output Filename
72#------------------------------------------------------------------------------
73# Important to distinguish each run - ensure str(user) is included!
74# Note, the user is free to include as many parameters as desired
75dir_comment='_'+setup+'_'+str(tide)+'_'+str(user)
76
77#------------------------------------------------------------------------------
78# Input Data
79#------------------------------------------------------------------------------
80
81# elevation data used in build_patong.py
82# four textfiles, with different resolutions
83elevation1 = 'patong_10m_grid_msl_Project.txt' 
84elevation2 = 'patong_10m_small_grid_for_anuga_sub_Project.txt'
85elevation3 = 'patong_bay_1s_grid_Project.txt'
86elevation4 = 'andaman_3s_grid_Clip_Project.txt'
87
88# gauges - used in get_timeseries.py
89gauge_name = 'patong.csv'
90
91# BOUNDING POLYGON - used in build_boundary.py and run_patong.py respectively
92# NOTE: when files are put together the points must be in sequence - for ease go clockwise!
93# Check the run_patong.py for boundary_tags
94# thinned ordering file from Hazard Map: format is index,latitude,longitude (with title)
95order_filename = 'thinned_boundary_ordering.csv'
96#landward bounding points
97landward = 'landward_bounding_polygon.csv'
98
99#------------------------------------------------------------------------------
100# Output Elevation Data
101#------------------------------------------------------------------------------
102# Output filename for elevation
103# this is a combination of all the data (utilisied in build_boundary)
104combined_name ='patong_combined_elevation'
105combined_smaller_name = 'patong_combined_elevation_smaller'
106
107#------------------------------------------------------------------------------
108# Directory Structure
109#------------------------------------------------------------------------------
110anuga_dir = home+state+sep+scenario+sep+'anuga'+sep
111topographies_in_dir = home+state+sep+scenario+sep+'elevation_final'+sep+'points'+sep
112topographies_dir = anuga_dir+'topographies'+sep
113polygons_dir = anuga_dir+'polygons'+sep
114tide_dir = anuga_dir+'tide_data'+sep
115boundaries_dir = anuga_dir+'boundaries'+ sep
116output_dir = anuga_dir+'outputs'+sep
117gauges_dir = anuga_dir+'gauges'+sep
118meshes_dir = anuga_dir+'meshes'+sep
119
120#------------------------------------------------------------------------------
121# Location of input and output data
122#------------------------------------------------------------------------------
123# where the input data sits
124elevation_in_dir_name1 = topographies_in_dir + elevation1
125elevation_in_dir_name2 = topographies_in_dir + elevation2
126elevation_in_dir_name3 = topographies_in_dir + elevation3
127elevation_in_dir_name4 = topographies_in_dir + elevation4
128
129# where the output data sits
130elevation_dir_name1 = topographies_dir + elevation1
131elevation_dir_name2 = topographies_dir + elevation2
132elevation_dir_name3 = topographies_dir + elevation3
133elevation_dir_name4 = topographies_dir + elevation4
134
135
136# where the combined elevation file sits
137combined_dir_name = topographies_dir + combined_name
138combined_smaller_name_dir = topographies_dir + combined_smaller_name
139
140# where the mesh sits (this is created during the run_patong.py)
141meshes_dir_name = meshes_dir + scenario_name+'.msh'
142
143# where the boundary ordering files sit (this is used within build_boundary.py)
144order_filename_dir = boundaries_dir + order_filename
145
146# where the landward points of boundary extent sit (this is used within run_patong.py)
147landward_dir = boundaries_dir + landward
148
149# where the directory of the output filename sits
150output_build_time_dir = output_dir+build_time+dir_comment+sep   #used for build_patong.py
151output_run_time_dir = output_dir+run_time+dir_comment+sep       #used for run_patong.py
152output_run_time_dir_name = output_run_time_dir + scenario_name  #Used by post processing
153
154# where the directory of the gauges sit
155gauges_dir_name = gauges_dir + gauge_name       #used for get_timeseries.py
156
157#------------------------------------------------------------------------------
158# Interior region definitions
159#------------------------------------------------------------------------------
160
161# extents of elevation datasets
162extent_elev_dir1 = read_polygon(polygons_dir + 'patong_10m.txt')
163extent_elev_dir2 = read_polygon(polygons_dir + 'saddle_10m.txt')
164extent_elev_dir3 = read_polygon(polygons_dir + 'patong_1s.txt')
165extent_elev_dir4 = read_polygon(polygons_dir + 'patong_10m_aos.txt')
166
167#Land, to set the initial stage/water to be offcoast only
168poly_mainland = read_polygon(polygons_dir+'initial_conditions.csv')
169
170# Initial bounding polygon for data clipping
171poly_all = read_polygon(polygons_dir+'poly_all.csv')
172res_poly_all = 100000*res_factor
173
174# Area of Interest 1 elevation from -10m to 20m
175poly_aoi1 = read_polygon(polygons_dir+'aoi.csv')
176res_aoi1 = 500*res_factor
177
178# Area of Significance 1 elevation from -20m to a 200m buffer of the 20m contour
179poly_aos1 = read_polygon(polygons_dir+'aos.csv')
180res_aos1 = 1000*res_factor
181
182# Area of Shallow water and coastal land that needs a finer res than 1000000
183poly_sw = read_polygon(polygons_dir+'sw.csv')
184res_sw = 2000*res_factor
185
186# Combined all regions, must check that all are included!
187interior_regions = [[poly_aoi1,res_aoi1],[poly_aos1,res_aos1]
188                    ,[poly_sw,res_sw]]
189                 
190   
191trigs_min = number_mesh_triangles(interior_regions, poly_all, res_poly_all)
192print 'min estimated number of triangles', trigs_min
193
194#------------------------------------------------------------------------------
195# Building polygons
196#------------------------------------------------------------------------------
197
198building_polygon_file = polygons_dir+'buildings.csv'
199
200#------------------------------------------------------------------------------
201# Clipping regions for export to asc and regions for clipping data
202# Final inundation maps should only be created in regions of the finest mesh
203#------------------------------------------------------------------------------
204
205#CBD extract ascii grid - cooridnates from patong_1s extent
206xminCBD = 417445.1119
207xmaxCBD = 425601.7881
208yminCBD = 870663.4547
209ymaxCBD = 876965.3856
210
211
Note: See TracBrowser for help on using the repository browser.