source: anuga_work/production/perth/export_results_all.py @ 5896

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

Updated script to combine the output asc grids into one maximum asc grid for the corresponding which_area + which_var, due to the problem of an .sww file only 2GB big (hence more than one for a scenario).

File size: 4.6 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
18
19
20directory = project.output_dir
21
22
23##time_dir1 = '20080924_123601_run_final_0_27283_250m_none_kvanputt' # This uses the 250m bathymetry without any interior polygons
24##time_dir2 = '20080924_123626_run_final_0_27283_250m_all_kvanputt' # This uses the 250m bathymetry with all interior polygons
25##time_dir3 = '20080912_154716_run_final_0_27283_alpha0.1_kvanputt' # This uses original bathyemetry data
26
27time_dir1 = '20081031_133353_run_final_0.6_68693_alpha0.1_kvanputt'
28time_dir2 = '20081031_133511_run_final_0_68693_alpha0.1_kvanputt'
29time_dir3 = '20081031_133624_run_final_0_27255_alpha0.1_kvanputt'
30time_dir4 = '20081031_133735_run_final_0.6_27255_alpha0.1_kvanputt'
31time_dir5 = '20081031_133841_run_final_0_27283_alpha0.1_kvanputt'
32time_dir6 = '20081031_133925_run_final_0.6_27283_alpha0.1_kvanputt'
33
34
35time_dirs = [time_dir1, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6]
36
37cellsize = 20
38#cellsize = 250
39
40timestep = None    # None means no timestep!
41#timestep = 0
42
43######
44# Set the special areas of interest.  If none, do: area='All'
45######
46#area = ['Geordie', 'Sorrento', 'Fremantle', 'Rockingham']  # 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 = ['depth', 'speed']
61
62######
63# Start running the various conversions we require.
64######
65for time_dir in time_dirs:
66    name1 = directory+time_dir+sep+project.scenario_name
67    name2 = directory+time_dir+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything
68    name3 = directory+time_dir+sep++project.scenario_name+'_time_79800_0' #need to get assistance on how to make this into anything
69
70    names = [name1, name2, name3]
71
72    asc_name = []
73     
74    for name in names:
75        for which_area in area:
76            if which_area == 'All':
77                easting_min = None
78                easting_max = None
79                northing_min = None
80                northing_max = None
81            else:
82                try:
83                    easting_min = eval('project.xmin%s' % which_area)
84                    easting_max = eval('project.xmax%s' % which_area)
85                    northing_min = eval('project.ymin%s' % which_area)
86                    northing_max = eval('project.ymax%s' % which_area)
87                except AttributeError:
88                    print 'Unrecognized area name: %s' % which_area
89                    break
90             
91            for which_var in var:
92                if which_var not in var_equations:
93                    print 'Unrecognized variable name: %s' % which_var
94                    break
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(name)
114
115    maxasc_outname = directory+time_dir + which_area+'_'+which_var+'_max.asc'
116   
117    MaxAsc(maxasc_outname, asc_name)
118
119
Note: See TracBrowser for help on using the repository browser.