[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 | |
---|
[3270] | 9 | #time_dir = '20060703_062936' #HAT |
---|
| 10 | #time_dir = '20060703_062753' #LAT |
---|
| 11 | time_dir = '20060703_062900' #MSL |
---|
[2682] | 12 | directory = project.outputdir |
---|
[3270] | 13 | name = directory + time_dir +sep + 'source' |
---|
[2682] | 14 | |
---|
[2700] | 15 | #normal screen output is stored in 'outname' |
---|
| 16 | screen_output_name = directory + time_dir + sep + "export_output.txt" |
---|
[2773] | 17 | screen_error_name = directory + time_dir + sep + "export_error.txt" |
---|
[2700] | 18 | |
---|
| 19 | #used to catch screen output to file |
---|
| 20 | sys.stdout = Screen_Catcher(screen_output_name) |
---|
[2773] | 21 | sys.stderr = Screen_Catcher(screen_error_name) |
---|
[2700] | 22 | |
---|
| 23 | print '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] | 26 | which_var = 2 |
---|
[2956] | 27 | #sys.stderr.write(sys.stdout.data) |
---|
[2543] | 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 | |
---|
[2682] | 46 | if which_var == 4: # Elevation |
---|
| 47 | outname = name + '_elevation' |
---|
| 48 | quantityname = 'elevation' #Elevation |
---|
| 49 | |
---|
[2700] | 50 | print 'start sww2dem' |
---|
[2956] | 51 | #sys.stderr.write(sys.stdout.data) |
---|
[2543] | 52 | sww2dem(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)) |
---|