source: anuga_work/production/hobart_2009/export_results_max.py @ 7146

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