source: anuga_work/production/carnarvon/export_results_max.py @ 5996

Last change on this file since 5996 was 5996, checked in by Leharne, 15 years ago

update export max script to allow for different names in each time_dir

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