source: anuga_work/production/geraldton/export_results_max.py @ 6065

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

general maintenance

File size: 4.4 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
20
21directory = project.output_dir
22##time_dir1 = '20081209_155330_run_final_0_27255_250m_none_lfountai'
23##time_dir2 = '20081209_161229_run_final_0_68693_250m_none_lfountai'
24##time_dirs = [time_dir1, time_dir2]
25
26##time_dir1 = '20081117_141353_run_final_0_27283_alpha0.1_kvanputt'
27##time_dir2 = '20081117_141443_run_final_0.6_27283_alpha0.1_kvanputt'
28time_dir3 = '20081117_141520_run_final_0_27255_alpha0.1_kvanputt'
29##time_dir4 = '20081117_141558_run_final_0.6_27255_alpha0.1_kvanputt'
30time_dir5 = '20081117_141634_run_final_0_68693_alpha0.1_kvanputt'
31##time_dir6 = '20081117_141717_run_final_0.6_68693_alpha0.1_kvanputt'
32##
33time_dirs = [time_dir3, time_dir5] #, time_dir3, time_dir4, time_dir5, time_dir6]
34
35 
36
37#cellsize = 10
38cellsize = 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
47#area = ['CBD']  # strings must match keys in var_equations below
48area = ['All']      # 'All' means no special areas - the whole thing
49
50######
51# Define allowed variable names and associated equations to generate values.
52# This would not normally change.
53######
54var_equations = {'stage':     'stage',
55                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
56                 'depth':     'stage-elevation',
57                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
58                 'elevation': 'elevation' }
59
60# one or more key strings from var_equations above
61var = ['stage']
62
63######
64# Start running the various conversions we require.
65######
66
67for which_var in var:
68    if which_var not in var_equations:
69        print 'Unrecognized variable name: %s' % which_var
70        break
71
72    for which_area in area:
73        if which_area == 'All':
74            easting_min = None
75            easting_max = None
76            northing_min = None
77            northing_max = None
78        else:
79            try:
80                easting_min = eval('project.xmin%s' % which_area)
81                easting_max = eval('project.xmax%s' % which_area)
82                northing_min = eval('project.ymin%s' % which_area)
83                northing_max = eval('project.ymax%s' % which_area)
84            except AttributeError:
85                print 'Unrecognized area name: %s' % which_area
86                break
87
88        for time_dir in time_dirs:
89
90            name1 = directory+time_dir+sep+project.scenario_name
91            name2 = directory+time_dir+sep+project.scenario_name+'_time_41820_0'
92           
93            names = [name1, name2]
94     
95            asc_name = []   
96               
97            for name in names:
98                         
99                outname = name + '_' + which_area + '_' + which_var
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)
Note: See TracBrowser for help on using the repository browser.