Changeset 5426


Ignore:
Timestamp:
Jun 25, 2008, 9:27:56 AM (14 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/plot.py

    r5413 r5426  
    55from os import sep
    66import project
     7from time import localtime, strftime
    78
    89def plot_compare_csv(location_sim, file_sim, location_exp, file_exp,
     
    8384    from scenarios import scenarios
    8485    outputdir_tag = "_good_tri_area_0.01_A"
    85     #scenarios = [scenarios[0]] # !!!!!!!!!!!!!!!!!!!!!!
     86    #scenarios = scenarios[1] # !!!!!!!!!!!!!!!!!!!!!!
     87    scenarios = [scenarios[5]] # !!!!!!!!!!!!!!!!!!!!!!
    8688    # Supported formats: emf, eps, pdf, png, ps, raw, rgba, svg, svgz.
    8789    plot_type = ".pdf"
     
    99101                                                    save_as_list,
    100102                                                    run_data['gauge_x']):
     103            time_date = strftime('plot date: %d/%m/%Y Time: %H:%M:%S',
     104                                      localtime())
    101105            plot_title = "Scenario: " + outputdir_name + "\n" + \
    102                          "X Gauge (m):" + str(gauge)
     106                         "X Gauge (m):" + str(gauge) + "    " + time_date
     107                         
    103108            print "Doing ", plot_title
    104109            plot_compare_csv(location_sim=loc_sim,
  • anuga_work/development/Hinwood_2008/run_dam.py

    r5413 r5426  
    250250   
    251251    from scenarios import scenarios
    252    
    253     run_type = 5
    254     for run_data in [scenarios[0]]:
     252
     253
     254    #4 is 0.01 5 is 0.001
     255    run_type = 4
     256    for run_data in [scenarios[5]]:
    255257        main( run_data['scenario_id'] + '_boundary.tsm'  , run_data,
    256258              run_type = run_type,
  • anuga_work/development/Hinwood_2008/slope.py

    r5413 r5426  
    66import project
    77#from scipy import arange
    8 from Numeric import arange
     8
     9from Numeric import arange, array, zeros, Float
     10from pylab import meshgrid, cm, contourf, contour, ion, plot, xlabel, \
     11     ylabel, close, legend, savefig, title, figure ,colorbar, show #, cbar
    912
    1013from anuga.fit_interpolate.interpolate import interpolate_sww2csv
     14from anuga.shallow_water.data_manager import csv2dict
    1115
     16def load_depths(slope_file):
     17    #slope, _ = csv2dict(file_sim)
     18   
     19    # Read the depth file
     20    dfid = open(slope_file)
     21    lines = dfid.readlines()
     22    dfid.close()
    1223
    13 #-------------------------------------------------------------
    14 if __name__ == "__main__":
    15     """
    16     """
     24    title = lines.pop(0)
     25    n_time = len(lines)
     26    n_sensors = len(lines[0].split(','))-1  # -1 to remove time
     27    dtimes = zeros(n_time, Float)  #Time
     28    depths = zeros(n_time, Float)  #
     29    sensors = zeros((n_time,n_sensors), Float)
     30    depth_locations = title.split(',') #(',')
     31    depth_locations.pop(0) # remove 'time'
     32    # !!!! -3 assumes a
     33    depths = [float(j.split(':')[0]) for j in depth_locations]
     34   
     35    for i, line in enumerate(lines):
     36        fields = line.split(',') #(',')
     37        fields = [float(j) for j in fields]
     38        dtimes[i] = fields[0]
     39        sensors[i] = fields[1:] # 1: to remove time
     40
     41    #print "dtimes",dtimes
     42    #print "depths", depths
     43    #print "sensors", sensors
     44    return dtimes, depths, sensors
     45   
     46def load_slopes(slope_file):
     47    times, depths, sensors = load_depths(slope_file)
     48    n_slope_locations = len(depths)-1
     49    n_time = len(times)
     50    slope_locations = zeros(n_slope_locations, Float)  #
     51    slopes = zeros((n_time,n_slope_locations), Float)
     52
     53    # An array of the sensor spacing values
     54    delta_depths = zeros(n_slope_locations, Float)
     55   
     56    for i in arange(n_slope_locations):
     57        slope_locations[i] = (depths[i+1] + depths[i+1])/2.
     58        delta_depths[i] = (depths[i+1] - depths[i])
     59   
     60    for j in arange(n_time):
     61        for i in arange(n_slope_locations):
     62            slopes[j,i] = (sensors[j,i+1] - sensors[j,i])/delta_depths[i]
     63
     64    return times, slope_locations, slopes
     65
     66def graph_slopes(slope_file):
     67    origin = 'lower'
     68    times, slope_locations, slopes = load_slopes(slope_file)
     69    X, Y = meshgrid(times, slope_locations)
     70    #print "X", times
     71    #print "Y", slope_locations
     72    #print "slopes", slopes
     73    CS = contourf(slope_locations, times, slopes, 10, # [-1, -0.1, 0, 0.1],
     74                        #alpha=0.5,
     75                        cmap=cm.bone,
     76                        origin=origin)
     77   
     78    #CS2 = contour(slope_locations, times, slopes, CS.levels[::2],
     79       #           colors = 'r',
     80        #          origin=origin,
     81         #         hold='on')
     82
     83    title('slope')
     84    xlabel('x location')
     85    ylabel('Time, seconds')
     86
     87    # Make a colorbar for the ContourSet returned by the contourf call.
     88    cbar = colorbar(CS)
     89    cbar.ax.set_ylabel('verbosity coefficient')
     90    # Add the contour line levels to the colorbar
     91    #cbar.add_lines(CS2)
     92
     93    figure()
     94    show()
     95
     96def auto_graph_slopes():
    1797    from scenarios import scenarios
    1898   
    1999    outputdir_tag = "_good_tri_area_0.01_A"
    20     scenarios = [scenarios[1]] # !!!!!!!!!!!!!!!!!!!!!!
     100    scenarios = [scenarios[1]] # !!!!!!!!!!!!!!!!!!!!!!
     101    for run_data in scenarios:
     102        id = run_data['scenario_id']
     103        outputdir_name = id + outputdir_tag
     104        pro_instance = project.Project(['data','flumes','Hinwood_2008'],
     105                                       outputdir_name=outputdir_name)
     106        end = id + ".csv"
     107        slope_file = pro_instance.outputdir + "slope_depth_" + end
     108        graph_slopes(slope_file)
     109   
     110def gauges_for_slope():
     111    from scenarios import scenarios
     112   
     113    outputdir_tag = "_good_tri_area_0.01_A"
     114    scenarios = [scenarios[1]] # !!!!!!!!!!!!!!!!!!!!!!
     115    dx = 0.001
    21116    for run_data in scenarios:
    22117        point_x = arange(run_data['start_slope_x'],
    23118                        run_data['finish_slope_x'],
    24                         0.01).tolist()
     119                        dx).tolist()
    25120        flume_y_middle = 0.5
    26121        points = []
     
    36131        interpolate_sww2csv(pro_instance.outputdir + basename +".sww",
    37132                            points,
    38                             pro_instance.outputdir + "depth_" + end,
    39                             pro_instance.outputdir + "velocity_x_" + end,
    40                             pro_instance.outputdir + "velocity_y_" + end)
     133                            pro_instance.outputdir + "slope_depth_" + end,
     134                            pro_instance.outputdir + "slope_velocity_x_" + end,
     135                            pro_instance.outputdir + "slope_velocity_y_" + end)
    41136 
    42        
     137   
     138   
    43139
     140#-------------------------------------------------------------
     141if __name__ == "__main__":
     142    """
     143    """
     144    auto_graph_slopes()
     145
Note: See TracChangeset for help on using the changeset viewer.