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