source: anuga_work/production/australia_ph2/wyndham/export_results_max.py @ 6959

Last change on this file since 6959 was 6959, checked in by myall, 15 years ago
File size: 4.8 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 = '20090415_094009_run_final_0_17918_1823_Tb__kvanputt'
25##time_dir2 = '20090418_182759_run_final_0_64962_1823_Tb__kvanputt'
26##time_dir3 = '20090421_145541_run_final_0_70920_1823_Tb__kvanputt'
27##time_dir4 = ''
28##time_dir5 = ''
29##time_dir6 = ''
30##time_dir7 = ''
31##time_dir8 = ''
32
33time_dir1 = '20090428_145948_run_final_0_64962_1823_Tb_internal_mhingee'
34
35time_dirs = [time_dir1]#, time_dir2, time_dir3]# , time_dir4, time_dir5, time_dir6]
36 
37
38cellsize = 250
39##cellsize = 5
40
41timestep = None    # None means no timestep!
42#timestep = 0
43
44######
45# Set the special areas of interest.  If none, do: area='All'
46######
47
48#area = ['Bunbury', 'Busselton']  # strings must match keys in var_equations below
49area = ['All']      # 'All' means no special areas - the whole thing
50
51######
52# Define allowed variable names and associated equations to generate values.
53# This would not normally change.
54######
55var_equations = {'stage':     'stage',
56                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
57                 'depth':     'stage-elevation',
58                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
59                 'elevation': 'elevation' }
60
61# one or more key strings from var_equations above
62var = ['stage']
63
64######
65# Start running the various conversions we require.
66######
67
68for which_var in var:
69    if which_var not in var_equations:
70        print 'Unrecognized variable name: %s' % which_var
71        break
72
73    for which_area in area:
74        if which_area == 'All':
75            easting_min = None
76            easting_max = None
77            northing_min = None
78            northing_max = None
79        else:
80            try:
81                easting_min = eval('project.xmin%s' % which_area)
82                easting_max = eval('project.xmax%s' % which_area)
83                northing_min = eval('project.ymin%s' % which_area)
84                northing_max = eval('project.ymax%s' % which_area)
85            except AttributeError:
86                print 'Unrecognized area name: %s' % which_area
87                break
88
89        for time_dir in time_dirs:
90
91            name1 = join(directory, time_dir, project.scenario_name)
92            name2 = join(directory, time_dir, project.scenario_name)+'_time_8460_0'
93            name3 = join(directory, time_dir, project.scenario_name)+'_time_16920_0'
94            name4 = join(directory, time_dir, project.scenario_name)+'_time_25380_0'
95            name5 = join(directory, time_dir, project.scenario_name)+'_time_33840_0'
96            name6 = join(directory, time_dir, project.scenario_name)+'_time_42300_0'
97            name7 = join(directory, time_dir, project.scenario_name)+'_time_50760_0'
98            name8 = join(directory, time_dir, project.scenario_name)+'_time_59220_0'
99           
100            names = [name1, name2, name3, name4, name5, name6, name7, name8]
101     
102            asc_name = []   
103               
104            for name in names:
105                         
106                outname = name + '_' + which_area + '_' + which_var
107                quantityname = var_equations[which_var]
108
109                print 'start sww2dem: time_dir=%s' % time_dir
110               
111                sww2dem(name, basename_out = outname,
112                            quantity = quantityname,
113                            timestep = timestep,
114                            cellsize = cellsize,     
115                            easting_min = easting_min,
116                            easting_max = easting_max,
117                            northing_min = northing_min,
118                            northing_max = northing_max,       
119                            reduction = max, 
120                            verbose = True,
121                            format = 'asc')
122
123                asc_name.append(outname + '.asc')
124   
125            maxasc_outname = join(directory, time_dir, project.scenario_name)+'_'+which_area+'_'+which_var+'_max.asc'
126
127            print 'max asc outname ', maxasc_outname
128            print 'asc_name ', str(asc_name)
129           
130            MaxAsc(maxasc_outname, asc_name)
Note: See TracBrowser for help on using the repository browser.