Beispiel #1
0
def plot_opening(csv_data):
    keys = ['distance', 'type', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    dists = np.array([float(f) for f in llists[0]])/100.
    types = llists[1]

    types_arr = np.array(types)
    drawer_dists = dists[np.where(types_arr == 'R')[0]]
    other_dists = dists[np.where(types_arr != 'R')[0]]

    print 'Opening distances types', set(types)
    bin_width = 0.02
    bins = np.arange(-bin_width/2., np.max(dists)+2*bin_width, bin_width)
    dists_list = [dists]#, drawer_dists, other_dists]
    titles = ['Opening Distances of Drawers']#, 'drawer', 'other']

#    print 'Total number of drawers:', len(dists)
    mpu.set_figure_size(5.,4.)
    for idx, d in enumerate(dists_list):
        f = pb.figure()
        f.set_facecolor('w')
        hist, bin_edges = np.histogram(d, bins)
        #import pdb; pdb.set_trace()
        mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                           width=0.8*bin_width, xlabel='Opening Distance (meters)',
                           ylabel='\# of Mechanisms',
                           plot_title=titles[idx], color='#3366FF')
Beispiel #2
0
def handle_height_histogram_advait(mean_height_list,
                                   plot_title='',
                                   color='#3366FF',
                                   max_height=2.2,
                                   bin_width=.1,
                                   ymax=35,
                                   new_figure=True,
                                   label='__no_legend__'):
    if new_figure:
        mpu.set_figure_size(5., 4.)


#        f = mpu.figure()
#        f.subplots_adjust(bottom=.25, top=.99, right=0.99, left=0.12)
    bins = np.arange(0. - bin_width / 2., max_height + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(np.array(mean_height_list), bins)
    h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=bin_width * 0.8,
                           plot_title=plot_title,
                           xlabel='Height (meters)',
                           ylabel='\# of mechanisms',
                           color=color,
                           label=label)
    pb.xlim(0, max_height)
    pb.ylim(0, ymax)
    return h
Beispiel #3
0
def plot_opening(csv_data):
    keys = ['distance', 'type', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    dists = np.array([float(f) for f in llists[0]]) / 100.
    types = llists[1]

    types_arr = np.array(types)
    drawer_dists = dists[np.where(types_arr == 'R')[0]]
    other_dists = dists[np.where(types_arr != 'R')[0]]

    print 'Opening distances types', set(types)
    bin_width = 0.02
    bins = np.arange(-bin_width / 2., np.max(dists) + 2 * bin_width, bin_width)
    dists_list = [dists]  #, drawer_dists, other_dists]
    titles = ['Opening Distances of Drawers']  #, 'drawer', 'other']

    #    print 'Total number of drawers:', len(dists)
    mpu.set_figure_size(5., 4.)
    for idx, d in enumerate(dists_list):
        f = pb.figure()
        f.set_facecolor('w')
        hist, bin_edges = np.histogram(d, bins)
        #import pdb; pdb.set_trace()
        mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=0.8 * bin_width,
                           xlabel='Opening Distance (meters)',
                           ylabel='\# of Mechanisms',
                           plot_title=titles[idx],
                           color='#3366FF')
Beispiel #4
0
def handle_height_histogram_advait(mean_height_list, plot_title='',
                                   color='#3366FF', max_height=2.2, bin_width=.1, ymax=35,
                                   new_figure = True, label = '__no_legend__'):
    if new_figure:
        mpu.set_figure_size(5.,4.)
#        f = mpu.figure()
#        f.subplots_adjust(bottom=.25, top=.99, right=0.99, left=0.12)
    bins = np.arange(0.-bin_width/2., max_height+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(np.array(mean_height_list), bins)
    h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                           width=bin_width*0.8, plot_title=plot_title,
                           xlabel='Height (meters)', ylabel='\# of mechanisms', color=color, label = label)
    pb.xlim(0, max_height)
    pb.ylim(0, ymax)
    return h
Beispiel #5
0
        print 'rad, cx, cy:', rad, cx, cy
        c_ts = np.matrix([cx, cy, 0.]).T
        start_angle = tr.angle_within_mod180(
            math.atan2(pts_2d[1, 0] - cy, pts_2d[0, 0] - cx) - math.pi / 2)
        end_angle = tr.angle_within_mod180(
            math.atan2(pts_2d[1, -1] - cy, pts_2d[0, -1] - cx) - math.pi / 2)
        mpu.plot_circle(cx,
                        cy,
                        rad,
                        start_angle,
                        end_angle,
                        label='Actual\_opt',
                        color='r')

    if opt.icra_presentation_plot:
        mpu.set_figure_size(30, 20)
        rad = 1.0
        x_guess = pts_2d[0, 0]
        y_guess = pts_2d[1, 0] - rad

        rad_guess = rad
        rad, cx, cy = fit_circle(rad_guess,
                                 x_guess,
                                 y_guess,
                                 pts_2d,
                                 method='fmin_bfgs',
                                 verbose=False)
        print 'Estimated rad, cx, cy:', rad, cx, cy

        start_angle = tr.angle_within_mod180(
            math.atan2(pts_2d[1, 0] - cy, pts_2d[0, 0] - cx) - math.pi / 2)
