source: anuga_work/production/new_south_wales/batemans_bay/export_results_max.py @ 7606

Last change on this file since 7606 was 7606, checked in by jgriffin, 14 years ago

Added extra events for probabilistic run

File size: 4.9 KB
Line 
1"""
2Generates ascii grids of nominated areas -
3Input: sww file from run_model.py
4       boundaries for grids from project.py
5Outputs: ascii grids of specified variables
6Stored in the 'outputs_folder' 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#Specify output directories
25time_dir1 = '20090528_153025_run_final_0.0_58346_jgriffin'
26##time_dir2 = '20090529_143458_run_final_0.0_58346_jgriffin'
27
28time_dirs = [time_dir1]#, time_dir2]   
29
30# sww filename extensions ie. if batemans_bay_time_37860_0.sww, input into list 37860
31# make sure numbers are in sequential order
32times = [37860]
33
34#Modify the cellsize value to set the size of the raster you require
35#Take into account mesh size when aplying this paramater
36cellsize = 20   #dependent on data resolution in area of interest.
37
38#Now set the timestep at which you want the raster generated.
39#Either set the actual timestep required or use 'None' to indicate that
40#you want the maximum values in the raster over all timesteps
41timestep = None    # None means no timestep!
42##timestep = 0
43
44######
45# Set the special areas of interest.  If none, do: area='All'
46######
47
48#area = ['', '']  # strings must match keys in var_equations below
49area = ['All']      # 'All' means no special areas - the whole thing
50
51######
52# Define allowed variable names and associated equations to generate values.
53# This would not normally change.
54######
55var_equations = {'stage':     'stage',
56                 'momentum':  '(xmomentum**2 + ymomentum**2)**0.5',
57                 'depth':     'stage-elevation',
58                 'speed':     '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)',
59                 'energy':  '(((xmomentum/(stage-elevation+1.e-6))**2 + (ymomentum/(stage-elevation+1.e-6))**2)*0.5*1000*(stage-elevation+1.e-6))+(9.81*stage*1000)',
60                 'elevation': 'elevation' }
61
62# one or more key strings from var_equations above
63#var = ['depth', 'speed','stage']
64var = ['energy']
65######
66# Start script, running through variables, area, folder, sww file (determine by times)
67# Then creates a maximum asci if there is more than one sww file
68######
69
70for which_var in var:
71    if which_var not in var_equations:
72        print 'Unrecognized variable name: %s' % which_var
73        break
74
75    for which_area in area:
76        if which_area == 'All':
77            easting_min = None
78            easting_max = None
79            northing_min = None
80            northing_max = None
81        else:
82            try:
83                easting_min = eval('project.xmin%s' % which_area)
84                easting_max = eval('project.xmax%s' % which_area)
85                northing_min = eval('project.ymin%s' % which_area)
86                northing_max = eval('project.ymax%s' % which_area)
87            except AttributeError:
88                print 'Unrecognized area name: %s' % which_area
89                break
90
91        for time_dir in time_dirs:
92            names = [join(directory, time_dir, project.scenario_name)]
93            for time in times:
94                names.append(join(directory, time_dir, project.scenario_name)+ '_time_' + str(time) + '_0')
95     
96            asc_name = []   
97               
98            for name in names:
99                         
100                outname = name + '_' + which_area + '_' + which_var
101                quantityname = var_equations[which_var]
102
103                print 'start sww2dem: time_dir=%s' % time_dir
104               
105                sww2dem(name, basename_out = outname,
106                            quantity = quantityname,
107                            timestep = timestep,
108                            cellsize = cellsize,     
109                            easting_min = easting_min,
110                            easting_max = easting_max,
111                            northing_min = northing_min,
112                            northing_max = northing_max,       
113                            reduction = max, 
114                            verbose = True,
115                            format = 'asc')
116
117                asc_name.append(outname + '.asc')
118   
119            if len(names) >1:
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                MaxAsc(maxasc_outname, asc_name)
126            else:
127                print 'only one sww input'
Note: See TracBrowser for help on using the repository browser.