source: anuga_work/production/perth/export_results_max.py @ 6391

Last change on this file since 6391 was 6391, checked in by kristy, 15 years ago
File size: 5.0 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
22time_dir1 = '20090129_155526_run_final_0.6_27255_Rottnest_kvanputt'
23
24
25##time_dir1 = '20081209_155431_run_final_0_27255_250m_none_lfountai'
26##time_dir2 = '20081210_100528_run_final_0_68693_250m_none_kvanputt'
27
28###time_dir1 = '20080924_123626_run_final_0_27283_250m_all_kvanputt' # This uses the 250m bathymetry with all interior polygons
29###time_dir2 = '20080912_154716_run_final_0_27283_alpha0.1_kvanputt' # This uses original bathyemetry data
30###time_dir3 = '20080924_123601_run_final_0_27283_250m_none_kvanputt' # This uses the 250m bathymetry without any interior polygons
31##time_dirs = [time_dir1, time_dir2]#, time_dir3]
32
33##time_dir1 = '20081031_133353_run_final_0.6_68693_alpha0.1_kvanputt'
34##time_dir2 = '20081031_133511_run_final_0_68693_alpha0.1_kvanputt'
35##time_dir3 = '20081031_133624_run_final_0_27255_alpha0.1_kvanputt'
36##time_dir4 = '20081031_133735_run_final_0.6_27255_alpha0.1_kvanputt'
37##time_dir5 = '20081031_133841_run_final_0_27283_alpha0.1_kvanputt'
38##time_dir6 = '20081031_133925_run_final_0.6_27283_alpha0.1_kvanputt'
39##
40time_dirs = [time_dir1] #2, time_dir3] #, time_dir3, time_dir4, time_dir5, time_dir6]
41
42 
43
44cellsize = 20
45#cellsize = 250
46
47timestep = None    # None means no timestep!
48#timestep = 0
49
50######
51# Set the special areas of interest.  If none, do: area='All'
52######
53
54area = ['Rottnest']  # strings must match keys in var_equations below
55#area = ['All']      # 'All' means no special areas - the whole thing
56
57######
58# Define allowed variable names and associated equations to generate values.
59# This would not normally change.
60######
61var_equations = {'stage':     'stage',
62                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
63                 'depth':     'stage-elevation',
64                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
65                 'elevation': 'elevation' }
66
67# one or more key strings from var_equations above
68var = ['depth', 'speed']
69
70######
71# Start running the various conversions we require.
72######
73
74for which_var in var:
75    if which_var not in var_equations:
76        print 'Unrecognized variable name: %s' % which_var
77        break
78
79    for which_area in area:
80        if which_area == 'All':
81            easting_min = None
82            easting_max = None
83            northing_min = None
84            northing_max = None
85        else:
86            try:
87                easting_min = eval('project.xmin%s' % which_area)
88                easting_max = eval('project.xmax%s' % which_area)
89                northing_min = eval('project.ymin%s' % which_area)
90                northing_max = eval('project.ymax%s' % which_area)
91            except AttributeError:
92                print 'Unrecognized area name: %s' % which_area
93                break
94
95        for time_dir in time_dirs:
96
97            name1 = directory+time_dir+sep+project.scenario_name
98##            name2 = directory+time_dir+sep+project.scenario_name+'_time_39900_0'
99##            name3 = directory+time_dir+sep+project.scenario_name+'_time_79800_0'
100
101            names = [name1]#, name2, name3]
102     
103       #     asc_name = []   
104               
105            for name in names:
106                         
107                outname = name + '_' + which_area + '_' + which_var
108                quantityname = var_equations[which_var]
109
110                print 'start sww2dem: time_dir=%s' % time_dir
111               
112                sww2dem(name, basename_out = outname,
113                            quantity = quantityname,
114                            timestep = timestep,
115                            cellsize = cellsize,     
116                            easting_min = easting_min,
117                            easting_max = easting_max,
118                            northing_min = northing_min,
119                            northing_max = northing_max,       
120                            reduction = max, 
121                            verbose = True,
122                            format = 'asc')
123##
124##                asc_name.append(outname + '.asc')
125##   
126##            maxasc_outname = directory+time_dir+sep+project.scenario_name+'_'+which_area+'_'+which_var+'_max.asc'
127##
128##            print 'max asc outname ', maxasc_outname
129##            print 'asc_name ', str(asc_name)
130##           
131##            MaxAsc(maxasc_outname, asc_name)
Note: See TracBrowser for help on using the repository browser.