Esempio n. 1
0
def run():
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )
    
    for axis_y in config.interesting_y_axes:
    
        x = data[:, tsv_get_column_index(data_file, 'config_Z')]
        y = data[:, tsv_get_column_index(data_file, axis_y['column'])]
        
        plt.figure()
        
        plt.plot(x, y)
        plt.title(axis_y['name'])
        plt.xlabel(r'Hub Location $Z$')
        plt.ylabel(axis_y['name'])
        plt.grid(True)
        #plt.show()
        
        fig_path = '%s/plot_%s.pdf' % (config.sink_dir, axis_y['column'])
        fig_path = fig_path.replace('/runs/', '/plots/')
        fig_path = fig_path.replace('/sink/', '/')
        make_sure_path_exists(os.path.dirname(fig_path))
        plt.savefig(fig_path)
Esempio n. 2
0
def run():

    data_file = "%s/latest.tsv" % config.sink_dir

    data = np.loadtxt(open(data_file, "rb"), delimiter="\t", skiprows=1)

    for axis_y in config.interesting_y_axes:

        x = data[:, tsv_get_column_index(data_file, "config_count_hubs")]
        y = data[:, tsv_get_column_index(data_file, axis_y["column"])]

        plt.figure()

        plt.plot(x, y)
        plt.xlim(min(x), max(x))
        plt.xticks(x)
        plt.ylim(0.0, 0.05)
        plt.title(axis_y["name"])
        plt.xlabel(r"Hub Count $H$")
        plt.ylabel(axis_y["name"])
        plt.grid(True)
        # plt.show()

        fig_path = "%s/plot_%s.pdf" % (config.sink_dir, axis_y["column"])
        fig_path = fig_path.replace("/runs/", "/plots/")
        fig_path = fig_path.replace("/sink/", "/")
        make_sure_path_exists(os.path.dirname(fig_path))
        plt.savefig(fig_path)
Esempio n. 3
0
def run():

    data_file = '%s/latest.tsv' % config.sink_dir

    data = np.loadtxt(open(data_file, 'rb'), delimiter="\t", skiprows=1)

    x = data[:, tsv_get_column_index(data_file, 'config_etah_slack')]
    y = data[:, tsv_get_column_index(data_file, 'formation_success_rate')]

    plt.plot(x, y)
    plt.show()
Esempio n. 4
0
def run():

    data_file = '%s/latest.tsv' % config.sink_dir

    data = np.loadtxt(open(data_file, 'rb'), delimiter="\t", skiprows=1)

    x = data[:, tsv_get_column_index(data_file, 'config_Z')]
    y = data[:, tsv_get_column_index(data_file, 'fuel_saved')]

    plt.plot(x, y)
    plt.show()
Esempio n. 5
0
def run():

    data_file = '%s/latest.tsv' % config.sink_dir

    data = np.loadtxt(open(data_file, 'rb'), delimiter="\t", skiprows=1)

    x = data[:, tsv_get_column_index(data_file, 'config_min_P')]
    y = data[:, tsv_get_column_index(data_file, 'fuel_saved')]

    plt.xlabel(r'Formation Suitability Criterium $C_{min}$')
    plt.ylabel(r'Fuel Saved $S_f$')

    plt.plot(x, y)
    plt.show()
Esempio n. 6
0
def run():
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )
    
    x = data[:, tsv_get_column_index(data_file, 'config_phi_max')]
    y = data[:, tsv_get_column_index(data_file, 'alpha_effective')]
    
    plt.plot(x, y)
    plt.show()
Esempio n. 7
0
def run():
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )
    
    x = data[:, tsv_get_column_index(data_file, 'config_etah_slack')]
    y = data[:, tsv_get_column_index(data_file, 'formation_success_rate')]
    
    plt.plot(x, y)
    plt.show()
Esempio n. 8
0
def run():
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )
    
    x = data[:, tsv_get_column_index(data_file, 'config_Z')]
    y = data[:, tsv_get_column_index(data_file, 'fuel_saved')]

    plt.plot(x, y)
    plt.show()
Esempio n. 9
0
def run():
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )
    
    x = data[:, tsv_get_column_index(data_file, 'config_min_P')]
    y = data[:, tsv_get_column_index(data_file, 'fuel_saved')]
    
    plt.xlabel(r'Formation Suitability Criterium $C_{min}$')
    plt.ylabel(r'Fuel Saved $S_f$')
    
    plt.plot(x, y)
    plt.show()
