Changeset 5849
- Timestamp:
- Oct 21, 2008, 8:58:10 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
anuga_work/production/busselton/export_results_all.py
r5786 r5849 1 """ 2 Generates ascii grids of nominated areas - 3 Input: sww file from run_perth.py 4 boundaries for grids from project.py 5 Outputs: ascii grids of specified variables 6 Stored in the 'outputs_dir' folder for respective .sww file 7 8 Note: 9 If producing a grid for the enitre extent cellsize should be greater than 30m 10 If producing grids for inundation area resolution should be greater than mesh (ie ~22m) 11 """ 12 1 13 import project, os 2 14 import sys 3 4 15 from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts 5 16 from anuga.shallow_water.data_manager import sww2dem … … 7 18 8 19 9 #time_dir = '20080815_103708_run_final_0.6_polyline_newExtent_kvanputt' 10 time_dir = '20080910_154939_run_final_0.6_27255_alpha0.1_kvanputt' 20 directory = project.output_dir 11 21 12 is_parallel = False 13 #is_parallel = True 14 if is_parallel == True: nodes = 4 22 time_dir1 = '20081002_111432_run_final_0_27283_250m_none_kvanputt' 23 time_dir2 = '20081002_111258_run_final_0_27283_250m_all_kvanputt' 24 time_dir3 = '20080815_103818_run_final_0_polyline_newExtent_kvanputt' 15 25 26 time_dirs = [time_dir1, time_dir2, time_dir3] 16 27 17 cellsize = 15 28 #cellsize = 20 29 cellsize = 250 30 31 timestep = None # None means no timestep! 18 32 #timestep = 0 19 directory = project.output_dir20 name1 = directory+time_dir+sep+project.scenario_name21 name2 = directory+time_dir+sep+'sww2'+sep+project.scenario_name+'_time_38460_0'22 name3 = directory+time_dir+sep+'sww3'+sep+project.scenario_name+'_time_76920_0'23 33 24 names= [name1, name2, name3] 25 for name in names: 34 ###### 35 # Set the special areas of interest. If none, do: area='All' 36 ###### 37 #area = ['Geordie', 'Sorrento', 'Fremantle', 'Rockingham'] # strings must match keys in var_equations below 38 area = ['All'] # 'All' means no special areas - the whole thing 26 39 27 area = ['Busselton', 'Bunbury'] 40 ###### 41 # Define allowed variable names and associated equations to generate values. 42 # This would not normally change. 43 ###### 44 var_equations = {'stage': 'stage', 45 'momentum': '(xmomentum**2 + ymomentum**2)**0.5', 46 'depth': 'stage-elevation', 47 'speed': '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6)', 48 'elevation': 'elevation' } 28 49 29 for which_area in area: 30 if which_area == 'Busselton': 31 easting_min = project.xminBusselton 32 easting_max = project.xmaxBusselton 33 northing_min = project.yminBusselton 34 northing_max = project.ymaxBusselton 50 # one or more key strings from var_equations above 51 var = ['stage', 'elevation'] 35 52 36 if which_area == 'Bunbury': 37 easting_min = project.xminBunbury 38 easting_max = project.xmaxBunbury 39 northing_min = project.yminBunbury 40 northing_max = project.ymaxBunbury 53 ###### 54 # Start running the various conversions we require. 55 ###### 56 for time_dir in time_dirs: 57 name1 = directory+time_dir+sep+project.scenario_name 58 # name2 = directory+time_dir+sep+'sww2'+sep+project.scenario_name+'_time_39900_0' #need to get assistance on how to make this into anything 59 names = [name1] 60 61 for name in names: 62 for which_area in area: 63 if which_area == 'All': 64 easting_min = None 65 easting_max = None 66 northing_min = None 67 northing_max = None 68 else: 69 try: 70 easting_min = eval('project.xmin%s' % which_area) 71 easting_max = eval('project.xmax%s' % which_area) 72 northing_min = eval('project.ymin%s' % which_area) 73 northing_max = eval('project.ymax%s' % which_area) 74 except AttributeError: 75 print 'Unrecognized area name: %s' % which_area 76 break 77 78 for which_var in var: 79 if which_var not in var_equations: 80 print 'Unrecognized variable name: %s' % which_var 81 break 41 82 42 var = [2] # momentum and depth 43 #var = [2] # depth 44 #var = [0,4] 83 outname = name + which_area + '_' + which_var 84 quantityname = var_equations[which_var] 45 85 46 for which_var in var: 47 if which_var == 0: # Stage 48 outname = name + which_area + '_stage' 49 quantityname = 'stage' 50 51 if which_var == 1: # Absolute Momentum 52 outname = name + which_area + '_momentum' 53 quantityname = '(xmomentum**2 + ymomentum**2)**0.5' 54 55 if which_var == 2: # Depth 56 outname = name + which_area + '_depth' 57 quantityname = 'stage-elevation' 58 59 if which_var == 3: # Speed 60 outname = name + which_area + '_speed' 61 quantityname = '(xmomentum**2 + ymomentum**2)**0.5/(stage-elevation+1.e-6/(stage-elevation))' #Speed 62 63 if which_var == 4: # Elevation 64 outname = name + which_area + '_elevation' 65 quantityname = 'elevation' #Elevation 66 67 if is_parallel == True: 68 # print 'is_parallel',is_parallel 69 for i in range(0,nodes): 70 namei = name + '_P%d_%d' %(i,nodes) 71 outnamei = outname + '_P%d_%d' %(i,nodes) 72 print 'start sww2dem for sww file %d' %(i) 73 sww2dem(namei, basename_out = outnamei, 74 quantity = quantityname, 75 #timestep = timestep, 76 cellsize = cellsize, 77 easting_min = project_grad.e_min_area, 78 easting_max = project_grad.e_max_area, 79 northing_min = project_grad.n_min_area, 80 northing_max = project_grad.n_max_area, 81 reduction = max, 82 verbose = True, 83 format = 'asc') 84 else: 85 print 'start sww2dem',which_area, easting_min,name,outname 86 print 'start sww2dem: time_dir=%s' % time_dir 87 86 88 sww2dem(name, basename_out = outname, 87 89 quantity = quantityname, 88 #timestep = timestep,90 timestep = timestep, 89 91 cellsize = cellsize, 90 92 easting_min = easting_min, … … 95 97 verbose = True, 96 98 format = 'asc') 97
Note: See TracChangeset
for help on using the changeset viewer.