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