示例#1
0
def do_work(file,mintime,wayness,lariat_dict):
  retval=(None,None,None,None,None)
  res=plot.get_data(file,mintime,wayness,lariat_dict)
  
  if (res is None):
    return retval

  (ts, ld, tmid,
   read_rate, write_rate, stall_rate, clock_rate, avx_rate, sse_rate, inst_rate,
   meta_rate, l1_rate, l2_rate, l3_rate, load_rate, read_frac, stall_frac) = res

  #  return (scipy.stats.tmean(stall_frac),
  #          scipy.stats.tmean((load_rate - (l1_rate + l2_rate +
  #          l3_rate))/load_rate))

  mean_mem_rate=scipy.stats.tmean(read_rate+write_rate)*64.0
  ename=ld.exc.split('/')[-1]
  ename=tspl_utils.string_shorten(ld.comp_name(ename,ld.equiv_patterns),8)
  if ename=='unknown':
    return retval
  flag=False
  if mean_mem_rate < 75.*1000000000./16.:
    flag=True

  return (scipy.stats.tmean(stall_frac),
          scipy.stats.tmean((load_rate - (l1_rate))/load_rate),
          scipy.stats.tmean(clock_rate/inst_rate),ename,
          flag)
def do_work(file, mintime, wayness, lariat_dict):
    bad_retval = (None, None, None, None, None, None, None)
    res = plot.get_data(file, mintime, wayness, lariat_dict)

    if (res is None):
        return bad_retval

    (ts, ld, tmid, read_rate, write_rate, stall_rate, clock_rate, avx_rate,
     sse_rate, inst_rate, meta_rate, l1_rate, l2_rate, l3_rate, load_rate,
     read_frac, stall_frac) = res

    mean_mem_rate = scipy.stats.tmean(read_rate + write_rate) * 64.0
    ename = ld.exc.split('/')[-1]

    if ename == 'unknown':
        return bad_retval

    ename = ld.comp_name(ename, ld.equiv_patterns)

    (s, m, cpi) = (scipy.stats.tmean(stall_frac),
                   scipy.stats.tmean((load_rate - (l1_rate)) / load_rate),
                   scipy.stats.tmean(clock_rate / inst_rate))

    return (s, m, cpi, ename, ts.j.id, ts.owner, ts.su)
def do_work(file,mintime,wayness,lariat_dict):
  bad_retval=(None,None,None,None,None,None,None)
  res=plot.get_data(file,mintime,wayness,lariat_dict)
  
  if (res is None):
    return bad_retval

  (ts, ld, tmid,
   read_rate, write_rate, stall_rate, clock_rate, avx_rate, sse_rate, inst_rate,
   meta_rate, l1_rate, l2_rate, l3_rate, load_rate, read_frac, stall_frac) = res

  mean_mem_rate=scipy.stats.tmean(read_rate+write_rate)*64.0
  ename=ld.exc.split('/')[-1]

  if ename=='unknown':
    return bad_retval

  ename=ld.comp_name(ename,ld.equiv_patterns)

  (s, m, cpi) = (scipy.stats.tmean(stall_frac),
                 scipy.stats.tmean((load_rate - (l1_rate))/load_rate),
                 scipy.stats.tmean(clock_rate/inst_rate))

  return (s,m,cpi,ename,ts.j.id,ts.owner,ts.su)
示例#4
0
def index():
    response = make_response(get_data().to_csv(), 200)
    response.mimetype = "text/plain"
    return response
示例#5
0
    matplotlib.use('Agg')
    plt.figure(figsize=(17.5, 4.25), frameon=False)

    CI_level = 0.6
    dir_List = [
        ('paper/lbdqn/alien-rews', 5000000),
        ('paper/lbdqn/stargunner-rews', 20000000),
        ('paper/lbdqn/zaxxon-rews', 15000000),
    ]
    lines = []

    for fig_id, dir_entry in enumerate(dir_List):
        dir_id, length = dir_entry
        title, final_flag = None, False
        length //= 50000
        data, data_path = get_data(dir_id, final_flag, args.smooth)

        for task in data.keys():
            plt.style.use('seaborn-whitegrid')
            plt.rc('font', family='Times New Roman')
            plt.subplot(1, 3, fig_id + 1)
            # matplotlib.rcParams['text.usetex'] = True
            ax = plt.gca()
            ax.spines['right'].set_visible(False)
            ax.spines['top'].set_visible(False)
            ax.spines['left'].set_color('black')
            ax.spines['bottom'].set_color('black')
            if not (title is None):
                plt.title(title, size=24.0)
            else:
                plt.title(task, size=24.0)
