Skip to content

Commit 42e9e0e

Browse files
committed
Merge branch 'feature/cie2024_varnish' into develop
2 parents 114a0d5 + 9d28abe commit 42e9e0e

File tree

12 files changed

+3355
-3725
lines changed

12 files changed

+3355
-3725
lines changed

BIBLIOGRAPHY.bib

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

README.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1802,6 +1802,14 @@ Colour Rendering Index
18021802
18031803
64.233724121664793
18041804
1805+
.. code-block:: python
1806+
1807+
sorted(colour.COLOUR_RENDERING_INDEX_METHODS)
1808+
1809+
.. code-block:: text
1810+
1811+
['CIE 1995', 'CIE 2024']
1812+
18051813
Academy Spectral Similarity Index (SSI)
18061814
***************************************
18071815

colour/__init__.py

+2
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@
443443
from .quality import (
444444
COLOUR_FIDELITY_INDEX_METHODS,
445445
COLOUR_QUALITY_SCALE_METHODS,
446+
COLOUR_RENDERING_INDEX_METHODS,
446447
colour_fidelity_index,
447448
colour_quality_scale,
448449
colour_rendering_index,
@@ -838,6 +839,7 @@
838839
__all__ += [
839840
"COLOUR_FIDELITY_INDEX_METHODS",
840841
"COLOUR_QUALITY_SCALE_METHODS",
842+
"COLOUR_RENDERING_INDEX_METHODS",
841843
"colour_fidelity_index",
842844
"colour_quality_scale",
843845
"colour_rendering_index",

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/__init__.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
ColourRendering_Specification_CIE2017,
1515
colour_fidelity_index_CIE2017,
1616
)
17-
from .cri import ColourRendering_Specification_CRI, colour_rendering_index
17+
from .cri import (
18+
COLOUR_RENDERING_INDEX_METHODS,
19+
ColourRendering_Specification_CRI,
20+
colour_rendering_index,
21+
)
1822
from .cqs import (
1923
COLOUR_QUALITY_SCALE_METHODS,
2024
ColourRendering_Specification_CQS,
@@ -38,6 +42,7 @@
3842
"colour_fidelity_index_ANSIIESTM3018",
3943
]
4044
__all__ += [
45+
"COLOUR_RENDERING_INDEX_METHODS",
4146
"ColourRendering_Specification_CRI",
4247
"colour_rendering_index",
4348
]

colour/quality/cri.py

+43-9
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,8 @@
4242
from colour.models import UCS_to_uv, XYZ_to_UCS, XYZ_to_xyY
4343
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
45-
from colour.utilities import domain_range_scale
45+
from colour.utilities import domain_range_scale, validate_method
46+
from colour.utilities.documentation import DocstringTuple, is_documentation_building
4647

4748
__author__ = "Colour Developers"
4849
__copyright__ = "Copyright 2013 Colour Developers"
@@ -55,6 +56,7 @@
5556
"DataColorimetry_TCS",
5657
"DataColourQualityScale_TCS",
5758
"ColourRendering_Specification_CRI",
59+
"COLOUR_RENDERING_INDEX_METHODS",
5860
"colour_rendering_index",
5961
"tcs_colorimetry_data",
6062
"colour_rendering_indexes",
@@ -110,26 +112,47 @@ class ColourRendering_Specification_CRI:
110112
]
111113

112114

115+
COLOUR_RENDERING_INDEX_METHODS: tuple = ("CIE 1995", "CIE 2024")
116+
if is_documentation_building(): # pragma: no cover
117+
COLOUR_RENDERING_INDEX_METHODS = DocstringTuple(COLOUR_RENDERING_INDEX_METHODS)
118+
COLOUR_RENDERING_INDEX_METHODS.__doc__ = """
119+
Supported *Colour Rendering Index* (CRI) computation methods.
120+
121+
References
122+
----------
123+
:cite:`Ohno2008a`
124+
"""
125+
126+
113127
@typing.overload
114128
def colour_rendering_index(
115-
sd_test: SpectralDistribution, additional_data: Literal[True] = True
129+
sd_test: SpectralDistribution,
130+
additional_data: Literal[True] = True,
131+
method: Literal["CIE 1995", "CIE 2024"] | str = ...,
116132
) -> ColourRendering_Specification_CRI: ...
117133

118134

119135
@typing.overload
120136
def colour_rendering_index(
121-
sd_test: SpectralDistribution, *, additional_data: Literal[False]
137+
sd_test: SpectralDistribution,
138+
*,
139+
additional_data: Literal[False],
140+
method: Literal["CIE 1995", "CIE 2024"] | str = ...,
122141
) -> float: ...
123142

