Commit 94c7a13d authored by Andreas Schmidt's avatar Andreas Schmidt

Add export flag.

parent 8e9b5f48
......@@ -3,6 +3,8 @@ import matplotlib.pyplot as plt
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)
......@@ -20,7 +22,7 @@ def regress(df,column):
plt.grid()
plt.plot(x,model.predict(x),color="red",linewidth=3)
def trace(df,title):
def trace(df,title,export=False):
fig, ax = plt.subplots(figsize=(8, 4.5))
plt.grid()
......@@ -55,16 +57,17 @@ def trace(df,title):
ax.set_yticklabels(series[3])
ax.yaxis.set_ticks(np.arange(0, n, 1))
plt.savefig(title)
if export:
plt.savefig(title)
plt.show()
def box(df_data,title=None):
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("Time", ""), ax.get_yticklabels())))
plt.xlabel("Time [us]")
fig.set_size_inches(8, 4.5, forward=True)
if title is not None:
if export and title is not None:
fig.savefig(title)
def describe_table(df):
......
# TODO: Refactor.
def get_outlier_treshold(stats):
q75 = stats["75%"]
iqr = q75 - stats["25%"]
......
......@@ -6,17 +6,20 @@ plt.rcParams.update({'figure.autolayout': True})
from xlap.analyse.common import get_outlier_treshold, extract_durations
from xlap.analyse import box
# TODO: Refactor.
def _dn(x):
return x + "Time"
def _filter(x, durations, source):
return durations[x]["Source"] == source
def _jitter_causes(df,title="JitterCause.pdf"):
def jitter_causes(df, export=False, file_name=None):
stats = df["EndToEndTime"].describe()
tresh = get_outlier_treshold(stats)
outliers = df[df["EndToEndTime"] > tresh]
# TODO: Refactor lines out.
reasons = ["SendTime",
"PrrtTransmitTime",
"LinkTransmitTime",
......@@ -44,19 +47,20 @@ def _jitter_causes(df,title="JitterCause.pdf"):
plt.ylabel("Frequency")
ax.set_xticklabels(list(map(lambda x: x.get_text().replace("Time", ""), ax.get_xticklabels())))
fig.set_size_inches(8, 3, forward=True)
fig.savefig(title)
if export:
fig.savefig(file_name)
print("Outliers:",len(outliers),";","Threshold[us]:",tresh)
def analyse(df_data, config, file_name=None):
columns = extract_durations(config)
df_box = df_data[columns]
thresh = get_outlier_treshold(df_box["EndToEndTime"].describe())
df_no = df_box[df_box["EndToEndTime"] <= thresh]
box(df_no, file_name)
print("No of non-outliers:",len(df_no))
def trace_jitter(df_filtered, export=False, file_name=None):
thresh = get_outlier_treshold(df_filtered["EndToEndTime"].describe())
df_no_outliers = df_filtered[df_filtered["EndToEndTime"] <= thresh]
box(df_no_outliers, export, file_name)
print("{} / {} are no outliers.".format(len(df_no_outliers), len(df_filtered)))
fig = plt.gcf()
fig.canvas.set_window_title('Jitter Analysis')
plt.show()
_jitter_causes(df_box)
def prep(df, config):
columns = extract_durations(config)
df_filtered = df[columns]
return df_filtered
......@@ -19,7 +19,8 @@ def main():
data_files = config["data_files"]
parser = argparse.ArgumentParser()
parser.add_argument("tasks", metavar="T", type=str, nargs="+", help="analysis tasks to execute")
parser.add_argument("tasks", metavar="T", type=str, nargs="+", help="Analysis tasks to execute")
parser.add_argument("-e", "--export", dest="export", action="store_true", default=False, help="Output pdf files.")
args = parser.parse_args()
for command in args.tasks:
......@@ -28,4 +29,15 @@ def main():
continue
df_data = evaluate(data_files["sender"], data_files["receiver"],kind=0)
jitter.analyse(df_data, config, "TraceJitter.pdf")
params = { "export": args.export}
if command == "jitter":
params1 = dict(params)
params1.update({"file_name" : "TraceJitter.pdf"})
params2 = dict(params)
params2.update({"file_name" : "JitterCauses.pdf"})
df = jitter.prep(df_data, config)
jitter.trace_jitter(df, **params1)
jitter.jitter_causes(df, **params2)
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