source: production/onslow_2006/export_results.py @ 3270

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

updates to Onslow report

File size: 2.4 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
[3270]9#time_dir = '20060703_062936' #HAT
10#time_dir = '20060703_062753' #LAT
11time_dir = '20060703_062900' #MSL
[2682]12directory = project.outputdir
[3270]13name = directory + time_dir +sep + 'source'
[2682]14
[2700]15#normal screen output is stored in 'outname'
16screen_output_name = directory + time_dir + sep + "export_output.txt"
[2773]17screen_error_name = directory + time_dir + sep + "export_error.txt"
[2700]18
19#used to catch screen output to file
20sys.stdout = Screen_Catcher(screen_output_name)
[2773]21sys.stderr = Screen_Catcher(screen_error_name)
[2700]22
23print 'output dir:', name
[2543]24#print 'Which variable do you want to export?'
25#which_var = int(raw_input('Stage = 0, Absolute Momentum = 1, Depth = 2, Speed = 3  '  ))
[3270]26which_var = 2
[2956]27#sys.stderr.write(sys.stdout.data)
[2543]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
[2682]46if which_var == 4:  # Elevation
47    outname = name + '_elevation'
48    quantityname = 'elevation'  #Elevation
49
[2700]50print 'start sww2dem'
[2956]51#sys.stderr.write(sys.stdout.data)
[2543]52sww2dem(name, basename_out = outname,
53            quantity = quantityname,
[2773]54            cellsize = 20,       # Trevor would like this at 25
[2543]55            # define region for viz purposes
[2682]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,       
[2543]60            reduction = max, #this is because we want max quantityname
61            verbose = True,
62            format = 'asc')
63
[2956]64#sys.stderr.write(sys.stdout.data)
[2700]65
[2543]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.