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)")