source: anuga_work/production/carnarvon/export_results_max_multiple_timesteps.py @ 6514

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