示例#6
0
def exp4_plot():
    datadir = Path("data", "exp4")
    zlearner = plot.get_data(Path(datadir, "data00"))
    qlearner = plot.get_data(Path(datadir, "data01"))
    zlearner_na = plot.get_data(Path(datadir, "data02"))
    qlearner_na = plot.get_data(Path(datadir, "data03"))
    data = [zlearner, qlearner]
    data_na = [zlearner_na, qlearner_na]

    basestyle = dict(c="k", lw=0.7)
    refstyle = dict(basestyle, c="r", ls="--")
    zstyle = dict(basestyle, c="y", ls="-")
    qstyle = dict(basestyle, c="b", ls="-.")
    zlearner.style.update(zstyle)
    qlearner.style.update(qstyle)
    zlearner_na.style.update(zstyle)
    qlearner_na.style.update(qstyle)

    # Figure common setup
    cfg = linear.cfg
    linear.load_config()
    t_range = (0, cfg.final_time)

    # All in inches
    subsize = (4.05, 0.946)
    width = 4.94
    top = 0.2
    bottom = 0.671765
    left = 0.5487688
    hspace = 0.2716

    # =================
    # States and inputs
    # =================
    figsize, pos = plot.posing(5, subsize, width, top, bottom, left, hspace)
    plt.figure(figsize=figsize)

    ax = plot.subplot(pos, 0)
    [plot.vector_by_index(d, "x", 0)[0] for d in data]
    plt.ylabel(r"$x_1$")
    # plt.ylim(-2, 2)
    plt.legend()

    plot.subplot(pos, 1, sharex=ax)
    [plot.vector_by_index(d, "x", 1) for d in data]
    plt.ylabel(r"$x_2$")
    # plt.ylim(-2, 2)

    plot.subplot(pos, 2, sharex=ax)
    [plot.vector_by_index(d, "u", 0) for d in data]
    plt.ylabel(r'$u$')
    # plt.ylim(-80, 80)

    # ====================
    # Parameter estimation
    # ====================
    ax = plot.subplot(pos, 3)
    plot.all(qlearner, "K", style=dict(refstyle, label="True"))
    for d in data:
        plot.all(
            d, "K", is_agent=True,
            style=dict(marker="o", markersize=2)
        )
    plt.ylabel(r"$\hat{K}$")
    plt.legend()
    # plt.ylim(-70, 30)

    plot.subplot(pos, 4, sharex=ax)
    plot.all(qlearner, "P", style=dict(qlearner.style, c="r", ls="--"))
    for d in data:
        plot.all(
            d, "P", is_agent=True,
            style=dict(marker="o", markersize=2)
        )
    plt.ylabel(r"$\hat{P}$")
    # plt.ylim(-70, 30)

    plt.xlabel("Time, sec")
    plt.xlim(t_range)

    for ax in plt.gcf().get_axes():
        ax.label_outer()

    # ==================================
    # States and inputs (Non-Admissible)
    # ==================================
    figsize, pos = plot.posing(5, subsize, width, top, bottom, left, hspace)
    plt.figure(figsize=figsize)

    ax = plot.subplot(pos, 0)
    [plot.vector_by_index(d, "x", 0)[0] for d in data_na]
    plt.ylabel(r"$x_1$")
    # plt.ylim(-2, 2)
    plt.legend()

    plot.subplot(pos, 1, sharex=ax)
    [plot.vector_by_index(d, "x", 1) for d in data_na]
    plt.ylabel(r"$x_2$")
    # plt.ylim(-2, 2)

    plot.subplot(pos, 2, sharex=ax)
    [plot.vector_by_index(d, "u", 0) for d in data_na]
    plt.ylabel(r'$u$')
    # plt.ylim(-80, 80)

    # =====================================
    # Parameter estimation (Non-Admissible)
    # =====================================
    ax = plot.subplot(pos, 3)
    plot.all(qlearner_na, "K", style=dict(refstyle, label="True"))
    for d in data_na:
        plot.all(
            d, "K", is_agent=True,
            style=dict(marker="o", markersize=2)
        )
    plt.ylabel(r"$\hat{K}$")
    plt.legend()
    # plt.ylim(-70, 30)

    plot.subplot(pos, 4, sharex=ax)
    plot.all(qlearner_na, "P", style=refstyle)
    for d in data_na:
        plot.all(
            d, "P", is_agent=True,
            style=dict(marker="o", markersize=2)
        )
    plt.ylabel(r"$\hat{P}$")
    # plt.ylim(-70, 30)

    plt.xlabel("Time, sec")
    plt.xlim(t_range)

    for ax in plt.gcf().get_axes():
        ax.label_outer()

    imgdir = Path("img", datadir.relative_to("data"))
    imgdir.mkdir(exist_ok=True)

    plt.figure(1)
    plt.savefig(Path(imgdir, "figure_1.pdf"), bbox_inches="tight")

    plt.figure(2)
    plt.savefig(Path(imgdir, "figure_2.pdf"), bbox_inches="tight")

    plt.show()
