Commit 471b17b7 authored by Daniel Friesel's avatar Daniel Friesel
Browse files

tabs -> spaces

parent 90eeeaf7
Loading
Loading
Loading
Loading
+127 −109
Original line number Diff line number Diff line
#!/usr/bin/env python3
# vim:tabstop=4:softtabstop=4:shiftwidth=4:textwidth=160:smarttab:expandtab

import getopt
import matplotlib.pyplot as plt
@@ -44,6 +45,12 @@ OPTIONS
  --skip <count>
    Skip <count> data samples. This is useful to avoid startup code
    influencing the results of a long-running measurement
  --threshold <watts>|auto
    Partition data into points with mean power >= <watts> and points with
    mean power < <watts>, and print some statistics. higher power is handled
    as peaks, whereas low-power measurements constitute the baseline.
    If the threshold is set to "auto", the mean power of all measurements
    will be used
  --plot
    Show power/time plot
  --stat
@@ -71,7 +78,7 @@ if __name__ == '__main__':
        else:
            opt['skip'] = 0

		if 'threshold' in opt:
        if 'threshold' in opt and opt['threshold'] != 'auto':
            opt['threshold'] = float(opt['threshold'])

    except getopt.GetoptError as err:
@@ -117,6 +124,17 @@ if __name__ == '__main__':
    if 'threshold' in opt:
        power = data[:, 1] * data[:, 2]

        if opt['threshold'] == 'auto':
            opt['threshold'] = np.mean(power)
            print('Threshold set to {:.0f} µW'.format(opt['threshold'] * 1e6))

        if np.any(power < opt['threshold']):
            print('Baseline mean: {:.0f} µW'.format(
                np.mean(power[power < opt['threshold']]) * 1e6 ))
        if np.any(power >= opt['threshold']):
            print('Peak mean: {:.0f} µW'.format(
                np.mean(power[power >= opt['threshold']]) * 1e6))

        peaks = []
        peak_start = -1
        for i, dp in enumerate(power):