1 | import project, os |
---|
2 | import sys |
---|
3 | |
---|
4 | from pyvolution.data_manager import sww2dem |
---|
5 | from pyvolution.ermapper_grids import read_ermapper_grid |
---|
6 | from pyvolution.util import Screen_Catcher |
---|
7 | from os import sep |
---|
8 | |
---|
9 | #time_dir = '20060704_063005' #HAT |
---|
10 | #time_dir = '20060704_063112' #LAT |
---|
11 | time_dir = '20060704_063234' #MSL |
---|
12 | directory = project.outputdir |
---|
13 | name = directory + time_dir +sep + 'source' |
---|
14 | |
---|
15 | #normal screen output is stored in 'outname' |
---|
16 | screen_output_name = directory + time_dir + sep + "export_output.txt" |
---|
17 | screen_error_name = directory + time_dir + sep + "export_error.txt" |
---|
18 | |
---|
19 | #used to catch screen output to file |
---|
20 | sys.stdout = Screen_Catcher(screen_output_name) |
---|
21 | sys.stderr = Screen_Catcher(screen_error_name) |
---|
22 | |
---|
23 | print '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 ' )) |
---|
26 | which_var = 2 |
---|
27 | #sys.stderr.write(sys.stdout.data) |
---|
28 | if which_var == 0: # Stage |
---|
29 | outname = name + '_stage' |
---|
30 | quantityname = 'stage' |
---|
31 | |
---|
32 | if which_var == 1: # Absolute Momentum |
---|
33 | outname = name + '_momentum' |
---|
34 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5' #Absolute momentum |
---|
35 | |
---|
36 | if which_var == 2: # Depth |
---|
37 | outname = name + '_depth' |
---|
38 | quantityname = 'stage-elevation' #Depth |
---|
39 | |
---|
40 | if 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 | |
---|
46 | if which_var == 4: # Elevation |
---|
47 | outname = name + '_elevation' |
---|
48 | quantityname = 'elevation' #Elevation |
---|
49 | |
---|
50 | print 'start sww2dem' |
---|
51 | #sys.stderr.write(sys.stdout.data) |
---|
52 | sww2dem(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)) |
---|