Beispiel #6
0
def plot_radii(csv_data, color='#3366FF'):
    keys = ['radius', 'type', 'name', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    rad_list = np.array([float(r) for r in llists[0]]) / 100.0
    types = llists[1]
    names = np.array(llists[2])
    all_types = set(types)
    print 'Radii types', all_types

    types_arr = np.array(types)
    # np.where(types_arr == 'C')
    cabinet_rad_list = rad_list[np.where(types_arr == 'C')[0]]
    others_rad_list = rad_list[np.where(types_arr != 'C')[0]]
    other_names = names[np.where(types_arr != 'C')[0]]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
    print 'radii other names'
    for i, n in enumerate(other_names):
        print n, others_rad_list[i]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'

    rad_lists = [rad_list, cabinet_rad_list, others_rad_list]
    titles = ['Radii of Rotary Mechanisms', 'Radii of Cabinets', 'Radii of Other Mechanisms']
    bin_width = 0.05
    max_radius = np.max(rad_list)
    print 'MIN RADIUS', np.min(rad_list)
    print 'MAX RADIUS', max_radius

    mpu.set_figure_size(5.,5.)
    for idx, radii in enumerate(rad_lists):
        f = pb.figure()
        f.set_facecolor('w')
        bins = np.arange(0.-bin_width/2., max_radius+2*bin_width, bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                           width=0.8*bin_width, xlabel='Radius (meters)',
                           ylabel='\# of mechanisms',
                           plot_title=titles[idx],
                           color=color, label='All')
        pb.xlim(.1, 1.)
        pb.ylim(0, 55)
        mpu.legend(display_mode = 'less_space', handlelength=1.)

    #-- different classes in different colors in the same histogram.
    f = pb.figure()
    f.set_facecolor('w')
    bins = np.arange(0.-bin_width/2., max_radius+2*bin_width, bin_width)
    hist, bin_edges = np.histogram(rad_lists[0], bins)
    h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=0.8*bin_width, xlabel='Radius (meters)',
                       ylabel='\# of mechanisms',
                       plot_title=titles[1],
                       color='g', label='Cabinets')
    hist, bin_edges = np.histogram(rad_lists[2], bins)
    h = mpu.plot_histogram(bin_edges[:-1]+bin_width/2., hist,
                       width=0.8*bin_width, xlabel='Radius (meters)',
                       ylabel='\# of mechanisms',
                       plot_title='Cabinets and Other Mechanisms',
                       color='y', label='Other')
    pb.xlim(.1, 1.)
    pb.ylim(0, 55)
    mpu.legend(display_mode = 'less_space', handlelength=1.)

    color_list = ['g', 'b', 'r']
    marker_list = ['s', '^', 'v']
    label_list = ['All', 'Cabinets', 'Other']
    scatter_size_list = [8, 5, 5]
    mpu.set_figure_size(5.,5.)
    mpu.figure()
    for idx, radii in enumerate(rad_lists):
        bins = np.arange(0.-bin_width/2., max_radius+2*bin_width, bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        bin_midpoints = np.arange(0., max_radius+bin_width, bin_width)
        mpu.plot_yx(hist, bin_midpoints, color = color_list[idx],
                    alpha = 0.6, marker = marker_list[idx],
                    scatter_size = scatter_size_list[idx], xlabel='Radius (meters)',
                    ylabel='\# of mechanisms', label = label_list[idx])
    mpu.legend(display_mode = 'less_space')
Beispiel #7
0
def plot_radii(csv_data, color='#3366FF'):
    keys = ['radius', 'type', 'name', 'repetition']
    llists = expand(extract_keys(csv_data, keys), keys)
    rad_list = np.array([float(r) for r in llists[0]]) / 100.0
    types = llists[1]
    names = np.array(llists[2])
    all_types = set(types)
    print 'Radii types', all_types

    types_arr = np.array(types)
    # np.where(types_arr == 'C')
    cabinet_rad_list = rad_list[np.where(types_arr == 'C')[0]]
    others_rad_list = rad_list[np.where(types_arr != 'C')[0]]
    other_names = names[np.where(types_arr != 'C')[0]]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'
    print 'radii other names'
    for i, n in enumerate(other_names):
        print n, others_rad_list[i]
    print '>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>'

    rad_lists = [rad_list, cabinet_rad_list, others_rad_list]
    titles = [
        'Radii of Rotary Mechanisms', 'Radii of Cabinets',
        'Radii of Other Mechanisms'
    ]
    bin_width = 0.05
    max_radius = np.max(rad_list)
    print 'MIN RADIUS', np.min(rad_list)
    print 'MAX RADIUS', max_radius

    mpu.set_figure_size(5., 5.)
    for idx, radii in enumerate(rad_lists):
        f = pb.figure()
        f.set_facecolor('w')
        bins = np.arange(0. - bin_width / 2., max_radius + 2 * bin_width,
                         bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                               hist,
                               width=0.8 * bin_width,
                               xlabel='Radius (meters)',
                               ylabel='\# of mechanisms',
                               plot_title=titles[idx],
                               color=color,
                               label='All')
        pb.xlim(.1, 1.)
        pb.ylim(0, 55)
        mpu.legend(display_mode='less_space', handlelength=1.)

    #-- different classes in different colors in the same histogram.
    f = pb.figure()
    f.set_facecolor('w')
    bins = np.arange(0. - bin_width / 2., max_radius + 2 * bin_width,
                     bin_width)
    hist, bin_edges = np.histogram(rad_lists[0], bins)
    h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=0.8 * bin_width,
                           xlabel='Radius (meters)',
                           ylabel='\# of mechanisms',
                           plot_title=titles[1],
                           color='g',
                           label='Cabinets')
    hist, bin_edges = np.histogram(rad_lists[2], bins)
    h = mpu.plot_histogram(bin_edges[:-1] + bin_width / 2.,
                           hist,
                           width=0.8 * bin_width,
                           xlabel='Radius (meters)',
                           ylabel='\# of mechanisms',
                           plot_title='Cabinets and Other Mechanisms',
                           color='y',
                           label='Other')
    pb.xlim(.1, 1.)
    pb.ylim(0, 55)
    mpu.legend(display_mode='less_space', handlelength=1.)

    color_list = ['g', 'b', 'r']
    marker_list = ['s', '^', 'v']
    label_list = ['All', 'Cabinets', 'Other']
    scatter_size_list = [8, 5, 5]
    mpu.set_figure_size(5., 5.)
    mpu.figure()
    for idx, radii in enumerate(rad_lists):
        bins = np.arange(0. - bin_width / 2., max_radius + 2 * bin_width,
                         bin_width)
        hist, bin_edges = np.histogram(radii, bins)
        bin_midpoints = np.arange(0., max_radius + bin_width, bin_width)
        mpu.plot_yx(hist,
                    bin_midpoints,
                    color=color_list[idx],
                    alpha=0.6,
                    marker=marker_list[idx],
                    scatter_size=scatter_size_list[idx],
                    xlabel='Radius (meters)',
                    ylabel='\# of mechanisms',
                    label=label_list[idx])
    mpu.legend(display_mode='less_space')
