colour.dominant_wavelength

colour.dominant_wavelength(xy, xy_n, cmfs=XYZ_ColourMatchingFunctions(name='CIE 1931 2 Degree Standard Observer', ...), inverse=False)[source]

Returns the dominant wavelength \(\lambda_d\) for given colour stimulus \(xy\) and the related \(xy_wl\) first and \(xy_{cw}\) second intersection coordinates with the spectral locus.

In the eventuality where the \(xy_wl\) first intersection coordinates are on the line of purples, the complementary wavelength will be computed in lieu.

The complementary wavelength is indicated by a negative sign and the \(xy_{cw}\) second intersection coordinates which are set by default to the same value than \(xy_wl\) first intersection coordinates will be set to the complementary dominant wavelength intersection coordinates with the spectral locus.

Parameters:
  • xy (array_like) – Colour stimulus CIE xy chromaticity coordinates.
  • xy_n (array_like) – Achromatic stimulus CIE xy chromaticity coordinates.
  • cmfs (XYZ_ColourMatchingFunctions, optional) – Standard observer colour matching functions.
  • inverse (bool, optional) – Inverse the computation direction to retrieve the complementary wavelength.
Returns:

Dominant wavelength, first intersection point CIE xy chromaticity coordinates, second intersection point CIE xy chromaticity coordinates.

Return type:

tuple

References

[CIETC1-482004o], [Erdogana]

Examples

Dominant wavelength computation:

>>> from pprint import pprint
>>> xy = np.array([0.54369557, 0.32107944])
>>> xy_n = np.array([0.31270000, 0.32900000])
>>> cmfs = CMFS['CIE 1931 2 Degree Standard Observer']
>>> pprint(dominant_wavelength(xy, xy_n, cmfs))  # doctest: +ELLIPSIS
(array(616...),
 array([ 0.6835474...,  0.3162840...]),
 array([ 0.6835474...,  0.3162840...]))

Complementary dominant wavelength is returned if the first intersection is located on the line of purples:

>>> xy = np.array([0.37605506, 0.24452225])
>>> pprint(dominant_wavelength(xy, xy_n, cmfs))  # doctest: +ELLIPSIS
(array(-509.0),
 array([ 0.4572314...,  0.1362814...]),
 array([ 0.0104096...,  0.7320745...]))