Ejemplo n.º 1
0
    def test_nan_daylight_locus_function(self):
        """
        Tests :func:`colour.colorimetry.illuminants.daylight_locus_function`
        definition nan support.
        """

        cases = [-1.0, 0.0, 1.0, -np.inf, np.inf, np.nan]
        for case in cases:
            daylight_locus_function(case)
Ejemplo n.º 2
0
    def test_daylight_locus_function(self):
        """
        Tests :func:`colour.colorimetry.illuminants.daylight_locus_function`
        definition.
        """

        self.assertAlmostEqual(
            daylight_locus_function(0.31270), 0.329105129999999, places=7)

        self.assertAlmostEqual(
            daylight_locus_function(0.34570), 0.358633529999999, places=7)

        self.assertAlmostEqual(
            daylight_locus_function(0.44758), 0.408571030799999, places=7)
Ejemplo n.º 3
0
    def test_daylight_locus_function(self):
        """
        Tests :func:`colour.colorimetry.illuminants.daylight_locus_function`
        definition.
        """

        self.assertAlmostEqual(daylight_locus_function(0.31270),
                               0.329105129999999,
                               places=7)

        self.assertAlmostEqual(daylight_locus_function(0.34570),
                               0.358633529999999,
                               places=7)

        self.assertAlmostEqual(daylight_locus_function(0.44758),
                               0.408571030799999,
                               places=7)
Ejemplo n.º 4
0
    def test_n_dimensional_daylight_locus_function(self):
        """
        Tests :func:`colour.colorimetry.illuminants.daylight_locus_function`
        definition n-dimensional support.
        """

        x_D = np.array([0.31270])
        y_D = daylight_locus_function(x_D)

        x_D = np.tile(x_D, (6, 1))
        y_D = np.tile(y_D, (6, 1))
        np.testing.assert_almost_equal(
            daylight_locus_function(x_D), y_D, decimal=7)

        x_D = np.reshape(x_D, (2, 3, 1))
        y_D = np.reshape(y_D, (2, 3, 1))
        np.testing.assert_almost_equal(
            daylight_locus_function(x_D), y_D, decimal=7)
Ejemplo n.º 5
0
    def test_n_dimensional_daylight_locus_function(self):
        """
        Tests :func:`colour.colorimetry.illuminants.daylight_locus_function`
        definition n-dimensional support.
        """

        x_D = np.array([0.31270])
        y_D = daylight_locus_function(x_D)

        x_D = np.tile(x_D, (6, 1))
        y_D = np.tile(y_D, (6, 1))
        np.testing.assert_almost_equal(daylight_locus_function(x_D),
                                       y_D,
                                       decimal=7)

        x_D = np.reshape(x_D, (2, 3, 1))
        y_D = np.reshape(y_D, (2, 3, 1))
        np.testing.assert_almost_equal(daylight_locus_function(x_D),
                                       y_D,
                                       decimal=7)
Ejemplo n.º 6
0
def CCT_to_xy_CIE_D(CCT):
    """
    Returns the *CIE xy* chromaticity coordinates of a
    *CIE Illuminant D Series* from its correlated colour temperature
    :math:`T_{cp}`.

    Parameters
    ----------
    CCT : numeric or array_like
        Correlated colour temperature :math:`T_{cp}`.

    Returns
    -------
    ndarray
        *CIE xy* chromaticity coordinates.

    Raises
    ------
    ValueError
        If the correlated colour temperature is not in appropriate domain.

    References
    ----------
    :cite:`Wyszecki2000z`

    Examples
    --------
    >>> CCT_to_xy_CIE_D(6504.38938305)  # doctest: +ELLIPSIS
    array([ 0.3127077...,  0.3291128...])
    """

    CCT = as_float_array(CCT)

    if np.any(CCT[np.asarray(np.logical_or(CCT < 4000, CCT > 25000))]):
        usage_warning(('Correlated colour temperature must be in domain '
                       '[4000, 25000], unpredictable results may occur!'))

    CCT_3 = CCT**3
    CCT_2 = CCT**2

    x = np.where(
        CCT <= 7000,
        -4.607 * 10**9 / CCT_3 + 2.9678 * 10**6 / CCT_2 +
        0.09911 * 10**3 / CCT + 0.244063,
        -2.0064 * 10**9 / CCT_3 + 1.9018 * 10**6 / CCT_2 +
        0.24748 * 10**3 / CCT + 0.23704,
    )

    y = daylight_locus_function(x)

    xy = tstack([x, y])

    return xy
Ejemplo n.º 7
0
def CCT_to_xy_CIE_D(CCT):
    """
    Converts from the correlated colour temperature :math:`T_{cp}` of a
    *CIE Illuminant D Series* to the chromaticity of that
    *CIE Illuminant D Series* illuminant.

    Parameters
    ----------
    CCT : numeric or array_like
        Correlated colour temperature :math:`T_{cp}`.

    Returns
    -------
    ndarray
        *xy* chromaticity coordinates.

    Raises
    ------
    ValueError
        If the correlated colour temperature is not in appropriate domain.

    References
    ----------
    :cite:`Wyszecki2000z`

    Examples
    --------
    >>> CCT_to_xy_CIE_D(6504.38938305)  # doctest: +ELLIPSIS
    array([ 0.3127077...,  0.3291128...])
    """

    CCT = as_float_array(CCT)

    if np.any(CCT[np.asarray(np.logical_or(CCT < 4000, CCT > 25000))]):
        usage_warning(('Correlated colour temperature must be in domain '
                       '[4000, 25000], unpredictable results may occur!'))

    x = np.where(
        CCT <= 7000,
        -4.607 * 10 ** 9 / CCT ** 3 + 2.9678 * 10 ** 6 / CCT ** 2 +
        0.09911 * 10 ** 3 / CCT + 0.244063,
        -2.0064 * 10 ** 9 / CCT ** 3 + 1.9018 * 10 ** 6 / CCT ** 2 +
        0.24748 * 10 ** 3 / CCT + 0.23704,
    )

    y = daylight_locus_function(x)

    xy = tstack([x, y])

    return xy