From 88952ef4101c36c9f7431754c57bc82de65d56b0 Mon Sep 17 00:00:00 2001 From: Holger Frey Date: Fri, 3 May 2019 09:23:36 +0200 Subject: [PATCH] added documentation for guard peak finding --- mtor/dataproc.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/mtor/dataproc.py b/mtor/dataproc.py index 72a6e2c..f52b845 100644 --- a/mtor/dataproc.py +++ b/mtor/dataproc.py @@ -113,14 +113,22 @@ def find_guard_threshold(data_frame, parameters): left_values = data_frame[parameters.left_guard_column] right_values = data_frame[parameters.right_guard_column] guard_values = left_values.append(right_values, ignore_index=True) + guard_data = numpy.histogram( guard_values, bins=parameters.guard_histogram_bins ) + + # The guard edges (x-axis values) enclose the counts (y-axis values) + # of the histogram. This means, there is one more guard edge than count. + # To construct a dataframe later, the number of items must be the same. + # Therefore a value of 0 counts is added before the "real counts" + # this also solves the problem of finding the first peak value later on + # if the first histogram bin contains the highest count. guard_counts = numpy.concatenate([[0], guard_data[0]]).astype( numpy.float16 ) - guard_edges = guard_data[1] # edges enclose the counts - + guard_edges = guard_data[1] + pyplot.clf() seaborn.lineplot(x=guard_edges, y=guard_counts) pyplot.title("Histogram of Guard Avarages (not filtered)")