-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmeasure_color_channel.py
46 lines (38 loc) · 1.5 KB
/
measure_color_channel.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
from achrolab.calibtubes import CalibTubes
from achrolab.eyeone.eyeone import EyeOne
import time
import random
eyeone = EyeOne(dummy=False)
caltub = CalibTubes(eyeone)
caltub.setVoltages((0xFFF, 0xFFF, 0xFFF))
voltages_g = []
xyY_g = []
spectra_g = []
random.seed(4)
for i in range(1):
#measure_green=caltub.measureOneColorChannel(color="green", n=50, each=1)
#voltages_g=voltages_g+measure_green[0]
#xyY_g=xyY_g+measure_green[1]
#spectra_g=spectra_g+measure_green[2]
#def fun(self,step, i,n):
# return ((0xFFF - step * n)+(step*i))
def fun(self,step, i,n):
return random.randint(1024, 4095)
measure_green=caltub.measureOneColorChannel(color="green", insertfunction=fun,
n=5,each=1)
voltages_g=voltages_g+measure_green[0]
xyY_g=xyY_g+measure_green[1]
spectra_g=spectra_g+measure_green[2]
with open('calibdata/measurements/measure_green_channel_' +
time.strftime("%Y%m%d_%H%M") + '.txt', 'w') as calibFile:
calibFile.write("voltage, xyY, spectra\n") # TODO not just with 3 values but with 3 + 3 + 36
voltages = (voltages_g)
xyY = (xyY_g)
spectra = (spectra_g)
for i in range(len(voltages)):
calibFile.write(", ".join([str(x) for x in voltages[i]]) +
", " + ", ".join([str(x) for x in
xyY[i]]) +
", " + ", ".join([str(x) for x in
spectra[i]]) +
"\n")