예제 #1
0
def interpolated_matrix(CCT, CCT_1, CCT_2, M_1, M_2):
    """
    Computes the matrix interpolated from :math:`CCT_1` and :math:`CCT_2`
    correlated colour temperatures to respectively :math:`M_1` and :math:`M_2`
    colour matrices using given correlated colour temperature :math:`CCT`
    interpolation value.

    Parameters
    ----------
    CCT : numeric
        Correlated colour temperature :math:`CCT`.
    CCT_1 : numeric
        Correlated colour temperature :math:`CCT_1`.
    CCT_2 : numeric
        Correlated colour temperature :math:`CCT_2`.
    M_1 : array_like
        :math:`M_1` colour matrix.
    M_2 : array_like
        :math:`M_2` colour matrix.

    Returns
    -------
    ndarray
        Interpolated colour matrix :math:`M_i`.

    Notes
    -----
    -   The computation is performed in mired (MIcro REciprocal Degree,
        reciprocal megakelvin) :math:`MK^{-1}`.

    Examples
    --------
    >>> CCT = 5000
    >>> CCT_1 = 2850
    >>> CCT_2 = 6500
    >>> M_1 = np.array([
    ...     [0.5309, -0.0229, -0.0336],
    ...     [-0.6241, 1.3265, 0.3337],
    ...     [-0.0817, 0.1215, 0.6664]])
    >>> M_2 = np.array([
    ...     [0.4716, 0.0603, -0.0830],
    ...     [-0.7798, 1.5474, 0.2480],
    ...     [-0.1496, 0.1937, 0.6651]])
    >>> interpolated_matrix(CCT, CCT_1, CCT_2, M_1, M_2)  # doctest: +ELLIPSIS
    array([[ 0.4854908...,  0.0408106..., -0.0714282...],
           [-0.7433278...,  1.4956549...,  0.2680749...],
           [-0.1336946...,  0.1767874...,  0.6654045...]])
    """

    if CCT <= CCT_1:
        return M_1
    elif CCT >= CCT_2:
        return M_2
    else:
        return linear_conversion(1e6 / CCT, (1e6 / CCT_1, 1e6 / CCT_2),
                                 tstack((M_1, M_2)))
예제 #2
0
    def test_linear_conversion(self):
        """
        Tests :func:`colour.utilities.array.linear_conversion` definition.
        """

        np.testing.assert_almost_equal(
            linear_conversion(np.linspace(0, 1, 10), np.array([0, 1]),
                              np.array([1, np.pi])),
            np.array([
                1.00000000, 1.23795474, 1.47590948, 1.71386422, 1.95181896,
                2.18977370, 2.42772844, 2.66568318, 2.90363791, 3.14159265
            ]),
            decimal=8)
예제 #3
0
    def test_linear_conversion(self):
        """
        Tests :func:`colour.utilities.array.linear_conversion` definition.
        """

        np.testing.assert_almost_equal(
            linear_conversion(
                np.linspace(0, 1, 10), np.array([0, 1]), np.array([1, np.pi])),
            np.array([
                1.00000000, 1.23795474, 1.47590948, 1.71386422, 1.95181896,
                2.18977370, 2.42772844, 2.66568318, 2.90363791, 3.14159265
            ]),
            decimal=8)