source: anuga_work/production/pt_hedland_2008/export_results_all.py @ 6540

Last change on this file since 6540 was 5861, checked in by jgriffin, 16 years ago
File size: 3.5 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
22time_dir1 = '20081015_140641_run_final_0_27283_alpha0.1_jgriffin'
23time_dirs = [time_dir1]
24
25#cellsize = 20
26cellsize = 20
27
28timestep = None    # None means no timestep!
29#timestep = 0
30
31######
32# Set the special areas of interest.  If none, do: area='All'
33######
34#area = ['Fremantle']  # strings must match keys in var_equations below
35area = ['All']      # 'All' means no special areas - the whole thing
36
37######
38# Define allowed variable names and associated equations to generate values.
39# This would not normally change.
40######
41var_equations = {'stage':     'stage',
42                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
43                 'depth':     'stage-elevation',
44                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
45                 'elevation': 'elevation' }
46
47# one or more key strings from var_equations above
48var = ['stage', 'speed','depth']
49
50######
51# Start running the various conversions we require.
52######
53for time_dir in time_dirs:
54    name1 = directory+time_dir+sep+project.scenario_name
55#    name2 = directory+time_dir+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything
56    names = [name1]
57   
58    for name in names:
59        for which_area in area:
60            if which_area == 'All':
61                easting_min = None
62                easting_max = None
63                northing_min = None
64                northing_max = None
65            else:
66                try:
67                    easting_min = eval('project.xmin%s' % which_area)
68                    easting_max = eval('project.xmax%s' % which_area)
69                    northing_min = eval('project.ymin%s' % which_area)
70                    northing_max = eval('project.ymax%s' % which_area)
71                except AttributeError:
72                    print 'Unrecognized area name: %s' % which_area
73                    break
74             
75            for which_var in var:
76                if which_var not in var_equations:
77                    print 'Unrecognized variable name: %s' % which_var
78                    break
79
80                outname = name + which_area + '_' + which_var
81                quantityname = var_equations[which_var]
82
83                print 'start sww2dem: time_dir=%s' % time_dir
84               
85                sww2dem(name, basename_out = outname,
86                            quantity = quantityname,
87                            timestep = timestep,
88                            cellsize = cellsize,     
89                            easting_min = easting_min,
90                            easting_max = easting_max,
91                            northing_min = northing_min,
92                            northing_max = northing_max,       
93                            reduction = max, 
94                            verbose = True,
95                            format = 'asc')
Note: See TracBrowser for help on using the repository browser.