-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMelissa_Code_1.3(openiteration)-IT.py
77 lines (55 loc) · 1.81 KB
/
Melissa_Code_1.3(openiteration)-IT.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
import matplotlib.pyplot as plt
import os
#name = input('100nm-5HT-glutamate-trode2-(3)_CV.txt')
#handle = open(name)
def function():
x_axis = list()
x_expon = list()
x_dec = list()
voltage_axis = list()
voltage_expon = list()
voltage_dec = list()
current_axis = list()
current_expon = list()
current_dec = list()
# Assign each column to seperate lists
for line in f:
sep = line.split()
voltage_axis.append(sep[0])
current_axis.append(sep[1])
# Conversion of exponents to decinmals of Current
for exp in current_axis:
conv = exp.split('E')
exp_num = float(conv[1])
current_expon.append(10**exp_num)
dec_num = float(conv[0])
current_dec.append(dec_num)
# Creates list of exponents and decimals
for exp in voltage_axis:
conv = exp.split('E')
exp_num = float(conv[1])
voltage_expon.append(10**exp_num)
dec_num = float(conv[0])
voltage_dec.append(dec_num)
# Multiples lists of decimals and exponents to give absolute float values
final_current = [m*n for m, n in zip(current_dec, current_expon)]
final_voltage = [j*k for j, k in zip(voltage_dec, voltage_expon)]
print('The highest current value is: ')
x_max = max(final_current)
print(x_max)
plt.axhline(0, color='black')
plt.xlabel('$Time$ (s)')
plt.ylabel('$Current$ (nA)')
plt.plot(final_voltage, final_current)
plt.legend(loc=1)
plt.savefig(filename+'.png', dpi=400)
plt.clf()
#name = input()
#file = open(name)
directory = '/Users/Wayne/Desktop/Python'
for filename in os.listdir(directory):
if filename.endswith(".txt"):
f = open(filename)
print('File opened: ',filename)
function()
else: continue