Esempio n. 10
0
def run():

    data_file = '%s/latest.tsv' % config.sink_dir

    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )

    j = 0
    for axis_y in config.axes_y:
        
        print 'Plotting %s (%d of %d)' % (
            axis_y['column'], (j+1), len(config.axes_y)
        )
        
        axis_x = config.axis_x
    
        fig = plt.figure(j)
        ax  = fig.add_subplot(111)
    
        x = data[:, tsv_get_column_index(data_file, axis_x['column'])]
        y = data[:, tsv_get_column_index(data_file, axis_y['column'])]
        
        # Note that we must convert the lock time into the lock distance L
        if axis_x['column'] == 'config_lock_time':
            raise Error('lock time needs conversion')
        
        nx = len(config.x)
        ny = len(config.y)

        x = x.reshape(nx, ny)
        y = y.reshape(nx, ny)
        
        plt.xlabel(axis_x['name'])
        plt.ylabel(axis_y['name'])
        
        i = 0
        for line in config.x:

            horizontal = x[0,:]
            vertical = y[i,:]

            plt.plot(horizontal, vertical, label = config.legend % line)
            i += 1
    
        plt.grid(True)
        t = plt.title(r'%s' % axis_y['name'])
        #t.set_y(1.03)
        #plt.subplots_adjust(top = 0.85, bottom = 0.2) 
        
        lgd = ax.legend(
            loc='upper center',
            bbox_to_anchor=(0.5,-0.15),
            ncol = 2
        )

        fig_path = '%s/plot_%s.pdf' % (config.sink_dir, axis_y['column'])
        fig_path = fig_path.replace('/runs/', '/plots/')
        fig_path = fig_path.replace('/sink/', '/')
        
        make_sure_path_exists(os.path.dirname(fig_path))
        
        locs, labels = plt.yticks()
        
        try:
            f = axis_y['yticks_formatter']
            plt.yticks(locs, f(locs, labels))
        except KeyError:
            pass
        
        #plt.show()
        #return
        
        plt.savefig(
            fig_path,
            bbox_extra_artists=(lgd,),
            bbox_inches='tight'
        )
        
        j += 1
Esempio n. 11
0
def run():

    data_file = '%s/latest.tsv' % config.sink_dir

    data = np.loadtxt(open(data_file, 'rb'), delimiter="\t", skiprows=1)

    axis_x = config.axis_x
    axis_y = config.axis_y

    i = 0
    for axis_z in config.interesting_z_axes:

        i += 1

        print 'Plotting %s (%d of %d)' % (axis_z['column'], i,
                                          len(config.interesting_z_axes))

        plt.figure()

        x = data[:, tsv_get_column_index(data_file, axis_x['column'])]
        y = data[:, tsv_get_column_index(data_file, axis_y['column'])]
        z = data[:, tsv_get_column_index(data_file, axis_z['column'])]

        # Note that we must convert the lock time into the lock distance L
        if axis_x['column'] == 'config_lock_time':
            x = 300 * x / 60
        if axis_y['column'] == 'config_lock_time':
            y = 300 * y / 60

        try:
            nx = config.output_nx
            ny = config.output_ny
        except AttributeError:
            N = len(z)
            nx = math.sqrt(N)
            ny = nx
        #
        #print 'variable: %s, nx = %d, ny = %d, count z = %d. z = %s' % (
        #    axis_z['column'],
        #    nx, ny, len(z), z
        #)

        x = x.reshape(nx, ny)
        y = y.reshape(nx, ny)
        z = z.reshape(nx, ny)

        plt.xlabel(axis_x['name'])
        plt.ylabel(axis_y['name'])

        plt.grid(True)

        try:
            cs = plt.contour(x, y, z, axis_z['levels'])
        except KeyError:
            cs = plt.contour(x, y, z, 10)

        plt.clabel(cs)

        plt.colorbar()

        #plt.title(r'%s ($n=%d$)' % (axis_z['name'], config.count_hubs))
        t = plt.title(r'%s' % axis_z['name'])
        #t.set_y(1.03)

        fig_path = '%s/plot_%s.pdf' % (config.sink_dir, axis_z['column'])
        fig_path = fig_path.replace('/runs/', '/plots/')
        fig_path = fig_path.replace('/sink/', '/')
        make_sure_path_exists(os.path.dirname(fig_path))
        print fig_path
        #plt.show()
        #return
        plt.savefig(fig_path)
