source: anuga_work/production/patong/export_results_max.py @ 5971

Last change on this file since 5971 was 5971, checked in by kristy, 15 years ago

Reworked boxing day validation, formatted from Perth

File size: 3.7 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 anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
16from anuga.shallow_water.data_manager import sww2dem
17from os import sep
18import maxasc
19
20directory = project.output_dir
21
22time_dir1 = '20081113_153848_run_final_0_kvanputt'
23
24time_dirs = [time_dir1]
25 
26
27cellsize = 20
28#cellsize = 250
29
30timestep = None    # None means no timestep!
31#timestep = 0
32
33######
34# Set the special areas of interest.  If none, do: area='All'
35######
36
37#area = ['CBD' ]  # strings must match keys in var_equations below
38area = ['All']      # 'All' means no special areas - the whole thing
39
40######
41# Define allowed variable names and associated equations to generate values.
42# This would not normally change.
43######
44var_equations = {'stage':     'stage',
45                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
46                 'depth':     'stage-elevation',
47                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
48                 'elevation': 'elevation' }
49
50# one or more key strings from var_equations above
51var = ['stage', 'elevation']
52
53######
54# Start running the various conversions we require.
55######
56
57for which_var in var:
58    if which_var not in var_equations:
59        print 'Unrecognized variable name: %s' % which_var
60        break
61
62    for which_area in area:
63        if which_area == 'All':
64            easting_min = None
65            easting_max = None
66            northing_min = None
67            northing_max = None
68        else:
69            try:
70                easting_min = eval('project.xmin%s' % which_area)
71                easting_max = eval('project.xmax%s' % which_area)
72                northing_min = eval('project.ymin%s' % which_area)
73                northing_max = eval('project.ymax%s' % which_area)
74            except AttributeError:
75                print 'Unrecognized area name: %s' % which_area
76                break
77
78        for time_dir in time_dirs:
79
80            name1 = directory+time_dir+sep+project.scenario_name
81           
82            names = [name1]
83     
84            #asc_name = []   
85               
86            for name in names:
87                         
88                outname = name + '_' + which_area + '_' + which_var
89                quantityname = var_equations[which_var]
90
91                print 'start sww2dem: time_dir=%s' % time_dir
92               
93                sww2dem(name, basename_out = outname,
94                            quantity = quantityname,
95                            timestep = timestep,
96                            cellsize = cellsize,     
97                            easting_min = easting_min,
98                            easting_max = easting_max,
99                            northing_min = northing_min,
100                            northing_max = northing_max,       
101                            reduction = max, 
102                            verbose = True,
103                            format = 'asc')
104
105                #asc_name.append(outname + '.asc')
106   
107##            maxasc_outname = directory+time_dir+sep+project.scenario_name+'_'+which_area+'_'+which_var+'_max.asc'
108##
109##            print 'max asc outname ', maxasc_outname
110##            print 'asc_name ', str(asc_name)
111##           
112##            maxasc.MaxAsc(maxasc_outname, asc_name)
Note: See TracBrowser for help on using the repository browser.