Changeset 5849


Ignore:
Timestamp:
Oct 21, 2008, 8:58:10 AM (16 years ago)
Author:
Leharne
Message:

updated export script to include the 250m bathy comparisons for Phase 2 hazard map

File:
1 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/busselton/export_results_all.py

    r5786 r5849  
     1"""
     2Generates ascii grids of nominated areas -
     3Input: sww file from run_perth.py
     4       boundaries for grids from project.py
     5Outputs: ascii grids of specified variables
     6Stored in the 'outputs_dir' folder for respective .sww file
     7
     8Note:
     9If producing a grid for the enitre extent cellsize should be greater than 30m
     10If producing grids for inundation area resolution should be greater than mesh (ie ~22m)
     11"""
     12
    113import project, os
    214import sys
    3 
    415from anuga.shallow_water.data_manager import convert_dem_from_ascii2netcdf, dem2pts
    516from anuga.shallow_water.data_manager import sww2dem
     
    718
    819
    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'
     20directory = project.output_dir
    1121
    12 is_parallel = False
    13 #is_parallel = True
    14 if is_parallel == True: nodes = 4
     22time_dir1 = '20081002_111432_run_final_0_27283_250m_none_kvanputt'
     23time_dir2 = '20081002_111258_run_final_0_27283_250m_all_kvanputt'
     24time_dir3 = '20080815_103818_run_final_0_polyline_newExtent_kvanputt'
    1525
     26time_dirs = [time_dir1, time_dir2, time_dir3]
    1627
    17 cellsize = 15
     28#cellsize = 20
     29cellsize = 250
     30
     31timestep = None    # None means no timestep!
    1832#timestep = 0
    19 directory = project.output_dir
    20 name1 = directory+time_dir+sep+project.scenario_name
    21 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'
    2333
    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
     38area = ['All']      # 'All' means no special areas - the whole thing
    2639
    27     area = ['Busselton', 'Bunbury']
     40######
     41# Define allowed variable names and associated equations to generate values.
     42# This would not normally change.
     43######
     44var_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' }
    2849
    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
     51var = ['stage', 'elevation']
    3552
    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######
     56for 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
    4182
    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]
    4585
    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               
    8688                sww2dem(name, basename_out = outname,
    8789                            quantity = quantityname,
    88                             #timestep = timestep,
     90                            timestep = timestep,
    8991                            cellsize = cellsize,     
    9092                            easting_min = easting_min,
     
    9597                            verbose = True,
    9698                            format = 'asc')
    97 
Note: See TracChangeset for help on using the changeset viewer.