Skip to content

Commit 9d28abe

Browse files
committed
Varnish *CRI* *CIE 2024* implementation.
1 parent fd3d349 commit 9d28abe

File tree

7 files changed

+3165
-3779
lines changed

7 files changed

+3165
-3779
lines changed

BIBLIOGRAPHY.bib

+3,020-3,683
Large diffs are not rendered by default.

colour/colorimetry/tests/test_uniformity.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -240,13 +240,15 @@ def test_spectral_uniformity(self) -> None:
240240
from colour.quality.datasets import SDS_TCS
241241

242242
np.testing.assert_allclose(
243-
spectral_uniformity(SDS_TCS.values()),
243+
spectral_uniformity(SDS_TCS["CIE 1995"].values()),
244244
DATA_UNIFORMITY_FIRST_ORDER_DERIVATIVES,
245245
atol=TOLERANCE_ABSOLUTE_TESTS,
246246
)
247247

248248
np.testing.assert_allclose(
249-
spectral_uniformity(SDS_TCS.values(), use_second_order_derivatives=True),
249+
spectral_uniformity(
250+
SDS_TCS["CIE 1995"].values(), use_second_order_derivatives=True
251+
),
250252
DATA_UNIFORMITY_SECOND_ORDER_DERIVATIVES,
251253
atol=TOLERANCE_ABSOLUTE_TESTS,
252254
)

