-
Notifications
You must be signed in to change notification settings - Fork 2
/
read_GUI_csv.py
63 lines (49 loc) · 1.93 KB
/
read_GUI_csv.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
import pandas
import matplotlib
import matplotlib.pyplot as plt
import datetime
matplotlib.use('TkAgg')
# This reads
mix = pandas.read_csv(
"initialtestreadingswithtalcandnylonpowder/mixHadamard 1_063003_20190226_071616.csv",
skiprows=22, names=["wavelength", "absorbance", "reference", "sample"]
)
nylon = pandas.read_csv(
"initialtestreadingswithtalcandnylonpowder/nylonHadamard 1_063002_20190226_071250.csv",
skiprows=22, names=["wavelength", "absorbance", "reference", "sample"]
)
talc = pandas.read_csv(
"initialtestreadingswithtalcandnylonpowder/talcHadamard 1_063001_20190226_070716.csv",
skiprows=22, names=["wavelength", "absorbance", "reference", "sample"]
)
count = 0
best_squares = 0
best_squares_index = 0
best_squares_offset = 0
squares_dict = {}
for offset in range(-100, 100):
print(offset)
for i in range(40,60):
squares = 0
pred_abs_list = []
for index, row in mix.iterrows():
pred_abs = (i/100)*talc['absorbance'][index] + ((100-i)/100)*nylon['absorbance'][index] + 0.01*offset/100
pred_abs_list.append(pred_abs)
squares += (mix['absorbance'][index] - pred_abs)**2
if squares < best_squares or count==0:
best_squares = squares
best_squares_index = i
best_squares_offset = offset
squares_dict[str(i)] = squares
mix[str("percent_{}_offset_{}".format(i, offset))] = pred_abs_list
count+=1
print("{}% Talc".format(best_squares_index))
tfig, tax = plt.subplots(1)
mix.plot(x="wavelength", y="absorbance", ax=tax)
mix.plot(x="wavelength", y=str("percent_{}_offset_{}".format(best_squares_index, best_squares_offset)), ax=tax)
# mix.plot(x="wavelength", y="percent_49", ax=tax)
# mix.plot(x="wavelength", y="percent_50", ax=tax)
# mix.plot(x="wavelength", y="percent_51", ax=tax)
nylon.plot(x="wavelength", y="absorbance", ax=tax)
talc.plot(x="wavelength", y="absorbance", ax=tax)
plt.show()