source: anuga_work/production/australia_ph2/sydney/export_results_max.py @ 6982

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