source: production/onslow_2006/export_results.py @ 3276

Last change on this file since 3276 was 3270, checked in by sexton, 18 years ago

updates to Onslow report

File size: 2.4 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
9#time_dir = '20060703_062936' #HAT
10#time_dir = '20060703_062753' #LAT
11time_dir = '20060703_062900' #MSL
12directory = project.outputdir
13name = directory + time_dir +sep + 'source'
14
15#normal screen output is stored in 'outname'
16screen_output_name = directory + time_dir + sep + "export_output.txt"
17screen_error_name = directory + time_dir + sep + "export_error.txt"
18
19#used to catch screen output to file
20sys.stdout = Screen_Catcher(screen_output_name)
21sys.stderr = Screen_Catcher(screen_error_name)
22
23print 'output dir:', name
24#print 'Which variable do you want to export?'
25#which_var = int(raw_input('Stage = 0, Absolute Momentum = 1, Depth = 2, Speed = 3  '  ))
26which_var = 2
27#sys.stderr.write(sys.stdout.data)
28if which_var == 0:  # Stage
29    outname = name + '_stage'
30    quantityname = 'stage'
31
32if which_var == 1:  # Absolute Momentum
33    outname = name + '_momentum'
34    quantityname = '(xmomentum**2 + ymomentum**2)**0.5'  #Absolute momentum
35
36if which_var == 2:  # Depth
37    outname = name + '_depth'
38    quantityname = 'stage-elevation'  #Depth
39
40if which_var == 3:  # Speed
41    outname = name + '_speed'
42    #quantityname = '((xmomentum/(stage-elevation))**2 + (ymomentum/(stage-elevation))**2)**0.5'  #Speed
43    #quantityname = 'xmomentum/(stage-elevation)'  #Speed
44    quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-30)'  #Speed
45
46if which_var == 4:  # Elevation
47    outname = name + '_elevation'
48    quantityname = 'elevation'  #Elevation
49
50print 'start sww2dem'
51#sys.stderr.write(sys.stdout.data)
52sww2dem(name, basename_out = outname,
53            quantity = quantityname,
54            cellsize = 20,       # Trevor would like this at 25
55            # define region for viz purposes
56            easting_min = project.e_min_area,
57            easting_max = project.e_max_area,
58            northing_min = project.n_min_area,
59            northing_max = project.n_max_area,       
60            reduction = max, #this is because we want max quantityname
61            verbose = True,
62            format = 'asc')
63
64#sys.stderr.write(sys.stdout.data)
65
66#Check
67
68#data = read_ermapper_grid(name)
69#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.