[5066] | 1 | import os |
---|
| 2 | import sys |
---|
| 3 | |
---|
| 4 | from anuga.shallow_water.data_manager import sww2dem |
---|
| 5 | from os import sep |
---|
| 6 | |
---|
| 7 | name2= 'gap' |
---|
| 8 | time_dir = '2550_1_2700_20000gap' # sww file location |
---|
| 9 | |
---|
| 10 | cellsize = 5 |
---|
| 11 | #cellsize = 150 |
---|
| 12 | timestep = None |
---|
| 13 | output_dir = sep+'d'+sep+'xrd'+sep+'gem'+sep+'5'+sep+'nhi'+sep+'inundation'+sep+'data'+sep+'idealised_bathymetry_study'+sep+'final_models'+sep+'gap'+sep+'transect'+sep |
---|
| 14 | directory = output_dir |
---|
| 15 | |
---|
| 16 | name = directory+time_dir+sep+str(name2) |
---|
| 17 | |
---|
| 18 | |
---|
| 19 | from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts |
---|
| 20 | |
---|
| 21 | is_parallel = False |
---|
| 22 | #is_parallel = True |
---|
| 23 | if is_parallel == True: nodes = 4 |
---|
| 24 | print 'output dir:', name |
---|
| 25 | |
---|
| 26 | #var = [2,3,4] # depth and speed |
---|
| 27 | #var = [2] # depth |
---|
| 28 | #var = [4] |
---|
| 29 | var = [0] |
---|
| 30 | |
---|
| 31 | for which_var in var: |
---|
| 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' |
---|
| 39 | |
---|
| 40 | if which_var == 2: # Depth |
---|
| 41 | outname = name + '_depth' |
---|
| 42 | quantityname = 'stage-elevation' |
---|
| 43 | |
---|
| 44 | if which_var == 3: # Speed |
---|
| 45 | outname = name + '_speed' |
---|
| 46 | quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6/(stage-elevation))' #Speed |
---|
| 47 | |
---|
| 48 | if which_var == 4: # Elevation |
---|
| 49 | outname = name + '_elevation' |
---|
| 50 | quantityname = 'elevation' #Elevation |
---|
| 51 | |
---|
| 52 | if is_parallel == True: |
---|
| 53 | # print 'is_parallel',is_parallel |
---|
| 54 | for i in range(0,nodes): |
---|
| 55 | namei = name + '_P%d_%d' %(i,nodes) |
---|
| 56 | outnamei = outname + '_P%d_%d' %(i,nodes) |
---|
| 57 | print 'start sww2dem for sww file %d' %(i) |
---|
| 58 | sww2dem(namei, basename_out = outnamei, |
---|
| 59 | quantity = quantityname, |
---|
| 60 | timestep = timestep, |
---|
| 61 | cellsize = cellsize, |
---|
| 62 | easting_min = project_grad.e_min_area, |
---|
| 63 | easting_max = project_grad.e_max_area, |
---|
| 64 | northing_min = project_grad.n_min_area, |
---|
| 65 | northing_max = project_grad.n_max_area, |
---|
| 66 | reduction = max, |
---|
| 67 | verbose = True, |
---|
| 68 | format = 'asc') |
---|
| 69 | else: |
---|
| 70 | print 'start sww2dem' |
---|
| 71 | sww2dem(name, basename_out = outname, |
---|
| 72 | quantity = quantityname, |
---|
| 73 | timestep = timestep, |
---|
| 74 | cellsize = cellsize, |
---|
| 75 | #easting_min = project_grad.e_min_area, |
---|
| 76 | #easting_max = project_grad.e_max_area, |
---|
| 77 | #northing_min = project_grad.n_min_area, |
---|
| 78 | #northing_max = project_grad.n_max_area, |
---|
| 79 | reduction = max, |
---|
| 80 | verbose = True, |
---|
| 81 | format = 'asc') |
---|
| 82 | |
---|