colour.sd_to_XYZ#

colour.sd_to_XYZ(sd: ArrayLike | SpectralDistribution | MultiSpectralDistributions, cmfs: MultiSpectralDistributions | None = None, illuminant: SpectralDistribution | None = None, k: Real | None = None, method: Literal['ASTM E308', 'Integration'] | str = 'ASTM E308', **kwargs: Any) NDArrayFloat[source]#

Convert given spectral distribution to CIE XYZ tristimulus values using given colour matching functions, illuminant and method.

If method is Integration, the spectral distribution can be either a colour.SpectralDistribution class instance or an ArrayLike in which case the shape must be passed.

Parameters:
  • sd (ArrayLike | SpectralDistribution | MultiSpectralDistributions) – Spectral distribution, if an ArrayLike and method is Integration the wavelengths are expected to be in the last axis, e.g. for a spectral array with 77 bins, sd shape could be (77, ) or (1, 77).

  • cmfs (MultiSpectralDistributions | None) – Standard observer colour matching functions, default to the CIE 1931 2 Degree Standard Observer.

  • illuminant (SpectralDistribution | None) – Illuminant spectral distribution, default to CIE Illuminant E.

  • k (Real | None) – Normalisation constant \(k\). For reflecting or transmitting object colours, \(k\) is chosen so that \(Y = 100\) for objects for which the spectral reflectance factor \(R(\lambda)\) of the object colour or the spectral transmittance factor \(\tau(\lambda)\) of the object is equal to unity for all wavelengths. For self-luminous objects and illuminants, the constants \(k\) is usually chosen on the grounds of convenience. If, however, in the CIE 1931 standard colorimetric system, the \(Y\) value is required to be numerically equal to the absolute value of a photometric quantity, the constant, \(k\), must be put equal to the numerical value of \(K_m\), the maximum spectral luminous efficacy (which is equal to 683 \(lm\cdot W^{-1}\)) and \(\Phi_\lambda(\lambda)\) must be the spectral concentration of the radiometric quantity corresponding to the photometric quantity required.

  • method (Literal['ASTM E308', 'Integration'] | str) – Computation method.

  • mi_5nm_omission_method – {colour.colorimetry.sd_to_XYZ_ASTME308()}, 5 nm measurement intervals spectral distribution conversion to tristimulus values will use a 5 nm version of the colour matching functions instead of a table of tristimulus weighting factors.

  • mi_20nm_interpolation_method – {colour.colorimetry.sd_to_XYZ_ASTME308()}, 20 nm measurement intervals spectral distribution conversion to tristimulus values will use a dedicated interpolation method instead of a table of tristimulus weighting factors.

  • shape – {colour.colorimetry.sd_to_XYZ_integration()}, Spectral shape that sd, cmfs and illuminant will be aligned to it if passed.

  • use_practice_range – {colour.colorimetry.sd_to_XYZ_ASTME308()}, Practise ASTM E308-15 working wavelengths range is [360, 780], if True this argument will trim the colour matching functions appropriately.

  • kwargs (Any) –

Returns:

CIE XYZ tristimulus values.

Return type:

numpy.ndarray

Notes

Range

Scale - Reference

Scale - 1

XYZ

[0, 100]

[0, 1]

  • When \(k\) is set to a value other than None, the computed CIE XYZ tristimulus values are assumed to be absolute and are thus converted from percentages by a final division by 100.

  • The code path using the ArrayLike spectral distribution produces results different to the code path using a colour.SpectralDistribution class instance: the former favours execution speed by aligning the colour matching functions and illuminant to the given spectral shape while the latter favours precision by aligning the spectral distribution to the colour matching functions.

References

[ASTMInternational11], [ASTMInternational15a], [WS00c]

Examples

>>> from colour import MSDS_CMFS, SDS_ILLUMINANTS
>>> cmfs = MSDS_CMFS["CIE 1931 2 Degree Standard Observer"]
>>> illuminant = SDS_ILLUMINANTS["D65"]
>>> shape = SpectralShape(400, 700, 20)
>>> data = np.array(
...     [
...         0.0641,
...         0.0645,
...         0.0562,
...         0.0537,
...         0.0559,
...         0.0651,
...         0.0705,
...         0.0772,
...         0.0870,
...         0.1128,
...         0.1360,
...         0.1511,
...         0.1688,
...         0.1996,
...         0.2397,
...         0.2852,
...     ]
... )
>>> sd = SpectralDistribution(data, shape)
>>> sd_to_XYZ(sd, cmfs, illuminant)
... 
array([ 10.8401953...,   9.6841740...,   6.2158913...])
>>> sd_to_XYZ(sd, cmfs, illuminant, use_practice_range=False)
... 
array([ 10.8402774...,   9.6841967...,   6.2158838...])
>>> sd_to_XYZ(sd, cmfs, illuminant, method="Integration")
... 
array([ 10.8404805...,   9.6838697...,   6.2115722...])
>>> sd_to_XYZ(data, cmfs, illuminant, method="Integration", shape=shape)
... 
array([ 10.8993917...,   9.6986145...,   6.2540301...])

The default CMFS are the CIE 1931 2 Degree Standard Observer, and the default illuminant is CIE Illuminant E:

>>> sd_to_XYZ(sd)
... 
array([ 11.7781589...,   9.9585580...,   5.7408602...])