swh:1:snp:147c5a9160b26fead84b349fc25e0a0058a11de1
Tip revision: d52e52c51e3f7c5b0e12f95829b8cf4886bb3379 authored by Alexej Schatz on 26 October 2022, 14:36:09 UTC
test implementations for Autopilot, Bpod and pyControl moved to an own folder
test implementations for Autopilot, Bpod and pyControl moved to an own folder
Tip revision: d52e52c
latencies_chart.py
import numpy as np
import pandas as pd
import shutil
def create_tex_file():
# float numbers f.write format
ff = "{:.3f}".format
labnet_data = pd.read_csv('data/read_and_set_test/LabNet/c_sharp_r4_no_opt.csv', delimiter=';')
autopilot_data = pd.read_csv('data/read_and_set_test/autopilot/latencies.csv', delimiter=';')
bpod_data = pd.read_csv('data/read_and_set_test/bpod/latencies.csv', delimiter=';')
pyControl_data = pd.read_csv('data/read_and_set_test/pyControl/latencies.csv', delimiter=';')
l_mean = str(ff(labnet_data["SetAndRead"].mean()))
l_std = str(ff(labnet_data["SetAndRead"].std()))
a_mean = str(ff(autopilot_data["SetAndRead"].mean()))
a_std = str(ff(autopilot_data["SetAndRead"].std()))
b_mean = str(ff(bpod_data["SetAndRead"].mean()))
b_std = str(ff(bpod_data["SetAndRead"].std()))
p_mean = str(ff(pyControl_data["SetAndRead"].mean()))
p_std = str(ff(pyControl_data["SetAndRead"].std()))
shutil.copyfile("template.tex", "latencies_chart.tex")
f = open("latencies_chart.tex", "a")
f.write("\\definecolor{color1}{HTML}{A95AA1}\n")
f.write("\definecolor{color2}{HTML}{85c0f9}\n")
f.write("\n")
f.write("\\begin{document}\n")
f.write("\\begin{tikzpicture}\n")
f.write(" \\pgfplotsset{compat=1.11,\n")
f.write(" /pgfplots/xbar legend/.style={\n")
f.write(" /pgfplots/legend image code/.code={%\n")
f.write(" \draw[##1,/tikz/.cd,yshift=-0.25em]\n")
f.write(" (0cm,0cm) rectangle (3pt,0.8em);},\n")
f.write(" %\draw[##1,/tikz/.cd,bar width=5pt,yshift=-0.2em,bar shift=0pt]\n")
f.write(" %plot coordinates {(0cm,0.8em)};},\n")
f.write(" },\n")
f.write(" }\n")
f.write("\n")
f.write(" \\begin{axis}[\n")
f.write(" axis x line=bottom,\n")
f.write(" axis y line=left,\n")
f.write(" compat=newest,\n")
f.write(" axis on top,\n")
f.write(" %title=Uses lowest $x$ coords for xmin,\n")
f.write(" xbar,\n")
f.write(" xmin=0,\n")
f.write(" width=6.5cm,\n")
f.write(" height=4.5cm,\n")
f.write(" enlarge y limits=0.15,\n")
f.write(" xlabel={latency, ms},\n")
f.write(" symbolic y coords={Autopilot,Bpod,pyControl,Whisker,LabNet},\n")
f.write(" ytick={Autopilot,Bpod,pyControl,Whisker,LabNet},\n")
f.write(" %y tick label style={anchor=west,color=red!50!blue,xshift= \pgfkeysvalueof{/pgfplots/major tick length}},\n")
f.write(" bar shift=0pt,\n")
f.write(" nodes near coords,\n")
f.write(" nodes near coords align=horizontal,\n")
f.write(" nodes near coords style={\n")
f.write(" anchor=west,\n")
f.write(" },\n")
f.write(" point meta=explicit symbolic,\n")
f.write(" bar width=0.35cm,\n")
f.write(" legend style={at={(1.7,0.95)}, anchor=north,legend columns=-1,draw=none},\n")
f.write(" ]\n")
f.write(" \\addplot[fill=color1, draw=black] coordinates {(" + a_mean + ",Autopilot) [$" + a_mean + "\pm{}" + a_std + "$] (" + b_mean + ",Bpod) [$" + b_mean + "\pm{}" + b_std + "$] (" + p_mean + ",pyControl) [$" + p_mean + "\pm{}" + p_std + "$]};\n")
f.write("\n")
f.write(" \\addplot[fill=color2, draw=black] coordinates {(1,Whisker) [1] (" + l_mean + ",LabNet) [$" + l_mean + "\pm{}" + l_std + "$]};\n")
f.write("\n")
f.write(" \\legend{local,network}\n")
f.write(" \\end{axis}\n")
f.write("\\end{tikzpicture}\n")
f.write("\\end{document}\n")