source: anuga_work/production/new_south_wales/batemans_bay/export_results_max.py @ 7608

Last change on this file since 7608 was 7608, checked in by jgriffin, 14 years ago

Added bed shear stress calculation to export_results_max.py
Added more probabilistic events to project.py

File size: 9.2 KB
Line 
1"""
2Generates ascii grids of nominated areas -
3Input: sww file from run_model.py
4       boundaries for grids from project.py
5Outputs: ascii grids of specified variables
6Stored in the 'outputs_folder' folder for respective .sww file
7
8Note:
9If producing a grid for the enitre extent cellsize should be greater than 30m
10If producing grids for inundation area resolution should be greater than mesh (ie ~22m)
11"""
12
13import project, os
14import sys
15from os.path import join
16from anuga.lib.maxasc.maxasc import MaxAsc
17from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
18from anuga.shallow_water.data_manager import sww2dem
19from os import sep
20
21
22directory = project.output_folder
23
24time_dirs =['20090422_162054_run_final_0.0_58368_jgriffin',
25            '20090422_162114_run_final_0.0_51436_jgriffin',
26            '20090520_144937_run_final_0.0_58272_jgriffin',
27            '20090520_145156_run_final_1.0_58272_jgriffin',
28            '20090520_145453_run_final_0.0_58115_jgriffin',
29            '20090520_145510_run_final_0.0_58129_jgriffin',
30            '20090520_145608_run_final_0.0_58226_jgriffin',
31            '20090520_145616_run_final_0.0_58284_jgriffin',
32            '20090520_145700_run_final_0.0_58286_jgriffin',
33            '20090525_093040_run_final_1.0_51445_jgriffin',
34            '20090528_143200_run_final_1.0_51204_jgriffin',
35            '20090528_143323_run_final_1.0_58346_jgriffin',
36            '20090528_153025_run_final_0.0_58346_jgriffin',
37            '20090528_153109_run_final_0.0_51204_jgriffin',
38            '20090529_143332_run_final_0.0_51378_jgriffin',
39            '20090529_143419_run_final_0.0_51077_jgriffin',
40            '20090529_143442_run_final_0.0_51347_jgriffin',
41            '20090529_143458_run_final_0.0_51292_jgriffin',
42            '20090529_143527_run_final_0.0_51424_jgriffin']
43           
44
45#Specify output directories
46##time_dirs =[
47##['20091216_122203_run_final_0.0_58176_jgriffin',
48##'20091216_122218_run_final_0.0_31997_jgriffin',
49##'20091216_122348_run_final_0.0_7871_jgriffin',
50##'20091216_124238_run_final_0.0_31708_jgriffin',
51##'20091216_124254_run_final_0.0_31981_jgriffin',
52##'20091216_124340_run_final_0.0_51470_jgriffin',
53##'20091221_110506_run_final_0.0_58274_jgriffin',
54##'20091221_110525_run_final_0.0_51270_jgriffin',
55##'20091221_110609_run_final_0.0_58286_jgriffin']
56##'20091221_110617_run_final_0.0_51268_jgriffin',
57##'20091221_110624_run_final_0.0_31831_jgriffin',
58##'20091221_110632_run_final_0.0_31583_jgriffin',
59##'20091223_100248_run_final_0.0_5867_jgriffin',
60##'20091223_100422_run_final_0.0_1964_jgriffin',
61##'20091223_101813_run_final_0.0_6157_jgriffin',
62##'20091223_101905_run_final_0.0_6475_jgriffin',
63##'20091223_102012_run_final_0.0_7865_jgriffin',
64##'20091223_102123_run_final_0.0_16968_jgriffin',
65##'20091223_102158_run_final_0.0_20902_jgriffin',
66##'20091223_102326_run_final_0.0_24247_jgriffin']
67##'20091223_102727_run_final_0.0_28084_jgriffin',
68##'20091223_102851_run_final_0.0_30858_jgriffin',
69##'20091223_102951_run_final_0.0_31441_jgriffin',
70##'20100105_103540_run_final_0.0_31602_jgriffin',
71##'20100105_103553_run_final_0.0_51375_jgriffin',
72##'20100105_103701_run_final_0.0_31897_jgriffin',
73##'20100105_103701_run_final_0.0_58318_jgriffin',
74##'20100105_134917_run_final_0.0_51328_jgriffin',
75##'20100105_134929_run_final_0.0_58331_jgriffin']
76##'20100105_135108_run_final_0.0_6262_jgriffin',
77##'20100105_135137_run_final_0.0_6512_jgriffin',
78##'20100105_135246_run_final_0.0_16990_jgriffin',
79##'20100105_135253_run_final_0.0_20993_jgriffin',
80##'20100105_135319_run_final_0.0_24300_jgriffin',
81##'20100105_135401_run_final_0.0_30207_jgriffin',
82##'20100105_135419_run_final_0.0_31012_jgriffin',
83##'20100105_135440_run_final_0.0_31536_jgriffin',
84##'20100105_150548_run_final_0.0_15491_jgriffin',
85##'20100105_170027_run_final_0.0_6143_jgriffin']
86
87##time_dirs =['20100109_002128_run_final_0.0_31593_jgriffin',
88##            '20100109_042200_run_final_0.0_17006_jgriffin',
89##            '20100109_101855_run_final_0.0_31714_jgriffin',
90##            '20100109_103842_run_final_0.0_6360_jgriffin',
91##            '20100109_105331_run_final_0.0_7741_jgriffin',
92##            '20100109_111451_run_final_0.0_58337_jgriffin',
93##            '20100109_124401_run_final_0.0_15505_jgriffin',
94##            '20100109_132407_run_final_0.0_30379_jgriffin',
95##            '20100109_142643_run_final_0.0_31173_jgriffin',
96##            '20100109_145548_run_final_0.0_24356_jgriffin',
97##            '20100109_150711_run_final_0.0_51436_jgriffin',
98##            '20100109_162600_run_final_0.0_22691_jgriffin']
99           
100
101
102##time_dir2 = '20090529_143458_run_final_0.0_58346_jgriffin'
103
104#time_dirs = [time_dir1]#, time_dir2]   
105
106# sww filename extensions ie. if batemans_bay_time_37860_0.sww, input into list 37860
107# make sure numbers are in sequential order
108times = [37860]
109
110#Modify the cellsize value to set the size of the raster you require
111#Take into account mesh size when aplying this paramater
112cellsize = 20   #dependent on data resolution in area of interest.
113
114#Now set the timestep at which you want the raster generated.
115#Either set the actual timestep required or use 'None' to indicate that
116#you want the maximum values in the raster over all timesteps
117timestep = None    # None means no timestep!
118##timestep = 0
119
120######
121# Set the special areas of interest.  If none, do: area='All'
122######
123
124area = ['AOI']  # strings must match keys in var_equations below
125##area = ['All']      # 'All' means no special areas - the whole thing
126
127######
128# Define allowed variable names and associated equations to generate values.
129# This would not normally change.
130######
131# Added bed shear stress quantity
132# Note that mannings n (friction value) is taken as 0.01, as in the model run
133# density of water is 1000
134
135
136# Quantities
137var_equations = {'stage':     'stage',
138                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
139                 'depth':     'stage-elevation',
140                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
141                 'energy':  '(((xmomentum/(stage-elevation+1.e-6))**2 + (ymomentum/(stage-elevation+1.e-6))**2)*0.5*1000*(stage-elevation+1.e-6))+(9.81*stage*1000)',
142                 'bed_shear_stress': ('(((1/depth**(7./3.))*1000*9.81*0.01**2*(xmomentum/(stage-elevation+1.e-6))*((xmomentum/(stage-elevation+1.e-6))**2+(ymomentum/(stage-elevation+1.e-6))**2)**0.5)**2+'
143                                      '((1/depth**(7./3.))*1000*9.81*0.01**2*(ymomentum/(stage-elevation+1.e-6))*((xmomentum/(stage-elevation+1.e-6))**2+(ymomentum/(stage-elevation+1.e-6))**2)**0.5)**2)**0.5'),
144                 'elevation': 'elevation' }
145
146# one or more key strings from var_equations above
147#var = ['depth', 'speed','stage']
148var = ['bed_shear_stress']
149######
150# Start script, running through variables, area, folder, sww file (determine by times)
151# Then creates a maximum asci if there is more than one sww file
152######
153
154for which_var in var:
155    if which_var not in var_equations:
156        print 'Unrecognized variable name: %s' % which_var
157        break
158
159    for which_area in area:
160        if which_area == 'All':
161            easting_min = None
162            easting_max = None
163            northing_min = None
164            northing_max = None
165        else:
166            try:
167                easting_min = eval('project.xmin%s' % which_area)
168                easting_max = eval('project.xmax%s' % which_area)
169                northing_min = eval('project.ymin%s' % which_area)
170                northing_max = eval('project.ymax%s' % which_area)
171            except AttributeError:
172                print 'Unrecognized area name: %s' % which_area
173                break
174
175        for time_dir in time_dirs:
176            names = [join(directory, time_dir, project.scenario_name)]
177            for time in times:
178                names.append(join(directory, time_dir, project.scenario_name)+ '_time_' + str(time) + '_0')
179     
180            asc_name = []   
181               
182            for name in names:
183                         
184                outname = name + '_' + which_area + '_' + which_var
185                quantityname = var_equations[which_var]
186
187                print 'start sww2dem: time_dir=%s' % time_dir
188               
189                sww2dem(name, basename_out = outname,
190                            quantity = quantityname,
191                            timestep = timestep,
192                            cellsize = cellsize,     
193                            easting_min = easting_min,
194                            easting_max = easting_max,
195                            northing_min = northing_min,
196                            northing_max = northing_max,       
197                            reduction = max, 
198                            verbose = True,
199                            format = 'asc')
200
201                asc_name.append(outname + '.asc')
202   
203            if len(names) >1:
204                maxasc_outname = join(directory, time_dir, project.scenario_name)+'_'+which_area+'_'+which_var+'_max.asc'
205
206                print 'max asc outname ', maxasc_outname
207                print 'asc_name ', str(asc_name)
208           
209                MaxAsc(maxasc_outname, asc_name)
210            else:
211                print 'only one sww input'
Note: See TracBrowser for help on using the repository browser.