Ignore:
Timestamp:
Jul 2, 2008, 4:34:48 PM (15 years ago)
Author:
duncan
Message:

Current Hinwood scenario

File:
1 edited

Legend:

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

    r5455 r5459  
    1515from Scientific.IO.NetCDF import NetCDFFile
    1616from Numeric import array, zeros, Float
     17from os.path import join
    1718 
    1819from anuga.utilities.numerical_tools import ensure_numeric
     
    2021from interp import interp
    2122
    22 from os.path import join
     23
     24import project
    2325
    2426# from os import getenv
     
    115117   
    116118    # Read velocity file
     119    #print "*********************"
     120    #print "velocity_file", velocity_file
    117121    vfid = open(velocity_file)
    118122    lines = vfid.readlines()
     
    133137
    134138    # Read the depth file
     139    #print "depth_file", depth_file
    135140    dfid = open(depth_file)
    136141    lines = dfid.readlines()
     
    159164    #print "len(dtimes)", len(vtimes)
    160165    #print "len(depths_at_vtimes)", len(depths_at_vtimes)
    161 #     for i in range(len(depths_at_vtimes)):
     166    #print "metadata_dic['scenario_id']", metadata_dic['scenario_id']
     167 #    for i in range(len(depths_at_vtimes)):
    162168#         print "i", i
    163169#         print "vtimes[i]", vtimes[i]
    164170#         print "depths_at_vtimes[i]", depths_at_vtimes[i]
    165 #     print "depths_at_vtimes",  depths_at_vtimes
     171
     172    #print "depths_at_vtimes",  depths_at_vtimes
    166173    depths_at_vtimes = depths_at_vtimes/1000.00 # convert from mm to m
    167174    missing=missing/1000.00 # Do to missing what is done to depths_at_vtimes
     
    192199
    193200    fid.close()
     201    print "The start time for is", start_time
     202    if not start_time == metadata_dic['ANUGA_start_time']:
     203        raise ValueError, "The calc'ed and recorded start times are different"
     204    # Modify the sensor array to reflect the new start time
     205    sensors[:,0] -= start_time
    194206   
    195207    # Since there is a new time reference save the depth info using this
    196208    # new reference.
    197209    fid = open(depth_file[:-4] + '_exp_depth.csv','w')
    198     sensors[:,0] -= start_time
    199210    #print "depth_file", depth_file
    200211    #print "start_time", start_time
     
    226237    # new reference.
    227238    fid = open(depth_file[:-4] + '_exp_stage.csv','w')
    228     sensors[:,0] -= start_time
    229239   
    230240    # Write a header
     
    248258def prepare_time_boundary(metadata_dic, raw_data_dir, output_dir):
    249259    """
     260    Use this if a project instance has already been created.
    250261    """
    251262    scenario_id = metadata_dic['scenario_id']
     
    256267   
    257268    final_time = combine_velocity_depth(velocity_file, depth_file, out_file,
    258                                         metadata_dic) 
     269                                        metadata_dic)
     270    #print "metadata_dic['xleft'][1]", metadata_dic['xleft'][1]
    259271    if metadata_dic['xleft'][1] >= 0.0:
    260272        # This should be a -ve value, since the still water level is the
     
    264276    csv2tms(tsm_file, metadata_dic['xleft'][1])
    265277    return final_time
     278
     279# Don't do this, since run-dam changes the  metadata_dic['xleft'][1],
     280# which is used by this function
     281def prepare_time_boundary_for_scenarios_warning(scenarios,
     282                                        outputdir_tag):
     283
     284    for run_data in scenarios:       
     285        id = run_data['scenario_id']
     286        outputdir_name = id + outputdir_tag
     287        pro_instance = project.Project(['data','flumes','Hinwood_2008'],
     288                                       outputdir_name=outputdir_name)
     289        prepare_time_boundary(run_data,
     290                              pro_instance.raw_data_dir,
     291                              pro_instance.boundarydir)
     292       
    266293   
    267294#-------------------------------------------------------------------
    268295if __name__ == "__main__":
    269     pass
     296   
     297    import sys; sys.exit()
     298   
     299    from scenarios import scenarios
     300    outputdir_tag = "XXXX"
     301    prepare_time_boundary_for_scenarios(scenarios,
     302                                        outputdir_tag)
Note: See TracChangeset for help on using the changeset viewer.