blob: ca6094919cb3eee67b674e657878eae0ceb58d13 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
#!/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.loader import MIMOSA
from dfatool.utils import running_mean
voltage = float(sys.argv[1])
shunt = float(sys.argv[2])
mimfile = sys.argv[3]
mim = MIMOSA(voltage, shunt)
charges, triggers = mim.load_file(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 = 1e-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()
|