colour/colorimetry/uniformity.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def spectral_uniformity(
9090
Examples
9191
--------
9292
>>> from colour.quality.datasets import SDS_TCS
93-
>>> spectral_uniformity(SDS_TCS.values()) # doctest: +ELLIPSIS
93+
>>> spectral_uniformity(SDS_TCS["CIE 1995"].values()) # doctest: +ELLIPSIS
9494
array([ 9.5514285...e-06, 1.1482142...e-05, 1.8784285...e-05,
9595
2.8711428...e-05, 3.1971428...e-05, 3.2342857...e-05,
9696
3.3850000...e-05, 3.9925714...e-05, 4.1333571...e-05,

colour/quality/cri.py

+9-5
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040

4141
from colour.hints import cast
4242
from colour.models import UCS_to_uv, XYZ_to_UCS, XYZ_to_xyY
43-
from colour.quality.datasets.tcs import INDEXES_TO_NAMES_TCS, SDS_TCS_SETS
43+
from colour.quality.datasets.tcs import INDEXES_TO_NAMES_TCS, SDS_TCS
4444
from colour.temperature import CCT_to_xy_CIE_D, uv_to_CCT_Robertson1968
4545
from colour.utilities import domain_range_scale, validate_method
4646
from colour.utilities.documentation import DocstringTuple, is_documentation_building
@@ -195,7 +195,7 @@ def colour_rendering_index(
195195

196196
shape = cmfs.shape
197197
sd_test = reshape_sd(sd_test, shape, copy=False)
198-
sds_tcs = SDS_TCS_SETS[method]
198+
sds_tcs = SDS_TCS[method]
199199
tcs_sds = {sd.name: reshape_sd(sd, shape, copy=False) for sd in sds_tcs.values()}
200200

201201
with domain_range_scale("1"):
@@ -212,11 +212,11 @@ def colour_rendering_index(
212212
sd_reference.align(shape)
213213

214214
test_tcs_colorimetry_data = tcs_colorimetry_data(
215-
sd_test, sd_reference, tcs_sds, cmfs, chromatic_adaptation=True
215+
sd_test, sd_reference, tcs_sds, cmfs, chromatic_adaptation=True, method=method
216216
)
217217

218218
reference_tcs_colorimetry_data = tcs_colorimetry_data(
219-
sd_reference, sd_reference, tcs_sds, cmfs
219+
sd_reference, sd_reference, tcs_sds, cmfs, method=method
220220
)
221221

222222
Q_as = colour_rendering_indexes(
@@ -245,6 +245,7 @@ def tcs_colorimetry_data(
245245
sds_tcs: Dict[str, SpectralDistribution],
246246
cmfs: MultiSpectralDistributions,
247247
chromatic_adaptation: bool = False,
248+
method: Literal["CIE 1995", "CIE 2024"] | str = "CIE 1995",
248249
) -> Tuple[DataColorimetry_TCS, ...]:
249250
"""
250251
Return the *test colour samples* colorimetry data.
@@ -268,6 +269,8 @@ def tcs_colorimetry_data(
268269
*Test colour samples* colorimetry data.
269270
"""
270271

272+
method = validate_method(method, tuple(COLOUR_RENDERING_INDEX_METHODS))
273+
271274
XYZ_t = sd_to_XYZ(sd_t, cmfs)
272275
uv_t = UCS_to_uv(XYZ_to_UCS(XYZ_t))
273276
u_t, v_t = uv_t[0], uv_t[1]
@@ -277,9 +280,10 @@ def tcs_colorimetry_data(
277280
u_r, v_r = uv_r[0], uv_r[1]
278281

279282
tcs_data = []
280-
for _key, value in sorted(INDEXES_TO_NAMES_TCS.items()):
283+
for _key, value in sorted(INDEXES_TO_NAMES_TCS[method].items()):
281284
if value not in sds_tcs:
282285
continue
286+
283287
sd_tcs = sds_tcs[value]
284288
XYZ_tcs = sd_to_XYZ(sd_tcs, cmfs, sd_t)
285289
xyY_tcs = XYZ_to_xyY(XYZ_tcs)

colour/quality/datasets/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
from .tcs import SDS_TCS, SDS_TCS_SETS
1+
from .tcs import SDS_TCS
22
from .vs import SDS_VS
33

44
__all__ = [
55
"SDS_TCS",
6-
"SDS_TCS_SETS",
6+
"SDS_TCS",
77
"SDS_VS",
88
]

colour/quality/datasets/tcs.py

+129-83
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,18 @@
22
Test Colour Samples Spectral Distributions
33
==========================================
44
5-
Define the *CIE 1995* test colour samples spectral distributions
6-
plus TCS15.
5+
Define the *CIE 1995* and *CIE 2024* test colour samples spectral distributions.
76
8-
The *CIE 1995* test colour samples data is in the form of a *dict* of
9-
:class:`colour.SpectralDistribution` classes as follows::
7+
The *CIE 1995* and *CIE 2024* test colour samples data is in the form of a
8+
*dict* of :class:`colour.SpectralDistribution` classes as follows::
109
1110
{'name': SpectralDistribution, ..., 'name': SpectralDistribution}
1211
1312
References
1413
----------
14+
- :cite:`CIE2024` : CIE. (2024). Spectral radiance factors of test-colour
15+
sample #15 of the Japanese skin complexion, 5nm wavelength steps [Data set].
16+
International Commission on Illumination (CIE). doi:10.25039/CIE.DS.7chm7z5h
1517
- :cite:`Ohno2008a` : Ohno, Yoshiro, & Davis, W. (2008). NIST CQS simulation
1618
(Version 7.4) [Computer software].
1719
https://drive.google.com/file/d/1PsuU6QjUJjCX6tQyCud6ul2Tbs8rYWW9/view?\
@@ -31,35 +33,19 @@
3133
__status__ = "Production"
3234

3335
__all__ = [
36+
"APPROXIMATE_MUNSELL_NOTATIONS_TCS_CIE1995",
37+
"INDEXES_TO_NAMES_TCS_CIE1995",
38+
"DATA_TCS_CIE1995",
39+
"SDS_TCS_CIE1995",
40+
"APPROXIMATE_MUNSELL_NOTATIONS_TCS_CIE2024",
41+
"INDEXES_TO_NAMES_TCS_CIE2024",
42+
"DATA_TCS_CIE2024",
43+
"SDS_TCS_CIE2024",
3444
"INDEXES_TO_NAMES_TCS",
35-
"APPROXIMATE_MUNSELL_NOTATIONS_TCS",
36-
"DATA_TCS",
37-
"SDS_TCS_CIE_1995",
38-
"SDS_TCS_CIE_2024",
39-
"SDS_TCS_SETS",
4045
"SDS_TCS",
4146
]
4247

43-
INDEXES_TO_NAMES_TCS: dict = {
44-
1: "TCS01",
45-
2: "TCS02",
46-
3: "TCS03",
47-
4: "TCS04",
48-
5: "TCS05",
49-
6: "TCS06",
50-
7: "TCS07",
51-
8: "TCS08",
52-
9: "TCS09",
53-
10: "TCS10",
54-
11: "TCS11",
55-
12: "TCS12",
56-
13: "TCS13",
57-
14: "TCS14",
58-
15: "TCS15",
59-
}
60-
"""Test colour samples indexes to names mapping."""
61-
62-
APPROXIMATE_MUNSELL_NOTATIONS_TCS: CanonicalMapping = CanonicalMapping(
48+
APPROXIMATE_MUNSELL_NOTATIONS_TCS_CIE1995: CanonicalMapping = CanonicalMapping(
6349
{
6450
"TCS01": "7.5 R 6/4",
6551
"TCS02": "5 Y 6/4",
@@ -78,9 +64,40 @@
7864
"TCS15": "1 YR 6/4",
7965
}
8066
)
81-
"""Test colour samples *Munsell* colour approximations."""
67+
"""
68+
Test colour samples *Munsell* colour approximations for *CIE 1995*
8269
83-
DATA_TCS: dict = {
70+
References
71+
----------
72+
:cite:`Ohno2008a`
73+
"""
74+
75+
76+
INDEXES_TO_NAMES_TCS_CIE1995: dict = {
77+
1: "TCS01",
78+
2: "TCS02",
79+
3: "TCS03",
80+
4: "TCS04",
81+
5: "TCS05",
82+
6: "TCS06",
83+
7: "TCS07",
84+
8: "TCS08",
85+
9: "TCS09",
86+
10: "TCS10",
87+
11: "TCS11",
88+
12: "TCS12",
89+
13: "TCS13",
90+
14: "TCS14",
91+
}
92+
"""
93+
Test colour samples indexes to names mapping for *CIE 1995*
94+
95+
References
96+
----------
97+
:cite:`Ohno2008a`
98+
"""
99+
100+
DATA_TCS_CIE1995: dict = {
84101
"TCS01": {
85102
360: 0.116,
86103
365: 0.136,
@@ -1439,6 +1456,63 @@
14391456
825: 0.451,
14401457
830: 0.454,
14411458
},
1459+
}
1460+
1461+
SDS_TCS_CIE1995: CanonicalMapping = CanonicalMapping(
1462+
{
1463+
key: SpectralDistribution(value, name=key)
1464+
for key, value in DATA_TCS_CIE1995.items()
1465+
}
1466+
)
1467+
"""
1468+
Test colour samples spectral distributions for *CIE 1995*.
1469+
1470+
References
1471+
----------
1472+
:cite:`Ohno2008a`
1473+
"""
1474+
1475+
APPROXIMATE_MUNSELL_NOTATIONS_TCS_CIE2024: CanonicalMapping = CanonicalMapping(
1476+
{
1477+
**APPROXIMATE_MUNSELL_NOTATIONS_TCS_CIE1995,
1478+
"TCS15": "1 YR 6/4",
1479+
}
1480+
)
1481+
"""
1482+
Test colour samples *Munsell* colour approximations for *CIE 2024*
1483+
1484+
References
1485+
----------
1486+
:cite:`CIE2024`
1487+
"""
1488+
1489+
INDEXES_TO_NAMES_TCS_CIE2024: dict = {
1490+
1: "TCS01",
1491+
2: "TCS02",
1492+
3: "TCS03",
1493+
4: "TCS04",
1494+
5: "TCS05",
1495+
6: "TCS06",
1496+
7: "TCS07",
1497+
8: "TCS08",
1498+
9: "TCS09",
1499+
10: "TCS10",
1500+
11: "TCS11",
1501+
12: "TCS12",
1502+
13: "TCS13",
1503+
14: "TCS14",
1504+
15: "TCS15",
1505+
}
1506+
"""
1507+
Test colour samples indexes to names mapping for *CIE 2024*.
1508+
1509+
References
1510+
----------
1511+
:cite:`CIE2024`
1512+
"""
1513+
1514+
DATA_TCS_CIE2024: dict = {
1515+
**DATA_TCS_CIE1995,
14421516
"TCS15": {
14431517
380: 0.131,
14441518
385: 0.139,
@@ -1524,72 +1598,44 @@
15241598
},
15251599
}
15261600

1527-
SDS_TCS_CIE_1995: CanonicalMapping = CanonicalMapping(
1601+
SDS_TCS_CIE2024: CanonicalMapping = CanonicalMapping(
15281602
{
15291603
key: SpectralDistribution(value, name=key)
1530-
for key, value in {
1531-
x: DATA_TCS[x]
1532-
for x in [
1533-
"TCS01",
1534-
"TCS02",
1535-
"TCS03",
1536-
"TCS04",
1537-
"TCS05",
1538-
"TCS06",
1539-
"TCS07",
1540-
"TCS08",
1541-
"TCS09",
1542-
"TCS10",
1543-
"TCS11",
1544-
"TCS12",
1545-
"TCS13",
1546-
"TCS14",
1547-
]
1548-
}.items()
1604+
for key, value in DATA_TCS_CIE2024.items()
15491605
}
15501606
)
1607+
"""
1608+
Test colour samples spectral distributions for *CIE 2024*.
1609+
1610+
References
1611+
----------
1612+
:cite:`CIE2024`
1613+
"""
15511614

1552-
SDS_TCS_CIE_2024: CanonicalMapping = CanonicalMapping(
1615+
INDEXES_TO_NAMES_TCS: CanonicalMapping = CanonicalMapping(
15531616
{
1554-
key: SpectralDistribution(value, name=key)
1555-
for key, value in {
1556-
x: DATA_TCS[x]
1557-
for x in [
1558-
"TCS01",
1559-
"TCS02",
1560-
"TCS03",
1561-
"TCS04",
1562-
"TCS05",
1563-
"TCS06",
1564-
"TCS07",
1565-
"TCS08",
1566-
"TCS09",
1567-
"TCS10",
1568-
"TCS11",
1569-
"TCS12",
1570-
"TCS13",
1571-
"TCS14",
1572-
"TCS15",
1573-
]
1574-
}.items()
1617+
"CIE 1995": INDEXES_TO_NAMES_TCS_CIE1995,
1618+
"CIE 2024": INDEXES_TO_NAMES_TCS_CIE2024,
15751619
}
15761620
)
1621+
"""
1622+
Test colour samples indexes to names mapping for *CIE 1995* and *CIE 2024*.
15771623
1578-
SDS_TCS_SETS: CanonicalMapping = CanonicalMapping(
1624+
References
1625+
----------
1626+
:cite:`CIE2024`, :cite:`Ohno2008a`
1627+
"""
1628+
1629+
SDS_TCS: CanonicalMapping = CanonicalMapping(
15791630
{
1580-
"CIE 1995": SDS_TCS_CIE_1995,
1581-
"CIE 2024": SDS_TCS_CIE_2024,
1631+
"CIE 1995": SDS_TCS_CIE1995,
1632+
"CIE 2024": SDS_TCS_CIE2024,
15821633
}
15831634
)
1584-
1585-
# TODO: deprecate SDS_TCS (was renamed to SDS_TCS_CIE_1995)
1586-
SDS_TCS = SDS_TCS_CIE_1995
1587-
1588-
15891635
"""
1590-
Test colour samples spectral distributions.
1636+
Test colour samples spectral distributions for *CIE 1995* and *CIE 2024*.
15911637
15921638
References
15931639
----------
1594-
:cite:`Ohno2008a`
1640+
:cite:`CIE2024`, :cite:`Ohno2008a`
15951641
"""

colour/quality/tests/test_cri.py

-3
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,11 @@ def test_colour_rendering_index(self) -> None:
358358
atol=TOLERANCE_ABSOLUTE_TESTS,
359359
)
360360

361-
# Drop CIE 2024 results to get CIE 1995 results
362361
specification_r.Q_as.pop(15)
363362
test_col_data = specification_r.colorimetry_data[0][:-1]
364363
ref_col_data = specification_r.colorimetry_data[1][:-1]
365364
specification_r.colorimetry_data = (test_col_data, ref_col_data)
366365

367-
# Test for CIE 1995
368366
specification_t = colour_rendering_index(
369367
SDS_ILLUMINANTS["FL1"], additional_data=True, method="CIE 1995"
370368
)
@@ -375,7 +373,6 @@ def test_colour_rendering_index(self) -> None:
375373
atol=TOLERANCE_ABSOLUTE_TESTS,
376374
)
377375

378-
# If method not defined, then CIE 1995 is used
379376
specification_t = colour_rendering_index(
380377
SDS_ILLUMINANTS["FL1"], additional_data=True
381378
)

0 commit comments

Comments
 (0)