Beispiel #8
0
        rad_guess = rad
        rad, cx, cy = fit_circle(rad_guess,x_guess,y_guess,pts_2d,
                                 method='fmin_bfgs',verbose=False)
        print 'rad, cx, cy:', rad, cx, cy
        c_ts = np.matrix([cx, cy, 0.]).T
        start_angle = tr.angle_within_mod180(math.atan2(pts_2d[1,0]-cy,
                               pts_2d[0,0]-cx) - math.pi/2)
        end_angle = tr.angle_within_mod180(math.atan2(pts_2d[1,-1]-cy,
                               pts_2d[0,-1]-cx) - math.pi/2)
        mpu.plot_circle(cx, cy, rad, start_angle, end_angle,
                        label='Actual\_opt', color='r')


    if opt.icra_presentation_plot:
        mpu.set_figure_size(30,20)
        rad = 1.0
        x_guess = pts_2d[0,0]
        y_guess = pts_2d[1,0] - rad

        rad_guess = rad
        rad, cx, cy = fit_circle(rad_guess,x_guess,y_guess,pts_2d,
                                 method='fmin_bfgs',verbose=False)
        print 'Estimated rad, cx, cy:', rad, cx, cy

        start_angle = tr.angle_within_mod180(math.atan2(pts_2d[1,0]-cy,
                               pts_2d[0,0]-cx) - math.pi/2)
        end_angle = tr.angle_within_mod180(math.atan2(pts_2d[1,-1]-cy,
                               pts_2d[0,-1]-cx) - math.pi/2)

        subsample_ratio = 1