source: anuga_work/production/gold_coast_2009/For_DVD/export_results_max.py @ 7306

Last change on this file since 7306 was 7306, checked in by Leharne, 14 years ago

Scripts to be included on Gold Coast DVD with AGD's report

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# Directories that contain the sww files of interest found in anuga/outputs:
25time_dir1 = 'Event1_HAT'
26time_dir2 = 'Event1_MSL'
27time_dir3 = 'Event2_HAT'
28time_dir4 = 'Event2_MSL'
29time_dir5 = 'Event3_HAT'
30time_dir6 = 'Event3_MSL'
31
32time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6]   
33
34# sww filename suffixes ie for gold_coast_time_28860_0.sww,
35# input 28860 into list, ensuring numbers are in sequential order
36time_dirs = [28860, 57720]
37
38# Modify the cellsize variable to set the resolution of the raster you require
39# Take into account the mesh size when setting this variable
40cellsize = 20 # use 250 if exporting entire model area
41
42#Now set the timestep at which you want the raster generated.
43#Either set the actual timestep required or use 'None' to indicate that
44#you want the maximum values in the raster over all timesteps
45timestep = None
46
47# Set the special areas of interest.  If none, do: area='All'
48# Areas identified below are specified by cooridinates in project.py
49area = ['All'] # 'All' means the whole model area
50
51# Specify which properties you would like to export by setting
52# one or more key strings from var_equations below
53var = ['speed', 'depth']
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######
65# Start script, running through variables, area, folder, sww file (determine
66# by times). Then creates a maximum asci if there is more than one sww file
67######
68
69for which_var in var:
70    if which_var not in var_equations:
71        print 'Unrecognized variable name: %s' % which_var
72        break
73
74    for which_area in area:
75        if which_area == 'All':
76            easting_min = None
77            easting_max = None
78            northing_min = None
79            northing_max = None
80        else:
81            try:
82                easting_min = eval('project.xmin%s' % which_area)
83                easting_max = eval('project.xmax%s' % which_area)
84                northing_min = eval('project.ymin%s' % which_area)
85                northing_max = eval('project.ymax%s' % which_area)
86            except AttributeError:
87                print 'Unrecognized area name: %s' % which_area
88                break
89
90        for time_dir in time_dirs:
91            names = [join(directory, time_dir, project.scenario_name)]
92            for time in times:
93                names.append(join(directory, time_dir, project.scenario_name)+ '_time_' + str(time) + '_0')
94           
95            asc_name = []   
96                           
97            for name in names:
98                outname = name + '_' + which_area + '_' + which_var
99                quantityname = var_equations[which_var]
100
101                print 'start sww2dem: time_dir=%s' % time_dir
102                print 'name=%s' % name
103                sww2dem(name, basename_out = outname,
104                            quantity = quantityname,
105                            timestep = timestep,
106                            cellsize = cellsize,     
107                            easting_min = easting_min,
108                            easting_max = easting_max,
109                            northing_min = northing_min,
110                            northing_max = northing_max,       
111                            reduction = max, 
112                            verbose = True,
113                            format = 'asc')
114
115                asc_name.append(outname + '.asc')
116           
117            if len(names) >1:
118                maxasc_outname = join(directory, time_dir, project.scenario_name)+'_'+which_area+'_'+which_var+'_max.asc'
119
120                print 'max asc outname ', maxasc_outname
121                print 'asc_name ', str(asc_name)
122               
123                MaxAsc(maxasc_outname, asc_name)
Note: See TracBrowser for help on using the repository browser.