# -*- coding: utf-8 -*-
"""
Showcases correlated colour temperature computations.
"""

import colour
from colour.utilities import message_box

message_box('Correlated Colour Temperature Computations')

cmfs = colour.CMFS['CIE 1931 2 Degree Standard Observer']
illuminant = colour.ILLUMINANTS_SDS['D65']
xy = colour.XYZ_to_xy(colour.sd_to_XYZ(illuminant, cmfs) / 100)
uv = colour.UCS_to_uv(colour.XYZ_to_UCS(colour.xy_to_XYZ(xy)))
message_box(('Converting to "CCT" and "D_uv" from given "CIE UCS" colourspace '
             '"uv" chromaticity coordinates using "Ohno (2013)" method:\n'
             '\n\t{0}'.format(uv)))
print(colour.uv_to_CCT(uv, cmfs=cmfs))
print(colour.temperature.uv_to_CCT_Ohno2013(uv, cmfs=cmfs))

print('\n')

message_box('Faster computation with 3 iterations but a lot less precise.')
print(colour.uv_to_CCT(uv, cmfs=cmfs, iterations=3))
print(colour.temperature.uv_to_CCT_Ohno2013(uv, cmfs=cmfs, iterations=3))

print('\n')

message_box(('Converting to "CCT" and "D_uv" from given "CIE UCS" colourspace '
             '"uv" chromaticity coordinates using "Robertson (1968)" method:\n'
             '\n\t{0}'.format(uv)))
print(colour.uv_to_CCT(uv, method='Robertson 1968'))
print(colour.temperature.uv_to_CCT_Robertson1968(uv))

print('\n')

CCT_D_uv = [6503.49254150, 0.00320598]
message_box(('Converting to "CIE UCS" colourspace "uv" chromaticity '
             'coordinates from given "CCT" and "D_uv" using '
             '"Ohno (2013)" method:\n'
             '\n\t{0}'.format(CCT_D_uv)))
print(colour.CCT_to_uv(CCT_D_uv, cmfs=cmfs))
print(colour.temperature.CCT_to_uv_Ohno2013(CCT_D_uv, cmfs=cmfs))

print('\n')

message_box(('Converting to "CIE UCS" colourspace "uv" chromaticity '
             'coordinates from given "CCT" and "D_uv" using '
             '"Robertson (1968)" method:\n'
             '\n\t{0}'.format(CCT_D_uv)))
print(colour.CCT_to_uv(CCT_D_uv, method='Robertson 1968'))
print(colour.temperature.CCT_to_uv_Robertson1968(CCT_D_uv))

print('\n')

CCT = 6503.49254150
message_box(('Converting to "CIE UCS" colourspace "uv" chromaticity '
             'coordinates from given "CCT" using "Krystek (1985)" method:\n'
             '\n\t({0})'.format(CCT)))
print(colour.CCT_to_uv(CCT, method='Krystek 1985'))
print(colour.temperature.CCT_to_uv_Krystek1985(CCT))

print('\n')

xy = colour.ILLUMINANTS['CIE 1931 2 Degree Standard Observer']['D65']
message_box(('Converting to "CCT" from given "xy" chromaticity coordinates '
             'using "McCamy (1992)" method:\n'
             '\n\t{0}'.format(xy)))
print(colour.xy_to_CCT(xy, method='McCamy 1992'))
print(colour.temperature.xy_to_CCT_McCamy1992(xy))

print('\n')

message_box(('Converting to "CCT" from given "xy" chromaticity coordinates '
             'using "Hernandez-Andres, Lee and Romero (1999)" method:\n'
             '\n\t{0}'.format(xy)))
print(colour.xy_to_CCT(xy, method='Hernandez 1999'))
print(colour.temperature.xy_to_CCT_Hernandez1999(xy))

print('\n')

CCT = 6503.49254150
message_box(('Converting to "xy" chromaticity coordinates from given "CCT" '
             'using "Kang, Moon, Hong, Lee, Cho and Kim (2002)" method:\n'
             '\n\t{0}'.format(CCT)))
print(colour.CCT_to_xy(CCT, method='Kang 2002'))
print(colour.temperature.CCT_to_xy_Kang2002(CCT))

print('\n')

message_box(('Converting to "xy" chromaticity coordinates from given "CCT" '
             'using "CIE Illuminant D Series" method:\n'
             '\n\t{0}'.format(CCT)))
print(colour.CCT_to_xy(CCT, method='CIE Illuminant D Series'))
print(colour.temperature.CCT_to_xy_CIE_D(CCT))

@@ -2422,32 +2422,36 @@
 CT%22 from given %22
+CIE 
 xy%22 chromaticity
@@ -2447,36 +2447,24 @@
 hromaticity 
-coordinates 
 '%0A          
@@ -2463,24 +2463,36 @@
            '
+coordinates 
 using %22McCam
@@ -2709,16 +2709,20 @@
  given %22
+CIE 
 xy%22 chro
@@ -2730,28 +2730,16 @@
 aticity 
-coordinates 
 '%0A      
@@ -2742,24 +2742,36 @@
            '
+coordinates 
 using %22Herna
@@ -2806,16 +2806,32 @@
 (1999)%22 
+'%0A             '
 method:%5C
@@ -3031,32 +3031,36 @@
 'Converting to %22
+CIE 
 xy%22 chromaticity
@@ -3074,38 +3074,32 @@
 nates from given
- %22CCT%22
  '%0A             
@@ -3095,24 +3095,30 @@
            '
+%22CCT%22 
 using %22Kang,
@@ -3151,24 +3151,40 @@
 Kim (2002)%22 
+'%0A             '
 method:%5Cn'%0A 
@@ -3361,16 +3361,20 @@
 ing to %22
+CIE 
 xy%22 chro
@@ -3404,22 +3404,16 @@
 om given
- %22CCT%22
  '%0A     
@@ -3421,16 +3421,22 @@
        '
+%22CCT%22 
 using %22C

Update "examples_cct.py" example module.