[2543] | 1 | import project, os |
---|
[2700] | 2 | import sys |
---|
[2543] | 3 | |
---|
| 4 | from pyvolution.data_manager import sww2dem |
---|
| 5 | from pyvolution.ermapper_grids import read_ermapper_grid |
---|
[2700] | 6 | from pyvolution.util import Screen_Catcher |
---|
| 7 | from os import sep |
---|
[2543] | 8 | |
---|
[2955] | 9 | time_dir = "20060426_004129" |
---|
[2682] | 10 | directory = project.outputdir |
---|
| 11 | name = directory + time_dir +sep + "source" |
---|
| 12 | |
---|
[2700] | 13 | #normal screen output is stored in 'outname' |
---|
| 14 | screen_output_name = directory + time_dir + sep + "export_output.txt" |
---|
[2773] | 15 | screen_error_name = directory + time_dir + sep + "export_error.txt" |
---|
[2700] | 16 | |
---|
| 17 | #used to catch screen output to file |
---|
| 18 | sys.stdout = Screen_Catcher(screen_output_name) |
---|
[2773] | 19 | sys.stderr = Screen_Catcher(screen_error_name) |
---|
[2700] | 20 | |
---|
| 21 | print 'output dir:', name |
---|
[2543] | 22 | #print 'Which variable do you want to export?' |
---|
| 23 | #which_var = int(raw_input('Stage = 0, Absolute Momentum = 1, Depth = 2, Speed = 3 ' )) |
---|
[2773] | 24 | which_var = 2 |
---|
[2956] | 25 | #sys.stderr.write(sys.stdout.data) |
---|
[2543] | 26 | if which_var == 0: # Stage |
---|
| 27 | outname = name + '_stage' |
---|
| 28 | quantityname = 'stage' |
---|
| 29 | |
---|
| 30 | if which_var == 1: # Absolute Momentum |
---|
| 31 | outname = name + '_momentum' |
---|
| 32 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5' #Absolute momentum |
---|
| 33 | |
---|
| 34 | if which_var == 2: # Depth |
---|
| 35 | outname = name + '_depth' |
---|
| 36 | quantityname = 'stage-elevation' #Depth |
---|
| 37 | |
---|
| 38 | if which_var == 3: # Speed |
---|
| 39 | outname = name + '_speed' |
---|
| 40 | #quantityname = '((xmomentum/(stage-elevation))**2 + (ymomentum/(stage-elevation))**2)**0.5' #Speed |
---|
| 41 | #quantityname = 'xmomentum/(stage-elevation)' #Speed |
---|
| 42 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-30)' #Speed |
---|
| 43 | |
---|
[2682] | 44 | if which_var == 4: # Elevation |
---|
| 45 | outname = name + '_elevation' |
---|
| 46 | quantityname = 'elevation' #Elevation |
---|
| 47 | |
---|
[2700] | 48 | print 'start sww2dem' |
---|
[2956] | 49 | #sys.stderr.write(sys.stdout.data) |
---|
[2543] | 50 | sww2dem(name, basename_out = outname, |
---|
| 51 | quantity = quantityname, |
---|
[2773] | 52 | cellsize = 20, # Trevor would like this at 25 |
---|
[2543] | 53 | # define region for viz purposes |
---|
[2682] | 54 | easting_min = project.e_min_area, |
---|
| 55 | easting_max = project.e_max_area, |
---|
| 56 | northing_min = project.n_min_area, |
---|
| 57 | northing_max = project.n_max_area, |
---|
[2543] | 58 | reduction = max, #this is because we want max quantityname |
---|
| 59 | verbose = True, |
---|
| 60 | format = 'asc') |
---|
| 61 | |
---|
[2956] | 62 | #sys.stderr.write(sys.stdout.data) |
---|
[2700] | 63 | |
---|
[2543] | 64 | #Check |
---|
| 65 | |
---|
| 66 | #data = read_ermapper_grid(name) |
---|
| 67 | #print 'Values from %s are in [%f, %f]' %(name, min(data.flat), max(data.flat)) |
---|