source: anuga_work/production/pt_hedland_2008/export_results_max.py @ 6012

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

Copied from Perth, modified for Port Hedland

File size: 4.0 KB
Line 
1"""
2Generates ascii grids of nominated areas -
3Input: sww file from run_pt_hedland.py
4       boundaries for grids from project_250m.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_250m, 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_250m.output_dir
21
22time_dir1 = '20081125_135917_run_final_0_27283_250m_none_lfountai'
23
24time_dirs = [time_dir1]#, time_dir2, time_dir3, time_dir4, time_dir5, time_dir6]
25
26#cellsize = 20
27cellsize = 250
28
29timestep = None    # None means no timestep!
30#timestep = 0
31
32######
33# Set the special areas of interest.  If none, do: area='All'
34######
35
36#area = ['']         # strings must match keys in var_equations below
37area = ['All']       # 'All' means no special areas - the whole thing
38
39######
40# Define allowed variable names and associated equations to generate values.
41# This would not normally change.
42######
43var_equations = {'stage':     'stage',
44                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
45                 'depth':     'stage-elevation',
46                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
47                 'elevation': 'elevation' }
48
49# one or more key strings from var_equations above
50var = ['stage', 'speed']
51
52######
53# Start running the various conversions we require.
54######
55
56for which_var in var:
57    if which_var not in var_equations:
58        print 'Unrecognized variable name: %s' % which_var
59        break
60
61    for which_area in area:
62        if which_area == 'All':
63            easting_min = None
64            easting_max = None
65            northing_min = None
66            northing_max = None
67        else:
68            try:
69                easting_min = eval('project_250m.xmin%s' % which_area)
70                easting_max = eval('project_250m.xmax%s' % which_area)
71                northing_min = eval('project_250m.ymin%s' % which_area)
72                northing_max = eval('project_250m.ymax%s' % which_area)
73            except AttributeError:
74                print 'Unrecognized area name: %s' % which_area
75                break
76
77        for time_dir in time_dirs:
78
79            name1 = directory+time_dir+sep+project_250m.scenario_name
80            name2 = directory+time_dir+sep+project_250m.scenario_name+'_time_59580_0'
81           # name3 = directory+time_dir+sep+project_250m.scenario_name+'_time_78360_0'
82
83            names = [name1, name2] #, name3]
84     
85            asc_name = []   
86               
87            for name in names:
88                         
89                outname = name + '_' + which_area + '_' + which_var
90                quantityname = var_equations[which_var]
91
92                print 'start sww2dem: time_dir=%s' % time_dir
93               
94                sww2dem(name, basename_out = outname,
95                            quantity = quantityname,
96                            timestep = timestep,
97                            cellsize = cellsize,     
98                            easting_min = easting_min,
99                            easting_max = easting_max,
100                            northing_min = northing_min,
101                            northing_max = northing_max,       
102                            reduction = max, 
103                            verbose = True,
104                            format = 'asc')
105
106                asc_name.append(outname + '.asc')
107   
108            maxasc_outname = directory+time_dir+sep+project_250m.scenario_name+'_'+which_area+'_'+which_var+'_max.asc'
109
110            print 'max asc outname ', maxasc_outname
111            print 'asc_name ', str(asc_name)
112           
113            MaxAsc(maxasc_outname, asc_name)
Note: See TracBrowser for help on using the repository browser.