示例#7
0
    def comp(sqldir, klmdir):
        # Data 001 ~ Data 002
        sql = plot.get_data(Path(datadir, sqldir))
        klm = plot.get_data(Path(datadir, klmdir))
        data = [sql, klm]
        # data_na = []

        basestyle = dict(c="k", lw=0.7)
        refstyle = dict(basestyle, c="r", ls="--")
        klm_style = dict(basestyle, c="y", ls="-")
        sql_style = dict(basestyle, c="b", ls="-.")
        klm.style.update(klm_style)
        sql.style.update(sql_style)
        # zlearner_na.style.update(klm_style)
        # qlearner_na.style.update(sql_style)

        # Figure common setup
        t_range = (0, sql.info["cfg"].env_kwargs.max_t)

        # All in inches
        subsize = (4.05, 0.946)
        width = 4.94
        top = 0.2
        bottom = 0.671765
        left = 0.5487688
        hspace = 0.2716

        # =================
        # States and inputs
        # =================
        figsize, pos = plot.posing(3, subsize, width, top, bottom, left,
                                   hspace)
        plt.figure(figsize=figsize)

        ax = plot.subplot(pos, 0)
        [plot.vector_by_index(d, "x", 0)[0] for d in data]
        plt.ylabel(r"$x_1$")
        # plt.ylim(-2, 2)
        plt.legend()

        plot.subplot(pos, 1, sharex=ax)
        [plot.vector_by_index(d, "x", 1) for d in data]
        plt.ylabel(r"$x_2$")
        # plt.ylim(-2, 2)

        plot.subplot(pos, 2, sharex=ax)
        [plot.vector_by_index(d, "x", 2) for d in data]
        plt.ylabel(r'$x_3$')
        # plt.ylim(-80, 80)

        plt.xlabel("Time, sec")
        plt.xlim(t_range)

        for ax in plt.gcf().get_axes():
            ax.label_outer()

        # ====================
        # Parameter estimation
        # ====================
        figsize, pos = plot.posing(3, subsize, width, top, bottom, left,
                                   hspace)
        plt.figure(figsize=figsize)

        ax = plot.subplot(pos, 0)
        [plot.vector_by_index(d, "u", 0) for d in data]
        plt.ylabel(r'$\delta_t$')

        plot.subplot(pos, 1, sharex=ax)
        plot.all(sql, "K", style=dict(refstyle, label="True"))
        for d in data:
            plot.all(d,
                     "K",
                     is_agent=True,
                     style=dict(marker="o", markersize=2))
        plt.ylabel(r"$\hat{K}$")
        plt.legend()
        # plt.ylim(-70, 30)

        plot.subplot(pos, 2, sharex=ax)
        plot.all(sql, "P", style=dict(sql.style, c="r", ls="--"))
        for d in data:
            plot.all(d,
                     "P",
                     is_agent=True,
                     style=dict(marker="o", markersize=2))
        plt.ylabel(r"$\hat{P}$")
        # plt.ylim(-70, 30)

        plt.xlabel("Time, sec")
        plt.xlim(t_range)

        for ax in plt.gcf().get_axes():
            ax.label_outer()
示例#8
0
文件: plot_hgg.py 项目: MouseHu/gem
	matplotlib.use('Agg')
	fig_cnt = len(experiments_set[args.id])
	if fig_cnt==8: fig_w, fig_h = 4, 2
	elif fig_cnt==4:
		if args.id=='7_slide': fig_w, fig_h = 2, 2
		else: fig_w, fig_h = 4, 1
	else: fig_w, fig_h = (fig_cnt-1)%3+1, (fig_cnt-1)//3+1
	size_w, size_h = size_dict[(fig_w,fig_h)]
	plt.figure(figsize=(size_w,size_h),frameon=False)

	CI_level = args.CI
	legend_id, legend_cnt, lines = 0, 0, []
	for fig_id, experiment in enumerate(experiments_set[args.id]):
		alg_cnt = 0
		data, _ = get_data(final_id[experiment][0])
		if len(list(data.keys()))==0: continue
		task = list(data.keys())[0]
		for alg in list(final_colors[args.id].keys()):
			if alg in data[task].keys():
				alg_cnt += 1
		if alg_cnt>legend_cnt:
			legend_cnt = alg_cnt
			legend_id = fig_id

	for fig_id, experiment in enumerate(experiments_set[args.id]):
		if args.id[0]=='9': lines = []
		data, _ = get_data(final_id[experiment][0])
		plt.subplot(fig_h, fig_w, fig_id+1)
		if args.id in ['6_2']:
			plt.title(final_id[experiment][1],size=16.0)
示例#9
0
# Get Video
vidObj = cv2.VideoCapture(
    '/Users/rachelzhou/Research/build_opencv/opencv/samples/python/single/bee6.avi'
)

vidObj.set(1, 50)

ret, frame = vidObj.read()

sec = []
for x in plot.x:
    x = x / 23.39
    sec.append(x)

t = np.array(sec)
x = np.array(plot.get_data(5))
y = np.array(plot.get_data(0))
z = np.array(plot.get_data(3))

# Configure subplots
fig, axs = plt.subplots(3, 2, sharex='col')

# Initialize the line plots
axs[0, 0].plot(t, x)
axs[0, 0].set_ylabel('velocity' + '\n' + '(pixels per second)')

axs[1, 0].plot(t, y)
axs[1, 0].set_ylabel('angle between' + '\n' + ' antennae (degrees)')

axs[2, 0].plot(t, z)
axs[2, 0].set_ylabel('airflow (meters' + '\n' + ' per second)')