source: production/onslow_2006/export_results.py @ 3031

Last change on this file since 3031 was 2956, checked in by nick, 19 years ago

update to Onslow

File size: 2.3 KB
Line 
1import project, os
2import sys
3
4from pyvolution.data_manager import sww2dem
5from pyvolution.ermapper_grids import read_ermapper_grid
6from pyvolution.util import Screen_Catcher
7from os import sep
8
9time_dir = "20060426_004129"
10directory = project.outputdir
11name = directory + time_dir +sep + "source"
12
13#normal screen output is stored in 'outname'
14screen_output_name = directory + time_dir + sep + "export_output.txt"
15screen_error_name = directory + time_dir + sep + "export_error.txt"
16
17#used to catch screen output to file
18sys.stdout = Screen_Catcher(screen_output_name)
19sys.stderr = Screen_Catcher(screen_error_name)
20
21print 'output dir:', name
22#print 'Which variable do you want to export?'
23#which_var = int(raw_input('Stage = 0, Absolute Momentum = 1, Depth = 2, Speed = 3  '  ))
24which_var = 2
25#sys.stderr.write(sys.stdout.data)
26if which_var == 0:  # Stage
27    outname = name + '_stage'
28    quantityname = 'stage'
29
30if which_var == 1:  # Absolute Momentum
31    outname = name + '_momentum'
32    quantityname = '(xmomentum**2 + ymomentum**2)**0.5'  #Absolute momentum
33
34if which_var == 2:  # Depth
35    outname = name + '_depth'
36    quantityname = 'stage-elevation'  #Depth
37
38if which_var == 3:  # Speed
39    outname = name + '_speed'
40    #quantityname = '((xmomentum/(stage-elevation))**2 + (ymomentum/(stage-elevation))**2)**0.5'  #Speed
41    #quantityname = 'xmomentum/(stage-elevation)'  #Speed
42    quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-30)'  #Speed
43
44if which_var == 4:  # Elevation
45    outname = name + '_elevation'
46    quantityname = 'elevation'  #Elevation
47
48print 'start sww2dem'
49#sys.stderr.write(sys.stdout.data)
50sww2dem(name, basename_out = outname,
51            quantity = quantityname,
52            cellsize = 20,       # Trevor would like this at 25
53            # define region for viz purposes
54            easting_min = project.e_min_area,
55            easting_max = project.e_max_area,
56            northing_min = project.n_min_area,
57            northing_max = project.n_max_area,       
58            reduction = max, #this is because we want max quantityname
59            verbose = True,
60            format = 'asc')
61
62#sys.stderr.write(sys.stdout.data)
63
64#Check
65
66#data = read_ermapper_grid(name)
67#print 'Values from %s are in [%f, %f]' %(name, min(data.flat), max(data.flat))
Note: See TracBrowser for help on using the repository browser.