Ignore:
Timestamp:
Jul 1, 2008, 3:48:00 PM (16 years ago)
Author:
duncan
Message:

Current Hinwood scenario - cropping the flume length

Location:
anuga_work/development/Hinwood_2008
Files:
4 edited

Legend:

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

    r5449 r5455  
    1818    """
    1919    from pylab import ion, plot, xlabel, ylabel, close, legend, \
    20          savefig, title
     20         savefig, title, axis
    2121    from anuga.shallow_water.data_manager import csv2dict
    2222
     
    4444    legend((legend_sim, legend_exp),'upper left')
    4545    title(plot_title)
     46    #axis([0,60,0.380,0.420])
    4647   
    4748    if is_interactive:
     
    5556    close()
    5657   
    57 def Hinwood_files_locations(run_data, outputdir_tag, plot_type):
    58    
     58def Hinwood_files_locations(run_data, outputdir_tag, plot_type,
     59                            quantity = "depth"):
     60    """
     61    run_data is a dictionary of data describing a Hinwood experiment
     62    outputdir_tag a string at the end of an output dir; '_good_tri_area_0.01_A'
     63    plot_type the file extension of the plot, eg '.pdf'
     64    """
    5965    id = run_data['scenario_id']
    6066    outputdir_name = id + outputdir_tag
     
    6268                                   outputdir_name=outputdir_name)
    6369   
    64     file_sim = pro_instance.outputdir + "depth_" + id + ".csv"
     70    file_sim = pro_instance.outputdir + quantity + "_" + id + ".csv"
    6571    #print "file_exp",file_exp
    66     file_exp = pro_instance.raw_data_dir + sep + id + 'pressfilt_exp_depth.csv'
     72    file_exp = pro_instance.raw_data_dir + sep + id + 'pressfilt_exp_' \
     73               + quantity + '.csv'
    6774    #print "file_sim", file_sim
    6875    location_sims = []
     
    7481        location_exps.append(gauge_x)
    7582        save_as_list.append(pro_instance.plots_dir + sep + \
    76                             outputdir_name + "_" + gauge_x + plot_type)
     83                            outputdir_name + "_" + quantity + "_" + \
     84                            gauge_x + plot_type)
    7785    return file_exp, file_sim, location_sims, location_exps, outputdir_name, \
    7886           save_as_list
    79 def plot():
    80     from scenarios import scenarios
    81     outputdir_tag = "_good_tri_area_0.01_A"
    82     outputdir_tag = "_test"
    83     #scenarios = scenarios[1] # !!!!!!!!!!!!!!!!!!!!!!
    84     #scenarios = [scenarios[5]] # !!!!!!!!!!!!!!!!!!!!!!
    85     # Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
     87def plot(scenarios, outputdir_tag, quantity = "stage"):
    8688    plot_type = ".pdf"
     89   
    8790    for run_data in scenarios:
    8891       
    89         temp = Hinwood_files_locations(run_data, outputdir_tag, plot_type)
     92        temp = Hinwood_files_locations(run_data, outputdir_tag,
     93                                       plot_type, quantity)
     94                                   
    9095        file_exp, file_sim, location_sims, location_exps, outputdir_name, \
    9196                  save_as_list = temp
     
    109114                             file_exp=file_exp,
    110115                             plot_title=plot_title,
    111                              y_label='Water height (m)',
     116                             y_label='Water '+ quantity +' (m)',
    112117                             is_interactive=False,
    113118                             save_as=save_as)
     
    118123    """
    119124    from scenarios import scenarios
    120     outputdir_tag = "_good_tri_area_0.01_A"
    121     #scenarios = scenarios[1] # !!!!!!!!!!!!!!!!!!!!!!
    122     scenarios = [scenarios[5]] # !!!!!!!!!!!!!!!!!!!!!!
    123     # Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
    124     plot_type = ".pdf"
    125     for run_data in scenarios:
    126        
    127         temp = Hinwood_files_locations(run_data, outputdir_tag, plot_type)
    128         file_exp, file_sim, location_sims, location_exps, outputdir_name, \
    129                   save_as_list = temp
    130         print "run_data['scenario_id']", run_data['scenario_id']
    131         #location_sims = [location_sims[0]]
    132         #location_exps = [location_exps[0]]
    133         #save_as_list = [save_as_list[0]]
    134         for loc_sim, loc_exp, save_as, gauge in map(None, location_sims,
    135                                                     location_exps,
    136                                                     save_as_list,
    137                                                     run_data['gauge_x']):
    138             time_date = strftime('plot date: %d/%m/%Y Time: %H:%M:%S',
    139                                       localtime())
    140             plot_title = "Scenario: " + outputdir_name + "\n" + \
    141                          "X Gauge (m):" + str(gauge) + "    " + time_date
    142                          
    143             print "Doing ", plot_title
    144             plot_compare_csv(location_sim=loc_sim,
    145                              file_sim=file_sim,
    146                              location_exp=loc_exp,
    147                              file_exp=file_exp,
    148                              plot_title=plot_title,
    149                              y_label='Water height (m)',
    150                              is_interactive=False,
    151                              save_as=save_as)
     125    outputdir_tag = "_test_C"
     126    #scenarios = scenarios[1]
     127    #scenarios = [scenarios[5]]
     128    plot(scenarios, outputdir_tag)
    152129
  • anuga_work/development/Hinwood_2008/prepare_time_boundary.py

    r5395 r5455  
    11"""
    2 
    32Script for running a breaking wave simulation of Jon Hinwoods wave tank.
    43Note: this is based on the frinction_ua_flume_2006 structure.
     
    65
    76Duncan Gray, GA - 2007
    8 
    9 
    107
    118"""
     
    203200    #print "start_time", start_time
    204201
     202   
     203    bed_elevation_list = metadata_dic['gauge_bed_elevation']
     204    # +2 due to Time column and gauge A
     205    max_j = len(bed_elevation_list)+2
    205206    # Write a header
    206207    fid.write('Time')
     
    212213        # Don't write sensor A.
    213214        # It is the boundary condition.
    214         for j, bed_elevation in map(None,xrange(2,len(sensors[0])),
    215                                        metadata_dic['gauge_bed_elevation']):
     215        for j, bed_elevation in map(None,
     216                                    xrange(2,max_j),
     217                                    bed_elevation_list):
    216218            # depth, m
    217219            gauge = sensors[i,j]/1000 - bed_elevation # Convert from mm to m
     
    219221        fid.write('\n')
    220222    fid.close()
     223
     224   
     225    # Since there is a new time reference save the stage info using this
     226    # new reference.
     227    fid = open(depth_file[:-4] + '_exp_stage.csv','w')
     228    sensors[:,0] -= start_time
     229   
     230    # Write a header
     231    fid.write('Time')
     232    for gauge_x in metadata_dic['gauge_x']:
     233        fid.write(',' + str(gauge_x))
     234    fid.write('\n')
     235    for i in xrange(len(dtimes)):       
     236        fid.write(str(sensors[i,0])) # Time
     237        # Don't write sensor A.
     238        # It is the boundary condition.
     239        for j in xrange(2,max_j):
     240            # stage, m
     241            gauge = sensors[i,j]/1000 # Convert from mm to m
     242            fid.write(',' + str(gauge))
     243        fid.write('\n')
     244    fid.close()
     245   
    221246    return final_time
    222247
  • anuga_work/development/Hinwood_2008/run_dam.py

    r5449 r5455  
    6666    basename = 'zz_' + metadata_dic['scenario_id']
    6767    if run_type == 1:
    68         outputdir_name += '_test'
     68        outputdir_name += '_test_C'
    6969        yieldstep = 1.0
    7070        finaltime = 15.
     
    8383        maximum_triangle_area=0.001
    8484    elif run_type == 4:
    85         outputdir_name += '_good_tri_area_0.01_A'
     85        outputdir_name += '_good_tri_area_0.01_C'
    8686        # this is not a test
    8787        # Output will go to a file
     
    9191        maximum_triangle_area=0.01
    9292    elif run_type == 5:
    93         outputdir_name += '_good_tri_area_0.001_A'
     93        outputdir_name += '_good_tri_area_0.001_C'
    9494        # this is not a test
    9595        # Output will go to a file
     
    9898        finaltime = None       
    9999        maximum_triangle_area=0.001
    100     elif run_type == 6:
    101         outputdir_name += '_good_tri_area_0.0001_A'
    102         # this is not a test
    103         # Output will go to a file
    104         # The sww file will be interpolated
    105         yieldstep = 0.01
    106         finaltime = None       
    107         maximum_triangle_area=0.0001
    108100     
    109101    metadata_dic = set_z_origin_to_water_depth(metadata_dic)   
     
    231223
    232224    if run_type >= 1:
    233         id = metadata_dic['scenario_id']
     225        id = metadata_dic['scenario_id'] + ".csv"
    234226        interpolate_sww2csv(pro_instance.outputdir + basename +".sww",
    235227                            points,
    236                             pro_instance.outputdir + "depth_" + id + ".csv",
    237                             pro_instance.outputdir + "velocity_x_" + id + ".csv",
    238                             pro_instance.outputdir + "velocity_y_" + id + ".csv")
     228                            pro_instance.outputdir + "depth_" + id,
     229                            pro_instance.outputdir + "velocity_x_" + id,
     230                            pro_instance.outputdir + "velocity_y_" + id,
     231                            pro_instance.outputdir + "stage_" + id)
    239232 
    240233    return pro_instance
     
    254247
    255248
    256     #4 is 0.01 5 is 0.001
    257     run_type = 5
     249    # 4 is 0.01
     250    # 5 is 0.001
     251    run_type = 1
    258252    #for run_data in [scenarios[5]]:
    259253    for run_data in scenarios:
    260         main( run_data['scenario_id'] + '_boundary.tsm'  , run_data,
    261               run_type = run_type,
    262               outputdir_name=run_data['scenario_id'])
    263     gauges_for_slope()
    264     #plot()
     254        pro_instance = main( run_data['scenario_id'] + '_boundary.tsm'  ,
     255                             run_data,
     256                             run_type = run_type,
     257                             outputdir_name=run_data['scenario_id'])
     258        gauges_for_slope(pro_instance.outputdir,[run_data])
  • anuga_work/development/Hinwood_2008/slope.py

    r5449 r5455  
    8585    xlabel('x location')
    8686    ylabel('Time, seconds')
    87     axis([5.0, 5.5, 30, 60])
     87    #axis([5.0, 5.5, 30, 60])
    8888
    8989
     
    104104   
    105105    outputdir_tag = "_good_tri_area_0.01_A"
    106     outputdir_tag = "_test"
     106    outputdir_tag = "_good_tri_area_0.01_old"
     107    #outputdir_tag = "_test"
    107108    scenarios = [scenarios[1]] # !!!!!!!!!!!!!!!!!!!!!!
    108109    for run_data in scenarios:
     
    112113                                       outputdir_name=outputdir_name)
    113114        end = id + ".csv"
    114         slope_file = pro_instance.outputdir + "d3slope_stage_" + end
     115        slope_file = pro_instance.outputdir + "bslope_stage_" + end
    115116        graph_slopes(slope_file, run_data['break_xs'],
    116117                     run_data['break_times'])
    117118   
    118 def gauges_for_slope():
    119     from scenarios import scenarios
     119def gauges_for_slope(outputdir_tag, scenarios):
    120120   
    121121    outputdir_tag = "_good_tri_area_0.01_A"
    122     outputdir_tag = "_test"
    123     #scenarios = [scenarios[1]] # !!!!!!!!!!!!!!!!!!!!!!
    124     dx = 0.005
     122    #outputdir_tag = "_test"
     123    #scenarios = [scenarios[0]] # !!!!!!!!!!!!!!!!!!!!!!
     124    dx = 0.05
    125125    for run_data in scenarios:
    126126        point_x = arange(run_data['start_slope_x'],
     
    140140        interpolate_sww2csv(pro_instance.outputdir + basename +".sww",
    141141                            points,
    142                             pro_instance.outputdir + "eslope_depth_" + end,
    143                             pro_instance.outputdir + "eslope_velocity_x_" + end,
    144                             pro_instance.outputdir + "eslope_velocity_y_" + end,
    145                             pro_instance.outputdir + "eslope_stage_" + end,
     142                            pro_instance.outputdir + "fslope_depth_" + end,
     143                            pro_instance.outputdir + "fslope_velocity_x_" + end,
     144                            pro_instance.outputdir + "fslope_velocity_y_" + end,
     145                            pro_instance.outputdir + "fslope_stage_" + end,
    146146                            time_thinning=1)
    147147 
     
    153153    """
    154154    """
    155     #gauges_for_slope()
    156     auto_graph_slopes()
     155    from scenarios import scenarios
     156    scenarios = [scenarios[0]]
     157    #gauges_for_slope("_good_tri_area_0.01_A", scenarios)
     158    #auto_graph_slopes()
    157159
Note: See TracChangeset for help on using the changeset viewer.