diff options
author | Daniel Friesel <derf@finalrewind.org> | 2017-04-03 15:04:15 +0200 |
---|---|---|
committer | Daniel Friesel <derf@finalrewind.org> | 2017-04-03 15:04:15 +0200 |
commit | 00e57331b1c7ef2b1f402f41e1223308e0d8ce61 (patch) | |
tree | 05e9b4223072582a5a6843de6d9845213a94f341 /bin/gradient |
initial commit
Diffstat (limited to 'bin/gradient')
-rwxr-xr-x | bin/gradient | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bin/gradient b/bin/gradient new file mode 100755 index 0000000..d2f43ef --- /dev/null +++ b/bin/gradient @@ -0,0 +1,32 @@ +#!/usr/bin/env python3 + +import csv +import numpy as np +import os +import struct +import sys +import tarfile +import matplotlib.pyplot as plt +from dfatool import running_mean, MIMOSA + +voltage = float(sys.argv[1]) +shunt = float(sys.argv[2]) +mimfile = sys.argv[3] + +mim = MIMOSA(voltage, shunt) + +charges, triggers = mim.load_data(mimfile) +charges = charges[2000000:3000000] + +currents = running_mean(mim.charge_to_current_nocal(charges), 10) * 1e-6 +xr = np.arange(len(currents)) * 1e-5 +threshold = 3e-5 +grad = np.gradient(currents, 2) +tp = np.abs(grad) > threshold +plt.plot( xr, currents, "r-") +plt.plot( xr, grad, "y-") +plt.plot( xr[tp], grad[tp], "bo") +plt.xlabel('Zeit [s]') +plt.ylabel('Strom [A]') +plt.grid(True) +plt.show() |