source: anuga_work/production/australia_ph2/darwin/export_results_max.py @ 6730

Last change on this file since 6730 was 6730, checked in by myall, 15 years ago
File size: 5.0 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
24time_dir1 = '20090327_103428_run_final_0_70906_1833_Bf_None_mhingee'
25time_dir2 = '20090327_121728_run_final_0_70906_1833_Tb_None_mhingee'
26##time_dir3 = ''
27##time_dir4 = ''
28##time_dir5 = ''
29##time_dir6 = ''
30##time_dir7 = ''
31##time_dir8 = ''
32time_dirs = [time_dir1, time_dir2] # time_dir4]# , time_dir4, time_dir5, time_dir6]
33 
34
35cellsize = 250
36##cellsize = 5
37
38#timestep = None    # None means no timestep!
39timestep = 0
40
41######
42# Set the special areas of interest.  If none, do: area='All'
43######
44
45#area = ['Bunbury', 'Busselton']  # strings must match keys in var_equations below
46area = ['All']      # 'All' means no special areas - the whole thing
47
48######
49# Define allowed variable names and associated equations to generate values.
50# This would not normally change.
51######
52var_equations = {'stage':     'stage',
53                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
54                 'depth':     'stage-elevation',
55                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
56                 'elevation': 'elevation' }
57
58# one or more key strings from var_equations above
59var = ['stage','speed','depth']
60
61######
62# Start running the various conversions we require.
63######
64
65for which_var in var:
66    if which_var not in var_equations:
67        print 'Unrecognized variable name: %s' % which_var
68        break
69
70    for which_area in area:
71        if which_area == 'All':
72            easting_min = None
73            easting_max = None
74            northing_min = None
75            northing_max = None
76        else:
77            try:
78                easting_min = eval('project.xmin%s' % which_area)
79                easting_max = eval('project.xmax%s' % which_area)
80                northing_min = eval('project.ymin%s' % which_area)
81                northing_max = eval('project.ymax%s' % which_area)
82            except AttributeError:
83                print 'Unrecognized area name: %s' % which_area
84                break
85
86        for time_dir in time_dirs:
87
88            name1 = join(directory, time_dir, project.scenario_name)
89            name2 = join(directory, time_dir, project.scenario_name)+'_time_7380_0'
90            name3 = join(directory, time_dir, project.scenario_name)+'_time_14760_0'
91            name4 = join(directory, time_dir, project.scenario_name)+'_time_22140_0'
92            name5 = join(directory, time_dir, project.scenario_name)+'_time_29520_0'
93            name6 = join(directory, time_dir, project.scenario_name)+'_time_36900_0'
94            name7 = join(directory, time_dir, project.scenario_name)+'_time_44280_0'
95            name8 = join(directory, time_dir, project.scenario_name)+'_time_51660_0'
96            name9 = join(directory, time_dir, project.scenario_name)+'_time_59040_0'
97            name10 = join(directory, time_dir, project.scenario_name)+'_time_66420_0'
98            name11 = join(directory, time_dir, project.scenario_name)+'_time_73800_0'
99
100            names = [name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11]
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.