Esempio n. 12
0
def do_plot(plotconf, data):
    
    plt.figure()
    
    column = plotconf['column']
    print 'Drawing plot for %s' % column
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    x = data[:, tsv_get_column_index(data_file, 'hub_lon')]
    y = data[:, tsv_get_column_index(data_file, 'hub_lat')]
    z = data[:, tsv_get_column_index(data_file, column)]
    
    minlat = np.min(y)
    maxlat = np.max(y)
    minlon = np.min(x)
    maxlon = np.max(x)
    
    m = Basemap(
        projection = 'merc', resolution = 'c',
        llcrnrlat = minlat, urcrnrlat = maxlat,
        llcrnrlon = minlon, urcrnrlon = maxlon
    )
    
    # Reverse Y-axis (high lat = low y)
    #y = y[::-1]
    
    #x, y = np.meshgrid(x, y)
    
    N = len(z)
    #print N
    nx = math.sqrt(N)
    ny = nx
    
    x = x.reshape(nx, ny)
    y = y.reshape(nx, ny)
    z = z.reshape(nx, ny)

    #print x
    #print y
    #print z
    
    m.drawcoastlines()
    m.drawstates()
    m.drawcountries()
    
    # draw lat/lon grid lines every 10 degrees.
    parallels = np.arange(-360.,360.,10.)
    meridians = np.arange(-360.,360.,20.)
    m.drawparallels(parallels,labels=[1,0,0,0])
    m.drawmeridians(meridians,labels=[0,0,0,1])

    # Midpoints were determined in runs/singlehub/trunk
    #midpoint_origins = Point(50., 8.)
    midpoint_origins = Waypoint('LUX')
    #midpoint_destinations = Point(35.,-87.)
    midpoint_destinations = Waypoint('PIT')

    lon1 = midpoint_origins.lon
    lat1 = midpoint_origins.lat
    lon2 = midpoint_destinations.lon
    lat2 = midpoint_destinations.lat
    
    # Draw the trunk route
    m.drawgreatcircle(lon1, lat1, lon2, lat2, linewidth = 3, color='#000000')
    
    x, y = m(x, y)
    cs = m.contourf(x, y, z, plotconf['levels'])

    plt.colorbar(cs, orientation = 'vertical', shrink = 0.65)
    plt.title(plotconf['title'])
    
    #plt.show()
    
    fig_path = '%s/plot_%s.pdf' % (config.sink_dir, column)
    fig_path = fig_path.replace('/runs/', '/plots/')
    fig_path = fig_path.replace('/sink/', '/')
    make_sure_path_exists(os.path.dirname(fig_path))
    plt.savefig(fig_path, bbox_inches='tight')
Esempio n. 13
0
def do_plot(plotconf, data):

    plt.figure()

    column = plotconf['column']
    print 'Drawing plot for %s' % column

    data_file = '%s/latest.tsv' % config.sink_dir

    x = data[:, tsv_get_column_index(data_file, 'hub_lon')]
    y = data[:, tsv_get_column_index(data_file, 'hub_lat')]
    z = data[:, tsv_get_column_index(data_file, column)]

    minlat = np.min(y)
    maxlat = np.max(y)
    minlon = np.min(x)
    maxlon = np.max(x)

    m = Basemap(projection='merc',
                resolution='c',
                llcrnrlat=minlat,
                urcrnrlat=maxlat,
                llcrnrlon=minlon,
                urcrnrlon=maxlon)

    # Reverse Y-axis (high lat = low y)
    #y = y[::-1]

    #x, y = np.meshgrid(x, y)

    N = len(z)
    #print N
    nx = math.sqrt(N)
    ny = nx

    x = x.reshape(nx, ny)
    y = y.reshape(nx, ny)
    z = z.reshape(nx, ny)

    #print x
    #print y
    #print z

    m.drawcoastlines()
    m.drawstates()
    m.drawcountries()

    # draw lat/lon grid lines every 10 degrees.
    parallels = np.arange(-360., 360., 10.)
    meridians = np.arange(-360., 360., 20.)
    m.drawparallels(parallels, labels=[1, 0, 0, 0])
    m.drawmeridians(meridians, labels=[0, 0, 0, 1])

    # Midpoints were determined in runs/singlehub/trunk
    #midpoint_origins = Point(50., 8.)
    midpoint_origins = Waypoint('LUX')
    #midpoint_destinations = Point(35.,-87.)
    midpoint_destinations = Waypoint('PIT')

    lon1 = midpoint_origins.lon
    lat1 = midpoint_origins.lat
    lon2 = midpoint_destinations.lon
    lat2 = midpoint_destinations.lat

    # Draw the trunk route
    m.drawgreatcircle(lon1, lat1, lon2, lat2, linewidth=3, color='#000000')

    x, y = m(x, y)
    cs = m.contourf(x, y, z, plotconf['levels'])

    plt.colorbar(cs, orientation='vertical', shrink=0.65)
    plt.title(plotconf['title'])

    #plt.show()

    fig_path = '%s/plot_%s.pdf' % (config.sink_dir, column)
    fig_path = fig_path.replace('/runs/', '/plots/')
    fig_path = fig_path.replace('/sink/', '/')
    make_sure_path_exists(os.path.dirname(fig_path))
    plt.savefig(fig_path, bbox_inches='tight')