124143

125144
@typing.overload
126145
def colour_rendering_index(
127-
sd_test: SpectralDistribution, additional_data: Literal[False]
146+
sd_test: SpectralDistribution,
147+
additional_data: Literal[False],
148+
method: Literal["CIE 1995", "CIE 2024"] | str = ...,
128149
) -> float: ...
129150

130151

131152
def colour_rendering_index(
132-
sd_test: SpectralDistribution, additional_data: bool = False
153+
sd_test: SpectralDistribution,
154+
additional_data: bool = False,
155+
method: Literal["CIE 1995", "CIE 2024"] | str = "CIE 1995",
133156
) -> float | ColourRendering_Specification_CRI:
134157
"""
135158
Return the *Colour Rendering Index* (CRI) :math:`Q_a` of given spectral
@@ -141,6 +164,8 @@ def colour_rendering_index(
141164
Test spectral distribution.
142165
additional_data
143166
Whether to output additional data.
167+
method
168+
Computation method.
144169
145170
Returns
146171
-------
@@ -160,6 +185,8 @@ def colour_rendering_index(
160185
64.2337241...
161186
"""
162187

188+
method = validate_method(method, tuple(COLOUR_RENDERING_INDEX_METHODS))
189+
163190
cmfs = reshape_msds(
164191
MSDS_CMFS["CIE 1931 2 Degree Standard Observer"],
165192
SPECTRAL_SHAPE_DEFAULT,
@@ -168,7 +195,8 @@ def colour_rendering_index(
168195

169196
shape = cmfs.shape
170197
sd_test = reshape_sd(sd_test, shape, copy=False)
171-
tcs_sds = {sd.name: reshape_sd(sd, shape, copy=False) for sd in SDS_TCS.values()}
198+
sds_tcs = SDS_TCS[method]
199+
tcs_sds = {sd.name: reshape_sd(sd, shape, copy=False) for sd in sds_tcs.values()}
172200

173201
with domain_range_scale("1"):
174202
XYZ = sd_to_XYZ(sd_test, cmfs)
@@ -184,11 +212,11 @@ def colour_rendering_index(
184212
sd_reference.align(shape)
185213

186214
test_tcs_colorimetry_data = tcs_colorimetry_data(
187-
sd_test, sd_reference, tcs_sds, cmfs, chromatic_adaptation=True
215+
sd_test, sd_reference, tcs_sds, cmfs, chromatic_adaptation=True, method=method
188216
)
189217

190218
reference_tcs_colorimetry_data = tcs_colorimetry_data(
191-
sd_reference, sd_reference, tcs_sds, cmfs
219+
sd_reference, sd_reference, tcs_sds, cmfs, method=method
192220
)
193221

194222
Q_as = colour_rendering_indexes(
@@ -217,6 +245,7 @@ def tcs_colorimetry_data(
217245
sds_tcs: Dict[str, SpectralDistribution],
218246
cmfs: MultiSpectralDistributions,
219247
chromatic_adaptation: bool = False,
248+
method: Literal["CIE 1995", "CIE 2024"] | str = "CIE 1995",
220249
) -> Tuple[DataColorimetry_TCS, ...]:
221250
"""
222251
Return the *test colour samples* colorimetry data.
@@ -240,6 +269,8 @@ def tcs_colorimetry_data(
240269
*Test colour samples* colorimetry data.
241270
"""
242271

272+
method = validate_method(method, tuple(COLOUR_RENDERING_INDEX_METHODS))
273+
243274
XYZ_t = sd_to_XYZ(sd_t, cmfs)
244275
uv_t = UCS_to_uv(XYZ_to_UCS(XYZ_t))
245276
u_t, v_t = uv_t[0], uv_t[1]
@@ -249,7 +280,10 @@ def tcs_colorimetry_data(
249280
u_r, v_r = uv_r[0], uv_r[1]
250281

251282
tcs_data = []
252-
for _key, value in sorted(INDEXES_TO_NAMES_TCS.items()):
283+
for _key, value in sorted(INDEXES_TO_NAMES_TCS[method].items()):
284+
if value not in sds_tcs:
285+
continue
286+
253287
sd_tcs = sds_tcs[value]
254288
XYZ_tcs = sd_to_XYZ(sd_tcs, cmfs, sd_t)
255289
xyY_tcs = XYZ_to_xyY(XYZ_tcs)

colour/quality/datasets/__init__.py

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
from .vs import SDS_VS
33

44
__all__ = [
5+
"SDS_TCS",
56
"SDS_TCS",
67
"SDS_VS",
78
]

0 commit comments

Comments
 (0)