Changeset 5392


Ignore:
Timestamp:
Jun 4, 2008, 2:44:28 PM (16 years ago)
Author:
duncan
Message:

Current Hinwood scenario

Location:
anuga_work/development/Hinwood_2008
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • anuga_work/development/Hinwood_2008/prepare_time_boundary.py

    r5370 r5392  
    2323from interp import interp
    2424
    25 def prepare_time_boundary(filename):
     25from os.path import join
     26
     27# from os import getenv
     28# from os.path import join
     29# home = getenv('INUNDATIONHOME')
     30# Hinwood_dir = join(home,'data','flumes','Hinwood_2008')
     31# raw_data_dir = join(Hinwood_dir, 'raw_data')
     32   
     33def csv2tms(filename, offshore_bed_elevation):
    2634    """Convert benchmark 2 time series to NetCDF tms file.
     35    the filename is the name of the output tms file, eg 'hi.tsm'.
     36    There must be an equivalent .csv file, eg 'hi.csv'.
    2737   
    2838    """
     
    5060
    5161        T[i] = float(fields[0])
    52         Q[i] = depth = float(fields[1])
     62        Q[i] = float(fields[1])
     63        depth = Q[i] - offshore_bed_elevation
    5364        X[i] = float(fields[2]) * depth
    5465        try:
     
    187198    fid.close()
    188199
     200def prepare_time_boundary(metadata_dic, raw_data_dir, output_dir):
     201    """
     202    """
     203    scenario_id = metadata_dic['scenario_id']
     204    velocity_file = join(raw_data_dir,scenario_id+'velfilt.txt')
     205    depth_file = join(raw_data_dir,scenario_id+'pressfilt.txt')
     206    out_file = join(output_dir, scenario_id+'_boundary.csv')
     207   
     208    combine_velocity_depth(velocity_file, depth_file, out_file) 
     209    tsm_file = out_file[:-4] + '.tsm'
     210    if metadata_dic['xleft'][1] >= 0.0:
     211        # This should be a -ve value, since the still water level is the
     212        # z origin.
     213        print "Warning: The z origin seems incorrect."
     214       
     215    csv2tms(tsm_file, metadata_dic['xleft'][1])
    189216   
    190217   
    191218#-------------------------------------------------------------------
    192219if __name__ == "__main__":
    193     from os import getenv
    194     from os.path import join
    195     home = getenv('INUNDATIONHOME')
    196     Hinwood_dir = join(home,'data','flumes','Hinwood_2008')
    197     raw_data_dir = join(Hinwood_dir, 'raw_data')
    198 
    199     # Test 1 Run 5
    200     combine_velocity_depth(join(raw_data_dir,'T1R5velfilt.txt'),
    201                            join(raw_data_dir,'T1R5pressfilt.txt'),
    202                            join(Hinwood_dir, 'T1R5_boundary.csv'))   
    203     # Create the tsm file
    204     prepare_time_boundary(join(Hinwood_dir, 'T1R5_boundary.tsm'))
    205    
    206     # Test 2 Run 7
    207     combine_velocity_depth(join(raw_data_dir,'T2R7velfilt.txt'),
    208                            join(raw_data_dir,'T2R7pressfilt.txt'),
    209                            join(Hinwood_dir, 'T2R7_boundary.csv'))
    210     # Create the tsm file
    211     prepare_time_boundary(join(Hinwood_dir, 'T2R7_boundary.tsm'))
     220    pass
  • anuga_work/development/Hinwood_2008/project.py

    r5370 r5392  
    33"""
    44
    5 from os import sep, environ, getenv, getcwd
     5from os import sep, getenv, getcwd, mkdir, access, F_OK
    66import sys
    77from time import localtime, strftime
    8 from os import mkdir, access, F_OK
    9 from anuga.abstract_2d_finite_volumes.util import add_directories, \
    10      copy_code_files
     8from os.path import join
     9from anuga.shallow_water.data_manager import copy_code_files
     10from anuga.abstract_2d_finite_volumes.util import add_directories
    1111
    1212from anuga.utilities.system_tools import get_user_name
     
    3838        self.meshdir = scenariodir+sep+'meshes'+sep
    3939        self.scenariodir = scenariodir+sep
    40         self.boundarydir = self.scenariodir
     40        self.boundarydir = self.outputdir
     41        self.raw_data_dir = join(scenariodir, 'raw_data')
    4142
    4243        # creates copy of output dir structure, if it doesn't exist
  • anuga_work/development/Hinwood_2008/run_dam.py

    r5390 r5392  
    3232from anuga.fit_interpolate.interpolate import interpolate_sww2csv
    3333from anuga.abstract_2d_finite_volumes.util import start_screen_catcher, \
    34      copy_code_files, file_function
     34      file_function
     35from anuga.shallow_water.data_manager import copy_code_files
    3536from anuga.abstract_2d_finite_volumes.generic_boundary_conditions\
    3637     import File_boundary_time
     
    6162         friction=0.01,
    6263         outputdir_name=None,
    63          is_trial_run=False):
     64         run_type=0):
    6465
    6566   
    6667    basename = 'zz' + str(friction)
    67     if is_trial_run is True:
     68    if run_type == 1:
    6869        outputdir_name += '_test'
    6970        yieldstep = 0.1
    7071        finaltime = 15.
    7172        maximum_triangle_area=0.01
    72     else:
    73         yieldstep = 0.02
    74         finaltime = 15.1
    75         maximum_triangle_area=0.0001
     73    elif run_type == 2:
     74        outputdir_name += '_test_good_time'
     75        yieldstep = 0.1
     76        finaltime = 50.0
     77        maximum_triangle_area=0.01
    7678       
    7779        maximum_triangle_area=0.001
     80    elif run_type == 3:
     81        outputdir_name += '_test_good_time_mesh'
     82        yieldstep = 0.1
     83        finaltime = 50.0       
     84        maximum_triangle_area=0.001
     85    elif run_type == 4:
     86        # this is not a test
     87        # Output will go to a file
     88        # The sww file will be interpolated
     89        yieldstep = 0.1
     90        finaltime = 50.0       
     91        maximum_triangle_area=0.001
     92         
    7893       
    7994    pro_instance = project.Project(['data','flumes','Hinwood_2008'],
     
    88103          pro_instance.outputdir + 'create_mesh.py')
    89104
     105    prepare_time_boundary(slope,pro_instance.raw_data_dir,
     106                          pro_instance.boundarydir)
     107   
    90108    # Boundary file manipulation
    91109    if boundary_path is None:
    92110        boundary_path = pro_instance.boundarydir
    93111    boundary_file_path = join(boundary_path, boundary_file)
    94     # Convert the boundary file, .csv to .tsm
    95     try:
    96         temp = open(boundary_file_path)
    97         temp.close()
    98     except IOError:
    99         prepare_time_boundary(boundary_file_path)
     112   # # Convert the boundary file, .csv to .tsm
     113#     try:
     114#         temp = open(boundary_file_path)
     115#         temp.close()
     116#     except IOError:
     117#         prepare_time_boundary(boundary_file_path)
    100118   
    101119    mesh_filename = pro_instance.meshdir + basename + '.msh'
     
    107125
    108126    # creates copy of code in output dir
    109     if is_trial_run is False:
     127    if run_type >= 4:
    110128        start_screen_catcher(pro_instance.outputdir, rank, pypar.size())
    111129
     
    196214    #-------------------------------------------------------------------------
    197215
    198     if True:
     216    if run_type >= 4:
    199217        interpolate_sww2csv(pro_instance.outputdir + basename +".sww",
    200218                            points,
     
    207225def set_z_origin_to_water_depth(seabed_coords):
    208226    offset = seabed_coords['offshore_water_depth']
    209     for x in seabed_coords.keys():
    210         if not x == 'offshore_water_depth':
     227    keys = ['xleft', 'xtoe', 'xbeach', 'xright']
     228    for x in keys:
    211229            seabed_coords[x][1] -= offset
    212230    return seabed_coords
     
    218236                     'xbeach':[1.285,0.090],
    219237                     'xright':[16.1,.960],
    220                      'offshore_water_depth':.4}
     238                     'offshore_water_depth':.4,
     239                     'scenario_id':'T1R5'}
    221240    run_data_T1R5 = set_z_origin_to_water_depth(run_data_T1R5)
     241    #print "run_data_T1R5", run_data_T1R5
     242    #prepare_time_boundary(run_data_T1R5)
    222243    main( 'T1R5_boundary.tsm', 8, run_data_T1R5,
    223           is_trial_run = True,
    224          outputdir_name='Hinwood_low_stage_low_velocity_draft')
     244          run_type = 2,
     245         outputdir_name='Hinwood_T1R5_draft')
Note: See TracChangeset for help on using the changeset viewer.