Esempio n. 14
0
def run():
    
    data_file = '%s/latest.tsv' % config.sink_dir
    
    data = np.loadtxt(
        open(data_file, 'rb'),
        delimiter = "\t",
        skiprows = 1
    )
    
    axis_x = config.axis_x
    axis_y = config.axis_y

    i = 0
    for axis_z in config.interesting_z_axes:
        
        i += 1
        
        print 'Plotting %s (%d of %d)' % (
            axis_z['column'], i, len(config.interesting_z_axes)
        )
        
        plt.figure()
    
        x = data[:, tsv_get_column_index(data_file, axis_x['column'])]
        y = data[:, tsv_get_column_index(data_file, axis_y['column'])]
        z = data[:, tsv_get_column_index(data_file, axis_z['column'])]
        
        # Note that we must convert the lock time into the lock distance L
        if axis_x['column'] == 'config_lock_time':
            x = 300 * x / 60
        if axis_y['column'] == 'config_lock_time':
            y = 300 * y / 60

        try:
            nx = config.output_nx
            ny = config.output_ny
        except AttributeError:
            N = len(z)
            nx = math.sqrt(N)
            ny = nx
        #    
        #print 'variable: %s, nx = %d, ny = %d, count z = %d. z = %s' % (
        #    axis_z['column'],
        #    nx, ny, len(z), z
        #)

        x = x.reshape(nx, ny)
        y = y.reshape(nx, ny)
        z = z.reshape(nx, ny)
        
        plt.xlabel(axis_x['name'])
        plt.ylabel(axis_y['name'])
        
        plt.grid(True)
        
        try:
            cs = plt.contour(x, y, z, axis_z['levels'])
        except KeyError:
            cs = plt.contour(x, y, z, 10)

        plt.clabel(cs)
        
        plt.colorbar()
        
        #plt.title(r'%s ($n=%d$)' % (axis_z['name'], config.count_hubs))
        t = plt.title(r'%s' % axis_z['name'])
        #t.set_y(1.03)
        
        fig_path = '%s/plot_%s.pdf' % (config.sink_dir, axis_z['column'])
        fig_path = fig_path.replace('/runs/', '/plots/')
        fig_path = fig_path.replace('/sink/', '/')
        make_sure_path_exists(os.path.dirname(fig_path))
        print fig_path
        #plt.show()
        #return
        plt.savefig(fig_path)
Esempio n. 15
0
def run():

    data_file = '%s/latest.tsv' % config.sink_dir

    data = np.loadtxt(open(data_file, 'rb'), delimiter="\t", skiprows=1)

    j = 0
    for axis_y in config.axes_y:

        print 'Plotting %s (%d of %d)' % (axis_y['column'],
                                          (j + 1), len(config.axes_y))

        axis_x = config.axis_x

        fig = plt.figure(j)
        ax = fig.add_subplot(111)

        x = data[:, tsv_get_column_index(data_file, axis_x['column'])]
        y = data[:, tsv_get_column_index(data_file, axis_y['column'])]

        # Note that we must convert the lock time into the lock distance L
        if axis_x['column'] == 'config_lock_time':
            raise Error('lock time needs conversion')

        nx = len(config.x)
        ny = len(config.y)

        x = x.reshape(nx, ny)
        y = y.reshape(nx, ny)

        plt.xlabel(axis_x['name'])
        plt.ylabel(axis_y['name'])

        i = 0
        for line in config.x:

            horizontal = x[0, :]
            vertical = y[i, :]

            plt.plot(horizontal, vertical, label=config.legend % line)
            i += 1

        plt.grid(True)
        t = plt.title(r'%s' % axis_y['name'])
        #t.set_y(1.03)
        #plt.subplots_adjust(top = 0.85, bottom = 0.2)

        lgd = ax.legend(loc='upper center',
                        bbox_to_anchor=(0.5, -0.15),
                        ncol=2)

        fig_path = '%s/plot_%s.pdf' % (config.sink_dir, axis_y['column'])
        fig_path = fig_path.replace('/runs/', '/plots/')
        fig_path = fig_path.replace('/sink/', '/')

        make_sure_path_exists(os.path.dirname(fig_path))

        locs, labels = plt.yticks()

        try:
            f = axis_y['yticks_formatter']
            plt.yticks(locs, f(locs, labels))
        except KeyError:
            pass

        #plt.show()
        #return

        plt.savefig(fig_path, bbox_extra_artists=(lgd, ), bbox_inches='tight')

        j += 1