Ejemplo n.º 1
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Showcases correlated colour temperature computations.
"""

import colour
from colour.utilities.verbose import message_box

message_box('Correlated Colour Temperature Computations')

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

print('\n')

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

print('\n')

message_box(('Converting to "CCT" and "Duv" from given "CIE UCS" colourspace '
Ejemplo n.º 2
0
    750: 0.436,
    755: 0.450,
    760: 0.462,
    765: 0.465,
    770: 0.448,
    775: 0.432,
    780: 0.421}

spd = colour.SpectralPowerDistribution('Sample', sample_spd_data)

cmfs = colour.CMFS['CIE 1931 2 Degree Standard Observer']
illuminant = colour.ILLUMINANTS_RELATIVE_SPDS['A']

message_box(('Computing *CIE XYZ* tristimulus values for sample spectral '
             'power distribution and "CIE Standard Illuminant A".'))
print(colour.spectral_to_XYZ(spd, cmfs, illuminant))

print('\n')

message_box(('Computing "CIE Standard Illuminant A" chromaticity coordinates '
             'from its relative spectral power distribution.'))
print(colour.XYZ_to_xy(colour.spectral_to_XYZ(illuminant, cmfs)))

print('\n')

message_box(('Computing *CIE XYZ* tristimulus values for a single given '
             'wavelength in nm.'))
print(colour.wavelength_to_XYZ(
    546.1,
    colour.CMFS['CIE 1931 2 Degree Standard Observer']))
Ejemplo n.º 3
0
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
Showcases blackbody / planckian radiator computations.
"""

from __future__ import division, unicode_literals

import colour
from colour.utilities.verbose import message_box

message_box('Blackbody / Planckian Radiator Computations')

message_box(('Computing the spectral radiance of a blackbody at wavelength '
            '500 nm and temperature 5500 kelvin degrees.'))
print(colour.planck_law(500 * 1e-9, 5500))

print('\n')

message_box(('Computing the spectral power distribution of a blackbody at '
            'temperature 5500 kelvin degrees and converting to "CIE XYZ" '
            'tristimulus values.'))
cmfs = colour.STANDARD_OBSERVERS_CMFS.get(
    'CIE 1931 2 Degree Standard Observer')
blackbody_spd = colour.blackbody_spd(5500, cmfs.shape)
print(blackbody_spd)
XYZ = colour.spectral_to_XYZ(blackbody_spd, cmfs)
print(XYZ)
Ejemplo n.º 4
0
 def post(self):
     data = request.json
     data = dict(zip(data['wavelengths'], data['values']))
     spd = SpectralPowerDistribution('spd', data)
     cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
     return spectral_to_XYZ(spd, cmfs).tolist()