Changeset 6324


Ignore:
Timestamp:
Feb 12, 2009, 4:50:25 PM (15 years ago)
Author:
rwilson
Message:

Changes to project+setup_model+build_urs_boundary+run_model.

Location:
anuga_work/production/busselton/standardised_version
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/production/busselton/standardised_version/project.py

    r6312 r6324  
    11"""
    2 Common filenames and locations for elevation, meshes and outputs.
    3 This script is the heart of all scripts in the folder
     2This file contains all your file and directory definitions
     3for elevation, meshes and outputs.
    44"""
    55
    6 import sys
    76import os
     7from anuga.utilities.system_tools import get_user_name, get_host_name
     8from time import localtime, strftime, gmtime
    89from os.path import join, exists
    9 from time import localtime, strftime, gmtime
    10 from anuga.utilities.polygon import read_polygon, number_mesh_triangles
    11 from anuga.utilities.system_tools import get_user_name, get_host_name
    12 
    13 
    14 #-----
    15 # Get system data - don't fiddle with this.
    16 # These values can be used to distinguish between two similar runs by two
    17 # different users or runs by the same user on two different machines.
    18 #-----
    19 
    20 user = get_user_name()
    21 host = get_host_name()
     10
    2211
    2312#-------------------------------------------------------------------------------
     
    3726# Model specific parameters.
    3827# One or all can be changed each time the run_model script is executed
    39 tide = 0                # ??
    40 event_number = 27283    # the event number
     28tide = 0                # difference between MSL and HAT
     29event_number = 26633    # the event number
    4130alpha = 0.1             # smoothing parameter for mesh
    4231friction=0.01           # manning's friction coefficient
     
    4433finaltime=80000         # final time for simulation
    4534
    46 setup = 'final'  # Final can be replaced with trial or basic.
    47                  # Either will result in a coarser mesh that will
    48                  # allow a faster, but less accurate, simulation.
    49 
    50 #-------------------------------------------------------------------------------
    51 # Output Filename
    52 #-------------------------------------------------------------------------------
    53 
    54 # Important to distinguish each run - ensure str(user) is included!
    55 # Note, the user is free to include as many parameters as desired
    56 # This should be moved to run_model.py, with the user providing the list to join
    57 # for example: output_comment_list = [setup, str(tide), str(event_number), str(user)]
    58 output_comment = '_'.join([setup, str(tide), str(event_number), str(user)])
     35setup = 'final'         # This can be one of three values
     36                        #    trial - coarsest mesh, fast
     37                        #    basic - coarse mesh
     38                        #    final - fine mesh, slowest
     39
     40#-------------------------------------------------------------------------------
     41# Output filename
     42#
     43# Your output filename should be unique between different runs on different data.
     44# The list of items below will be used to create a file in your output directory.
     45# Your user name and time+date will be automatically added.  For example,
     46#     [setup, tide, event_number]
     47# will result in a filename like
     48#     20090212_091046_run_final_0_27283_rwilson
     49#-------------------------------------------------------------------------------
     50
     51output_comment = [setup, tide, event_number]
    5952
    6053#-------------------------------------------------------------------------------
     
    109102# Used in run_building_inundation.py
    110103# Format latitude,longitude etc (geographic)
    111 building_exposure_filename = 'busselton_res_clip.csv' #from NEXIS
     104building_exposure_filename = 'busselton_res_clip.csv' # from NEXIS
    112105
    113106# BOUNDING POLYGON - used in build_boundary.py and run_model.py respectively
     
    124117landward_boundary_filename = 'landward_boundary_extend.csv'
    125118
    126 # MUX input filename
    127 # Must exist in $MUXHOME/mux directory.
    128 # File is prodiced by EventSelection.
    129 # If MUX file not used, do "mux_input_filename = None".
    130 mux_input_filename = r'C:\temp\event_026633.list'
     119# MUX input filename.
     120# If a meta-file from EventSelection is used, set 'multi-mux' to True.
     121# If a single MUX stem filename is used, set 'multi-mux' to False.
     122mux_input_filename = 'event_026633.list'
     123multi_mux = True
    131124
    132125#-------------------------------------------------------------------------------
     
    147140ymaxBunbury = 6316500
    148141
    149 
    150 ################################################################################
    151 ################################################################################
    152 ####             NOTE: NOTHING SHOULD CHANGE BELOW THIS POINT.              ####
    153 ################################################################################
    154 ################################################################################
    155 
    156 #-------------------------------------------------------------------------------
    157 # Sanity checks
    158 #-------------------------------------------------------------------------------
    159 
    160 # Test that environment variables are defined.
    161 # A little late, but better here than up in user-changeable data.
     142################################################################################
     143################################################################################
     144####         NOTE: NOTHING WOULD NORMALLY CHANGE BELOW THIS POINT.          ####
     145################################################################################
     146################################################################################
     147
     148# Get system user and host names.
     149# These values can be used to distinguish between two similar runs by two
     150# different users or runs by the same user on two different machines.
     151user = get_user_name()
     152host = get_host_name()
    162153
    163154# Environment variable names.
     
    167158# Path to MUX data
    168159ENV_MUXHOME = 'MUXHOME'
    169 
    170 ### Check we have required environment variables set
    171 ##sanity_error = False               # checked at bottom of this file
    172 ##
    173 ##if os.getenv(ENV_INUNDATIONHOME) is None:
    174 ##    print "Environment variable '%s' is not set" % ENV_INUNDATIONHOME
    175 ##    sanity_error = True
    176 ##
    177 ##if os.getenv(ENV_MUXHOME) is None:
    178 ##    print "Environment variable '%s' is not set" % ENV_MUXHOME
    179 ##    sanity_error = True
    180 ##
    181 ### check for errors detected so far
    182 ##if sanity_error:
    183 ##    print 'You must fix the above errors before continuing.'
    184 ##    sys.exit(10)
    185160
    186161#-------------------------------------------------------------------------------
     
    204179# create paths generated from environment variables.
    205180home = join(os.getenv(ENV_INUNDATIONHOME), 'data') # Absolute path for data folder
    206 ##if not exists(home):
    207 ##    print "Sorry, data directory '%s' doesn't exist" % home
    208 ##    sanity_error = True
    209    
    210181muxhome = os.getenv(ENV_MUXHOME)
    211 ##if not exists(muxhome):
    212 ##    print "Sorry, MUX directory '%s' doesn't exist" % muxhome
    213 ##    sanity_error = True
    214182   
    215183# check various directories/files that must exist
    216184anuga_folder = join(home, state, scenario_folder, 'anuga')
    217 ##if not exists(anuga_folder):
    218 ##    print "Sorry, ANUGA directory '%s' doesn't exist" % anuga_folder
    219 ##    sanity_error = True
    220 
    221185topographies_folder = join(anuga_folder, 'topographies')
    222 ##if not exists(topographies_folder):
    223 ##    print "Sorry, topo directory '%s' doesn't exist" % topographies_folder
    224 ##    sanity_error = True
    225 
    226186polygons_folder = join(anuga_folder, 'polygons')
    227 ##if not exists(polygons_folder):
    228 ##    print "Sorry, polygon directory '%s' doesn't exist" % polygons_folder
    229 ##    sanity_error = True
    230 
    231187boundaries_folder = join(anuga_folder, 'boundaries')
    232 ##if not exists(boundaries_folder):
    233 ##    print "Sorry, boundaries directory '%s' doesn't exist" % boundaries_folder
    234 ##    sanity_error = True
    235 
    236188output_folder = join(anuga_folder, 'outputs')
    237 ##if not exists(output_folder):
    238 ##    print "Sorry, outputs directory '%s' doesn't exist" % output_folder
    239 ##    sanity_error = True
    240 
    241189gauges_folder = join(anuga_folder, 'gauges')
    242 ##if not exists(gauges_folder):
    243 ##    print "Sorry, gauges directory '%s' doesn't exist" % gauges_folder
    244 ##    sanity_error = True
    245 
    246190meshes_folder = join(anuga_folder, 'meshes')
    247 ##if not exists(meshes_folder):
    248 ##    print "Sorry, meshes directory '%s' doesn't exist" % meshes_folder
    249 ##    sanity_error = True
    250 
    251 ### if mux_input_filename has been defined, check if file exists
    252 ##if mux_input_filename:
    253 ##    if not exists(mux_input_filename):
    254 ##        print ("Sorry, MUX input file '%s' doesn't exist" % mux_input_filename)
    255 ##        sanity_error = True
    256 
    257 #-----
    258 # If these directories don't exist initially, create them.
    259 # This should be moved to run_model.py.
    260 #-----
    261 
    262191event_folder = join(boundaries_folder, str(event_number))
    263 if not exists(event_folder):
    264     print "Creating directory 'event_folder'=%s" % event_folder
    265     os.mkdir(event_folder)
     192
     193# MUX data files
     194# Directory containing the MUX data files to be used with EventSelection.
     195mux_data_folder = '/nas/gemd/georisk_models/tsunami/models/PTHA/Australia/mux'
    266196
    267197#-------------------------------------------------------------------------------
    268198# Location of input and output data
    269199#-------------------------------------------------------------------------------
     200
     201# Convert the user output_comment to a string for run_model.py
     202output_comment = ('_'.join([str(x) for x in output_comment if x != user])
     203                  + '_' + user)
    270204
    271205# The absolute pathname of the all elevation, generated in build_elevation.py
     
    283217
    284218# The absolute pathname for the .sts file, generated in build_boundary.py
    285 event_sts = join(boundaries_folder, str(event_number), scenario_name)
     219event_sts = join(event_folder, scenario_name)
    286220
    287221# The absolute pathname for the output folder names
     
    301235building_exposure = join(gauges_folder, building_exposure_filename)
    302236
    303 #-------------------------------------------------------------------------------
    304 # Determine type of run
    305 #-------------------------------------------------------------------------------
    306 
    307 if setup == 'trial':
    308     print 'trial'
    309     scale_factor = 100
    310     time_thinning = 96
    311     yieldstep = 240
    312 elif setup == 'basic':
    313     print 'basic'
    314     scale_factor = 4
    315     time_thinning = 12
    316     yieldstep = 120
    317 elif setup == 'final':
    318     print 'final'
    319     scale_factor = 1
    320     time_thinning = 4
    321     yieldstep = 60
    322 ##else:
    323 ##    print ("Sorry, you must set the 'setup' variable to one of 'trial', "
    324 ##           "'basic' or 'final'. I found '%s'" % str(setup))
    325 ##    sanity_error = True
    326 
    327 #-------------------------------------------------------------------------------
    328 # Reading polygons and creating interior regions
    329 #-------------------------------------------------------------------------------
    330 
    331 # Create list of land polygons with initial conditions
    332 land_initial_conditions = []
    333 for filename, MSL in land_initial_conditions_filename:
    334     polygon = read_polygon(join(polygons_folder, filename))
    335     land_initial_conditions.append([polygon, MSL])
    336 
    337 # Create list of interior polygons with scaling factor
    338 interior_regions = []
    339 for filename, maxarea in interior_regions_data:
    340     polygon = read_polygon(join(polygons_folder, filename))
    341     interior_regions.append([polygon, maxarea*scale_factor])
    342 
    343 # Initial bounding polygon for data clipping
    344 bounding_polygon = read_polygon(join(polygons_folder,
    345                                      bounding_polygon_filename))
    346 bounding_maxarea = bounding_polygon_maxarea*scale_factor
    347 
    348 # Estimate the number of triangles                     
    349 trigs_min = number_mesh_triangles(interior_regions,
    350                                   bounding_polygon, bounding_maxarea)
    351 
    352 ###-------------------------------------------------------------------------------
    353 ### Check for errors detected above.
    354 ###-------------------------------------------------------------------------------
    355 ##
    356 ##if sanity_error:
    357 ##    print 'You must fix the above errors before continuing.'
    358 ##    sys.exit(10)
    359 
    360 
    361 print 'min estimated number of triangles', trigs_min
     237# full path to where MUX files (or meta-files) live
     238mux_input = join(boundaries_folder, mux_input_filename)
     239
  • anuga_work/production/busselton/standardised_version/run_model.py

    r6312 r6324  
    3838   
    3939# Application specific imports
    40 import project  # Definition of file names and polygons
     40from setup_model import project
    4141import build_urs_boundary as bub
    4242
    43 
    44 #-------------------------------------------------------------------------------
    45 # Perform (as much as possible) a sanity check on values from import of project.
    46 #-------------------------------------------------------------------------------
    4743
    4844#-------------------------------------------------------------------------------
     
    6561
    6662# Create the STS file
    67 bub.build_urs_boundary(os.path.join(project.muxhome, 'mux'),
    68                        project.mux_input_filename,
     63bub.build_urs_boundary(project.mux_data_folder,
     64                       project.mux_input,
    6965                       os.path.join(project.event_folder,
    7066                                    project.scenario_name))
Note: See TracChangeset for help on using the changeset viewer.