source: anuga_work/production/australia_ph2/bamaga/export_results_max.py @ 7005

Last change on this file since 7005 was 7005, checked in by jgriffin, 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 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
24##time_dir1 = '20090408_152655_run_final_0_31975_2000_Tb__mhingee'
25##time_dir2 = '20090409_123239_run_final_0_51390_2000_Tb__mhingee'
26##time_dir3 = '20090410_110658_run_final_0_63735_2000_Tb__mhingee'
27
28time_dir1 = '20090507_091836_run_final_0_64977_1914_Tb__jgriffin'
29
30time_dirs = [time_dir1]#, time_dir2, time_dir3]
31
32cellsize = 250
33##cellsize = 5
34
35timestep = None    # None means no timestep!
36#timestep = 0
37
38######
39# Set the special areas of interest.  If none, do: area='All'
40######
41
42#area = ['Bunbury', 'Busselton']  # strings must match keys in var_equations below
43area = ['All']      # 'All' means no special areas - the whole thing
44
45######
46# Define allowed variable names and associated equations to generate values.
47# This would not normally change.
48######
49var_equations = {'stage':     'stage',
50                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
51                 'depth':     'stage-elevation',
52                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
53                 'elevation': 'elevation' }
54
55# one or more key strings from var_equations above
56var = ['stage']
57
58######
59# Start running the various conversions we require.
60######
61
62for which_var in var:
63    if which_var not in var_equations:
64        print 'Unrecognized variable name: %s' % which_var
65        break
66
67    for which_area in area:
68        if which_area == 'All':
69            easting_min = None
70            easting_max = None
71            northing_min = None
72            northing_max = None
73        else:
74            try:
75                easting_min = eval('project.xmin%s' % which_area)
76                easting_max = eval('project.xmax%s' % which_area)
77                northing_min = eval('project.ymin%s' % which_area)
78                northing_max = eval('project.ymax%s' % which_area)
79            except AttributeError:
80                print 'Unrecognized area name: %s' % which_area
81                break
82
83        for time_dir in time_dirs:
84
85            name1 = join(directory, time_dir, project.scenario_name)
86            name2 = join(directory, time_dir, project.scenario_name)+'_time_6960_0'
87            name3 = join(directory, time_dir, project.scenario_name)+'_time_13920_0'
88            name4 = join(directory, time_dir, project.scenario_name)+'_time_20880_0'
89            name5 = join(directory, time_dir, project.scenario_name)+'_time_27840_0'
90            name6 = join(directory, time_dir, project.scenario_name)+'_time_34800_0'
91            name7 = join(directory, time_dir, project.scenario_name)+'_time_41760_0'
92            name8 = join(directory, time_dir, project.scenario_name)+'_time_48720_0'
93            name9 = join(directory, time_dir, project.scenario_name)+'_time_55680_0'
94            name10 = join(directory, time_dir, project.scenario_name)+'_time_62640_0'
95            name11 = join(directory, time_dir, project.scenario_name)+'_time_69600_0'
96            name12 = join(directory, time_dir, project.scenario_name)+'_time_76560_0'
97           
98            names = [name1, name2, name3, name4, name5, name6, name7, name8, name9, name10, name11, name12]
99
100            asc_name = []
101
102            for name in names:
103               
104                outname = name + '_' + which_area + '_' + which_var
105                quantityname = var_equations[which_var]
106
107                print 'start sww2dem: time_dir=%s' % time_dir
108               
109                sww2dem(name, basename_out = outname,
110                            quantity = quantityname,
111                            timestep = timestep,
112                            cellsize = cellsize,     
113                            easting_min = easting_min,
114                            easting_max = easting_max,
115                            northing_min = northing_min,
116                            northing_max = northing_max,       
117                            reduction = max, 
118                            verbose = True,
119                            format = 'asc')
120
121                asc_name.append(outname + '.asc')
122   
123            maxasc_outname = join(directory, time_dir, project.scenario_name)+'_'+which_area+'_'+which_var+'_max.asc'
124
125            print 'max asc outname ', maxasc_outname
126            print 'asc_name ', str(asc_name)
127           
128            MaxAsc(maxasc_outname, asc_name)
129             
Note: See TracBrowser for help on using the repository browser.