42
42
from colour .models import UCS_to_uv , XYZ_to_UCS , XYZ_to_xyY
43
43
from colour .quality .datasets .tcs import INDEXES_TO_NAMES_TCS , SDS_TCS
44
44
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
46
47
47
48
__author__ = "Colour Developers"
48
49
__copyright__ = "Copyright 2013 Colour Developers"
55
56
"DataColorimetry_TCS" ,
56
57
"DataColourQualityScale_TCS" ,
57
58
"ColourRendering_Specification_CRI" ,
59
+ "COLOUR_RENDERING_INDEX_METHODS" ,
58
60
"colour_rendering_index" ,
59
61
"tcs_colorimetry_data" ,
60
62
"colour_rendering_indexes" ,
@@ -110,26 +112,47 @@ class ColourRendering_Specification_CRI:
110
112
]
111
113
112
114
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
+
113
127
@typing .overload
114
128
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 = ...,
116
132
) -> ColourRendering_Specification_CRI : ...
117
133
118
134
119
135
@typing .overload
120
136
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 = ...,
122
141
) -> float : ...
123
142
124
143
125
144
@typing .overload
126
145
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 = ...,
128
149
) -> float : ...
129
150
130
151
131
152
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" ,
133
156
) -> float | ColourRendering_Specification_CRI :
134
157
"""
135
158
Return the *Colour Rendering Index* (CRI) :math:`Q_a` of given spectral
@@ -141,6 +164,8 @@ def colour_rendering_index(
141
164
Test spectral distribution.
142
165
additional_data
143
166
Whether to output additional data.
167
+ method
168
+ Computation method.
144
169
145
170
Returns
146
171
-------
@@ -160,6 +185,8 @@ def colour_rendering_index(
160
185
64.2337241...
161
186
"""
162
187
188
+ method = validate_method (method , tuple (COLOUR_RENDERING_INDEX_METHODS ))
189
+
163
190
cmfs = reshape_msds (
164
191
MSDS_CMFS ["CIE 1931 2 Degree Standard Observer" ],
165
192
SPECTRAL_SHAPE_DEFAULT ,
@@ -168,7 +195,8 @@ def colour_rendering_index(
168
195
169
196
shape = cmfs .shape
170
197
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 ()}
172
200
173
201
with domain_range_scale ("1" ):
174
202
XYZ = sd_to_XYZ (sd_test , cmfs )
@@ -184,11 +212,11 @@ def colour_rendering_index(
184
212
sd_reference .align (shape )
185
213
186
214
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
188
216
)
189
217
190
218
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
192
220
)
193
221
194
222
Q_as = colour_rendering_indexes (
@@ -217,6 +245,7 @@ def tcs_colorimetry_data(
217
245
sds_tcs : Dict [str , SpectralDistribution ],
218
246
cmfs : MultiSpectralDistributions ,
219
247
chromatic_adaptation : bool = False ,
248
+ method : Literal ["CIE 1995" , "CIE 2024" ] | str = "CIE 1995" ,
220
249
) -> Tuple [DataColorimetry_TCS , ...]:
221
250
"""
222
251
Return the *test colour samples* colorimetry data.
@@ -240,6 +269,8 @@ def tcs_colorimetry_data(
240
269
*Test colour samples* colorimetry data.
241
270
"""
242
271
272
+ method = validate_method (method , tuple (COLOUR_RENDERING_INDEX_METHODS ))
273
+
243
274
XYZ_t = sd_to_XYZ (sd_t , cmfs )
244
275
uv_t = UCS_to_uv (XYZ_to_UCS (XYZ_t ))
245
276
u_t , v_t = uv_t [0 ], uv_t [1 ]
@@ -249,7 +280,10 @@ def tcs_colorimetry_data(
249
280
u_r , v_r = uv_r [0 ], uv_r [1 ]
250
281
251
282
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
+
253
287
sd_tcs = sds_tcs [value ]
254
288
XYZ_tcs = sd_to_XYZ (sd_tcs , cmfs , sd_t )
255
289
xyY_tcs = XYZ_to_xyY (XYZ_tcs )
0 commit comments