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

Last change on this file since 6988 was 6988, checked in by jgriffin, 11 years ago
File size: 5.6 KB
Line 
1"""
2Generates ascii grids of nominated areas -
3Input: sww file from run_perth.py
4       boundaries for grids from project.py
5Outputs: ascii grids of specified variables
6Stored in the 'outputs_dir' 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
24##time_dir1 = '20081217_101310_run_final_0_27283_250m_none_dt_kvanputt'
25##time_dir2 = '20081217_115336_run_final_0_27283_250m_none_dp_kvanputt'
26###time_dir1 = '20080924_123626_run_final_0_27283_250m_all_kvanputt' # This uses the 250m bathymetry with all interior polygons
27###time_dir2 = '20080912_154716_run_final_0_27283_alpha0.1_kvanputt' # This uses original bathyemetry data
28###time_dir3 = '20080924_123601_run_final_0_27283_250m_none_kvanputt' # This uses the 250m bathymetry without any interior polygons
29##time_dirs = [time_dir1, time_dir2]#, time_dir3]
30
31time_dir1 = '20090422_162114_run_final_0.0_51436_jgriffin'
32##time_dir2 = '20081211_162311_run_final_0_27255_alpha0.1_kvanputt'
33##time_dir3 = '20081211_162346_run_final_0_68693_alpha0.1_kvanputt'
34##time_dir4 = '20081211_162433_run_final_0.6_68693_alpha0.1_kvanputt'
35##time_dir5 = '20081211_162656_run_final_0.6_27283_alpha0.1_kvanputt'
36##time_dir6 = '20081211_162744_run_final_0_27283_alpha0.1_kvanputt'
37##
38time_dirs = [time_dir1] #5, time_dir4]# , time_dir4, time_dir5, time_dir6]
39 
40
41cellsize = 20
42##cellsize = 5
43
44timestep = None    # None means no timestep!
45##timestep = 0
46
47######
48# Set the special areas of interest.  If none, do: area='All'
49######
50
51#area = ['Bunbury', 'Busselton']  # strings must match keys in var_equations below
52area = ['All']      # 'All' means no special areas - the whole thing
53
54######
55# Define allowed variable names and associated equations to generate values.
56# This would not normally change.
57######
58var_equations = {'stage':     'stage',
59                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
60                 'depth':     'stage-elevation',
61                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
62                 'elevation': 'elevation' }
63
64# one or more key strings from var_equations above
65var = ['depth', 'stage', 'speed']#, 'stage', 'speed','depth']
66
67######
68# Start running the various conversions we require.
69######
70
71for which_var in var:
72    if which_var not in var_equations:
73        print 'Unrecognized variable name: %s' % which_var
74        break
75
76    for which_area in area:
77        if which_area == 'All':
78            easting_min = None
79            easting_max = None
80            northing_min = None
81            northing_max = None
82        else:
83            try:
84                easting_min = eval('project.xmin%s' % which_area)
85                easting_max = eval('project.xmax%s' % which_area)
86                northing_min = eval('project.ymin%s' % which_area)
87                northing_max = eval('project.ymax%s' % which_area)
88            except AttributeError:
89                print 'Unrecognized area name: %s' % which_area
90                break
91
92        for time_dir in time_dirs:
93
94            name1 = join(directory, time_dir, project.scenario_name)
95            name2 = join(directory, time_dir, project.scenario_name)+'_time_6310_0'
96            name3 = join(directory, time_dir, project.scenario_name)+'_time_12620_0'
97            name4 = join(directory, time_dir, project.scenario_name)+'_time_18930_0'
98            name5 = join(directory, time_dir, project.scenario_name)+'_time_25240_0'
99            name6 = join(directory, time_dir, project.scenario_name)+'_time_31550_0'
100            name7 = join(directory, time_dir, project.scenario_name)+'_time_37860_0'
101            name8 = join(directory, time_dir, project.scenario_name)+'_time_44170_0'
102            name9 = join(directory, time_dir, project.scenario_name)+'_time_50480_0'
103            name10 = join(directory, time_dir, project.scenario_name)+'_time_56790_0'
104
105           
106
107            names = [name1, name2, name3,name4,name5,name6,name7,name8,name9,name10]
108     
109            asc_name = []   
110               
111            for name in names:
112                         
113                outname = name + '_' + which_area + '_' + which_var
114                quantityname = var_equations[which_var]
115
116                print 'start sww2dem: time_dir=%s' % time_dir
117               
118                sww2dem(name, basename_out = outname,
119                            quantity = quantityname,
120                            timestep = timestep,
121                            cellsize = cellsize,     
122                            easting_min = easting_min,
123                            easting_max = easting_max,
124                            northing_min = northing_min,
125                            northing_max = northing_max,       
126                            reduction = max, 
127                            verbose = True,
128                            format = 'asc')
129
130                asc_name.append(outname + '.asc')
131   
132            maxasc_outname = join(directory, time_dir, project.scenario_name)+'_'+which_area+'_'+which_var+'_max.asc'
133
134            print 'max asc outname ', maxasc_outname
135            print 'asc_name ', str(asc_name)
136           
137            MaxAsc(maxasc_outname, asc_name)
Note: See TracBrowser for help on using the repository browser.