source: anuga_work/production/Broome_2008/export_results_all.py @ 5816

Last change on this file since 5816 was 5816, checked in by rwilson, 15 years ago

Changed handling of

easting_min = project.xminGeordie

to

easting_min = eval('project.xmin%s' % which_area)

which means the code will never have to change again.

File size: 4.9 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.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
16from anuga.shallow_water.data_manager import sww2dem
17from os import sep
18
19
20directory = project.output_dir
21
22#time_dir = '20080526_104946_run_final_0.6_test_kvanputt'
23#time_dir = '20080530_170833_run_final_0.6_exmouth_kvanputt'
24time_dir1 = '20081002_171412_run_final_0.6_27255_alpha0.1_rwilson'
25time_dirs = [time_dir1]
26
27#cellsize = 20
28cellsize = 30
29
30#timestep = None    # None means no timestep!
31timestep = 0
32
33######
34# Set the special areas of interest.  If none, do: area='All'
35######
36#area = ['Geordie', 'Sorrento', 'Fremantle', 'Rockingham']  # 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', 'elevation']
51
52######
53# Start running the various conversions we require.
54######
55for time_dir in time_dirs:
56    name1 = directory+time_dir+sep+project.scenario_name
57#    name2 = directory+time_dir+sep+'sww2'+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything
58    names = [name1]
59   
60    for name in names:
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.xmin%s' % which_area)
70                    easting_max = eval('project.xmax%s' % which_area)
71                    northing_min = eval('project.ymin%s' % which_area)
72                    northing_max = eval('project.ymax%s' % which_area)
73                except AttributeError:
74                    print 'Unrecognized area name: %s' % which_area
75                    break
76### This is replaced by the single 'else' case above
77##            elif which_area == 'Geordie':
78##                easting_min = project.xminGeordie
79##                easting_max = project.xmaxGeordie
80##                northing_min = project.yminGeordie
81##                northing_max = project.ymaxGeordie
82##            elif which_area == 'Sorrento':
83##                easting_min = project.xminSorrento
84##                easting_max = project.xmaxSorrento
85##                northing_min = project.yminSorrento
86##                northing_max = project.ymaxSorrento
87##            elif which_area == 'Fremantle':
88##                easting_min = project.xminFremantle
89##                easting_max = project.xmaxFremantle
90##                northing_min = project.yminFremantle
91##                northing_max = project.ymaxFremantle
92##            elif which_area == 'Rockingham':
93##                easting_min = project.xminRockingham
94##                easting_max = project.xmaxRockingham
95##                northing_min = project.yminRockingham
96##                northing_max = project.ymaxRockingham
97##            else:
98##                print 'Unrecognized area name: %s' % which_area
99##                break
100             
101            for which_var in var:
102                if which_var not in var_equations:
103                    print 'Unrecognized variable name: %s' % which_var
104                    break
105
106                outname = name + which_area + '_' + which_var
107                quantityname = var_equations[which_var]
108
109                print 'start sww2dem: time_dir=%s' % time_dir
110               
111                sww2dem(name, basename_out = outname,
112                            quantity = quantityname,
113                            timestep = timestep,
114                            cellsize = cellsize,     
115                            easting_min = easting_min,
116                            easting_max = easting_max,
117                            northing_min = northing_min,
118                            northing_max = northing_max,       
119                            reduction = max, 
120                            verbose = True,
121                            format = 'asc')
Note: See TracBrowser for help on using the repository browser.