source: anuga_work/production/australia_ph2/wyndham/export_results_max.py @ 6539

Last change on this file since 6539 was 6539, checked in by myall, 15 years ago

divided darwin model into 'darwin' and 'wyndham', as it was too large

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