source: production/onslow_2006/export_results.py @ 3160

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

update to Onslow

File size: 2.3 KB
RevLine 
[2543]1import project, os
[2700]2import sys
[2543]3
4from pyvolution.data_manager import sww2dem
5from pyvolution.ermapper_grids import read_ermapper_grid
[2700]6from pyvolution.util import Screen_Catcher
7from os import sep
[2543]8
[2955]9time_dir = "20060426_004129"
[2682]10directory = project.outputdir
11name = directory + time_dir +sep + "source"
12
[2700]13#normal screen output is stored in 'outname'
14screen_output_name = directory + time_dir + sep + "export_output.txt"
[2773]15screen_error_name = directory + time_dir + sep + "export_error.txt"
[2700]16
17#used to catch screen output to file
18sys.stdout = Screen_Catcher(screen_output_name)
[2773]19sys.stderr = Screen_Catcher(screen_error_name)
[2700]20
21print 'output dir:', name
[2543]22#print 'Which variable do you want to export?'
23#which_var = int(raw_input('Stage = 0, Absolute Momentum = 1, Depth = 2, Speed = 3  '  ))
[2773]24which_var = 2
[2956]25#sys.stderr.write(sys.stdout.data)
[2543]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
[2682]44if which_var == 4:  # Elevation
45    outname = name + '_elevation'
46    quantityname = 'elevation'  #Elevation
47
[2700]48print 'start sww2dem'
[2956]49#sys.stderr.write(sys.stdout.data)
[2543]50sww2dem(name, basename_out = outname,
51            quantity = quantityname,
[2773]52            cellsize = 20,       # Trevor would like this at 25
[2543]53            # define region for viz purposes
[2682]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,       
[2543]58            reduction = max, #this is because we want max quantityname
59            verbose = True,
60            format = 'asc')
61
[2956]62#sys.stderr.write(sys.stdout.data)
[2700]63
[2543]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.