forked from OpenSourceBrain/BlueBrainProjectShowcase
-
Notifications
You must be signed in to change notification settings - Fork 2
/
iv_analyse.py
90 lines (67 loc) · 1.96 KB
/
iv_analyse.py
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/python
from decimal import Decimal
import glob
import re
import numpy as np
from matplotlib import pyplot as plt
def main():
# Build dict of voltages and their corresponding files
filenames = glob.glob('./i_*.lems.dat')
file_dict = {}
for name in filenames:
v_match = re.match("\./i_(.*)\.lems\.dat", name)
voltage = v_match.group(1)
voltage = voltage.replace("min", "-")
voltage = Decimal(voltage)
file_dict[voltage] = name
v_arr = []
ih = []
il = []
ip = []
print "voltage (mV) i_lowest (A) i_highest (A) i_peak (A)"
# Find highest, lowest, and steady-state current from each file
voltages = file_dict.keys()
voltages.sort()
for voltage in voltages:
i_highest = None
i_lowest = 10000
i_peak = None
i_file = open(file_dict[voltage], "r")
for line in i_file:
columns = line.split()
i = float(columns[1])
if i < i_lowest:
i_lowest = i;
if i > i_highest:
i_highest = i;
if abs(i_lowest) > abs(i_highest):
i_peak = i_lowest
else:
i_peak = i_highest
print "{0:>12}{1:>15E}{2:>15E}{3:>15E}".format(voltage, i_lowest, i_highest, i_peak)
v_arr.append(float(voltage));
ih.append(float(i_highest));
il.append(float(i_lowest));
ip.append(float(i_peak));
x=np.array(v_arr)
y=np.array(ih)
plt.figure(1)
plt.plot(x,y)
plt.title("Highest current")
plt.xlabel("voltage (mV)")
plt.ylabel("current (A)")
y=np.array(il)
plt.figure(2)
plt.plot(x,y)
plt.title("Lowest current")
plt.xlabel("voltage (mV)")
plt.ylabel("current (A)")
y=np.array(ip)
plt.figure(3)
plt.plot(x,y)
plt.title("Peak absolute current")
plt.xlabel("voltage (mV)")
plt.ylabel("current (A)")
plt.show()
if __name__ == '__main__':
main()