Commit fa84559d authored by Andreas Schmidt's avatar Andreas Schmidt

Reformatted files.

parent 6377fa33
import pandas as pd
import math
import numpy as np
import matplotlib.pyplot as plt
plt.rcParams["figure.figsize"] = (16,9)
from sklearn import linear_model
plt.rcParams["figure.figsize"] = (16, 9)
plt.rcParams.update({'figure.autolayout': True})
# TODO: Refactor.
def hist(df):
return df.hist(cumulative=True, normed=1,bins=200)
return df.hist(cumulative=True, normed=1, bins=200)
def scatter(df, column):
plt.scatter(df.index, df[column], grid=True)
def scatter(df,column):
plt.scatter(df.index,df[column],grid=True)
def regress(df,column):
x = df.index.values.reshape(-1,1)
def regress(df, column):
x = df.index.values.reshape(-1, 1)
y = df[column].values
model = linear_model.LinearRegression()
model.fit(x,y)
print("R-Score:", model.score(x,y))
plt.scatter(x,y)
model.fit(x, y)
print("R-Score:", model.score(x, y))
plt.scatter(x, y)
plt.grid()
plt.plot(x,model.predict(x),color="red",linewidth=3)
plt.plot(x, model.predict(x), color="red", linewidth=3)
def trace(df,title,export=False):
def trace(df, title, export=False):
fig, ax = plt.subplots(figsize=(8, 4.5))
plt.grid()
......@@ -42,7 +49,7 @@ def trace(df,title,export=False):
["PrrtTransmitStart_T", "PrrtTransmitEnd_T", sender_color, "PrrtTransmit"],
["LinkTransmitStart_T", "LinkTransmitEnd_T", sender_color, "LinkTransmit"],
["LinkReceive_T", "PrrtDeliver_T", receiver_color, "ReceiverTotal"],
#["DecodeStart_T", "DecodeEnd_T", receiver_color, "Decoding"],
# ["DecodeStart_T", "DecodeEnd_T", receiver_color, "Decoding"],
["HandlePacketStart_T", "HandlePacketEnd_T", receiver_color, "HandlePacket"],
["PrrtReturnPackage_T", "PrrtReceivePackage_T", receiver_color, "ReceiverIPC"],
["SendFeedbackStart_T", "SendFeedbackEnd_T", receiver_color, "Feedback"],
......@@ -50,7 +57,7 @@ def trace(df,title,export=False):
n = series.shape[1]
starts = df[series[0]] - base
ends = df[series[1]] - base
plt.hlines(range(n), starts, ends, series[2],linewidths=[5])
plt.hlines(range(n), starts, ends, series[2], linewidths=[5])
plt.xlabel("Time [us]")
fig.canvas.draw()
......@@ -61,24 +68,27 @@ def trace(df,title,export=False):
plt.savefig(title)
plt.show()
def box(df_data,export=False,title=None):
ax = df_data.plot.box(vert=False,grid=True)
fig=ax.get_figure()
def box(df_data, export=False, title=None):
ax = df_data.plot.box(vert=False, grid=True)
fig = ax.get_figure()
ax.set_yticklabels(list(map(lambda x: x.get_text().replace("_D", ""), ax.get_yticklabels())))
plt.xlabel("Time [us]")
fig.set_size_inches(8, 4.5, forward=True)
if export and title is not None:
fig.savefig(title)
def describe_table(df):
stats = df.describe()
stats.drop(["count"],inplace=True)
stats.drop(["count"], inplace=True)
stats.columns = list(map(lambda x: x.replace("_D", ""), stats.columns))
table = stats.to_latex(float_format=lambda x: "%.3f" % x)
print(table)
return stats
def correlation(df_data,title="Correlation.pdf"):
def correlation(df_data, title="Correlation.pdf"):
columns = list(["Sender_D",
"SendTime",
"SenderIPCTime",
......@@ -89,17 +99,17 @@ def correlation(df_data,title="Correlation.pdf"):
"FeedbackTime",
])
cols=4
rows=math.ceil(len(columns) / cols)
cols = 4
rows = int(math.ceil(len(columns) / cols))
fig, axes = plt.subplots(nrows=rows, ncols=cols)
fig.set_size_inches(4*cols, 3.5*rows, forward=True)
fig.set_size_inches(4 * cols, 3.5 * rows, forward=True)
i = 0
for column in columns:
ax = df_data.plot.scatter(ax=axes[i//cols,i % cols],y="EndToEndTime",x=column,grid=True,marker="+",color="black")
fig2 = ax.get_figure()
ax = df_data.plot.scatter(ax=axes[i // cols, i % cols], y="EndToEndTime", x=column, grid=True, marker="+",
color="black")
ax.set_ylabel("EndToEnd [us]")
ax.margins(0.1,0.1)
ax.margins(0.1, 0.1)
ax.set_xlabel("{} [us]".format(column.replace("_D", "")))
i += 1
fig.savefig(title)
......@@ -8,12 +8,13 @@ tasks = {
"jitter": None
}
def parse_config():
contents = None
with open("xlap.yml") as f:
contents = f.read()
return yaml.load(contents)
def main():
config = parse_config()
data_files = config["data_files"]
......@@ -30,13 +31,13 @@ def main():
df_data = evaluate(data_files["sender"], data_files["receiver"], config=config, kind=0)
params = { "export": args.export}
params = {"export": args.export}
if command == "jitter":
params1 = dict(params)
params1.update({"file_name" : "TraceJitter.pdf"})
params1.update({"file_name": "TraceJitter.pdf"})
params2 = dict(params)
params2.update({"file_name" : "JitterCauses.pdf"})
params2.update({"file_name": "JitterCauses.pdf"})
df = jitter.prep(df_data, config)
jitter.trace_jitter(df, **params1)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment