summaryrefslogtreecommitdiff
path: root/crl_tools/make_tables.py
blob: eeadd7d87ac0210536f686ee771dcbde476c0fea (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
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
import numpy as np
import os

def prefix(path):
	return os.path.join(os.path.dirname(__file__), "table_data", path)

print("# Generated by make_tables.py, do not modify")
print("import numpy as np")

#
# CIE CMFs
# 

def load_cmf(path, ident, comment):
	data = np.nan_to_num(np.genfromtxt(path, delimiter=","), copy=False)

	print("\n# %s" % comment)
	print("%s = np.array([" % ident)
	for row in data:
		print(("\t[" + "%.8g, " * 4 + "],") % tuple(row))
	print("])")

load_cmf(prefix("ciexyz31.csv"), "cmf",
         "CIE 1931 2-deg, XYZ CMFs, http://www.cvrl.org/")
load_cmf(prefix("ciexyzj.csv"), "cmf_judd",
         "CIE 1931 2-deg, XYZ CMFs modified by Judd (1951), http://www.cvrl.org/")
load_cmf(prefix("ciexyzjv.csv"), "cmf_judd_vos",
         "CIE 1931 2-deg, XYZ CMFs modified by Judd (1951) and Vos (1978), http://www.cvrl.org/")
load_cmf(prefix("ciexyz64.csv"), "cmf_1964",
         "CIE 1964 10-deg, XYZ CMFs")
load_cmf(prefix("linss2_10e_5.csv"), "cmf_lms",
         "2-deg fundamentals based on the Stiles & Burch 10-deg CMFs (adjusted to 2-deg), http://www.cvrl.org/")

#
# CIE illuminants
#

data = np.genfromtxt(prefix("illuminants.csv"))
print("\n# CIE standard illuminants")
print("# https://law.resource.org/pub/us/cfr/ibr/003/cie.15.2004.tables.xls")
print("# nm\tA\tD65\tC\tD50\tD55\tD75")
print("illuminants = np.array([")
for row in data:
	print(("\t[" + "%.8g, " * 7 + "],") % tuple(row))
print("])")

#
# CIE D illuminant eigenvectors
#

data = np.genfromtxt(prefix("D_eigenvectors.csv"))
print("\n# #CIE D illuminant eigenvectors")
print("# http://www.brucelindbloom.com/index.html?Eqn_DIlluminant.html")
print("# wvl\tS0\tS1\tS2")
print("D_eigenvectors = np.array([")
for row in data:
	print(("\t[" + "%.8g, " * 4 + "],") % tuple(row))
print("])")

# Series F illuminants

data = np.genfromtxt(prefix("F.txt"))
print("\n# CIE standard illuminants")
print("# https://web.archive.org/web/20110725185449/http://www.colour.org/tc8-04/Data/F.txt")
print("# https://web.archive.org/web/20110725185449/http://www.colour.org/tc8-04/Data/F.txt")
print("#(nm)\tF1\tF2*\tF3\tF4\tF5\tF6+\tF7*\tF8+\tF9\tF10+\tF11*\tF12")
print("illuminants_F = np.array([")
for row in data:
	print(("\t[" + "%.8g, " * 13 + "],") % tuple(row))
print("])")

#
# CRI Ra test color samples
#

data = np.genfromtxt(prefix("tcs_ra.txt"))
print("\n# CRI Ra test color samples")
print("# https://www.waveformlighting.com/files/cri_1nm.txt")
print("# nm\tTCS01\tTCS02\tTCS03\tTCS04\tTCS05\tTCS06\tTCS07\tTCS08\tTCS09\tTCS10\tTCS11\tTCS12\tTCS13\tTCS14")
print("tcs_ra = np.array([")
for row in data:
	print(("\t[" + "%.8g, " * 15 + "],") % tuple(row))
print("])")

#
# CQS test color samples
#

data = np.genfromtxt(prefix("tcs_cqs.csv"))
print("\n# CQS test color samples")
print("# https://www.researchgate.net/profile/Velu_Arasu/post/What_will_be_RGBA_LEDs_pattern_to_creat_white_light/attachment/59d62f13c49f478072e9fb7b/AS%3A273582771376136%401442238623549/download/CQS+9.0.3++%28Win%29.xls")
print("# nm\tVS1\tVS2\tVS3\tVS4\tVS5\tVS6\tVS7\tVS8\tVS9\tVS10\tVS11\tVS12\tVS13\tVS14\tVS15")
print("tcs_cqs = np.array([")
for row in data:
	print(("\t[" + "%.8g, " * 16 + "],") % tuple(row))
print("])")

#
#
#
print("\n# CQS multiplication factors")
print("# https://accreditedgemologists.org/lightingtaskforce/NISTDevelopmentofColorQualityScale.pdf")
print("# CCT factor")
data = np.genfromtxt(prefix("cqs_factors.csv"))
print("cqs_factors = np.array([")
for row in data:
	print(("\t[" + "%.8g, " * 2 + "],") % tuple(row))
print("])")