コード例 #1
0
ファイル: tests_common.py プロジェクト: canavandl/colour
    def test_closest(self):
        """
        Tests :func:`colour.algebra.common.closest` definition.
        """

        y = np.array([
            24.31357115, 63.62396289, 55.71528816, 62.70988028, 46.84480573,
            25.40026416
        ])

        self.assertEqual(closest(y, 63.05), 62.70988028)
        self.assertEqual(closest(y, 24.90), 25.40026416)
        self.assertEqual(closest(y, 51.15), 46.84480573)
コード例 #2
0
ファイル: tests_common.py プロジェクト: KevinJW/colour
    def test_closest(self):
        """
        Tests :func:`colour.algebra.common.closest` definition.
        """

        y = np.array(
            [24.31357115,
             63.62396289,
             55.71528816,
             62.70988028,
             46.84480573,
             25.40026416])

        self.assertEqual(closest(y, 63.05), 62.70988028)
        self.assertEqual(closest(y, 24.90), 25.40026416)
        self.assertEqual(closest(y, 51.15), 46.84480573)
コード例 #3
0
ファイル: lefs.py プロジェクト: aforsythe/colour
def mesopic_weighting_function(wavelength,
                               Lp,
                               source='Blue Heavy',
                               method='MOVE',
                               photopic_lef=PHOTOPIC_LEFS.get(
                                   'CIE 1924 Photopic Standard Observer'),
                               scotopic_lef=SCOTOPIC_LEFS.get(
                                   'CIE 1951 Scotopic Standard Observer')):
    """
    Calculates the mesopic weighting function factor at given wavelength
    :math:`\lambda` using the photopic luminance :math:`L_p`.

    Parameters
    ----------
    wavelength : numeric
        Wavelength :math:`\lambda` to calculate the mesopic weighting function
        factor.
    Lp : numeric
        Photopic luminance :math:`L_p`.
    source : unicode, optional
        {'Blue Heavy', 'Red Heavy'},
        Light source colour temperature.
    method : unicode, optional
        {'MOVE', 'LRC'},
        Method to calculate the weighting factor.
    photopic_lef : SpectralPowerDistribution, optional
        :math:`V(\lambda)` photopic luminous efficiency function.
    scotopic_lef : SpectralPowerDistribution, optional
        :math:`V^\prime(\lambda)` scotopic luminous efficiency function.

    Returns
    -------
    numeric
        Mesopic weighting function factor.

    Raises
    ------
    KeyError
        If wavelength :math:`\lambda` is not available in either luminous
        efficiency function.

    Examples
    --------
    >>> mesopic_weighting_function(500, 0.2)  # doctest: +ELLIPSIS
    0.7052200...
    """

    for function in (photopic_lef, scotopic_lef):
        if function.get(wavelength) is None:
            raise KeyError(
                ('"{0} nm" wavelength not available in "{1}" '
                 'luminous efficiency function with "{2}" shape!').format(
                    wavelength, function.name, function.shape))

    mesopic_x_luminance_values = sorted(MESOPIC_X_DATA.keys())
    index = mesopic_x_luminance_values.index(
        closest(mesopic_x_luminance_values, Lp))
    x = MESOPIC_X_DATA.get(
        mesopic_x_luminance_values[index]).get(source).get(method)

    Vm = ((1 - x) *
          scotopic_lef.get(wavelength) + x * photopic_lef.get(wavelength))

    return Vm
コード例 #4
0
ファイル: lefs.py プロジェクト: canavandl/colour
def mesopic_weighting_function(
    wavelength,
    Lp,
    source='Blue Heavy',
    method='MOVE',
    photopic_lef=PHOTOPIC_LEFS.get('CIE 1924 Photopic Standard Observer'),
    scotopic_lef=SCOTOPIC_LEFS.get('CIE 1951 Scotopic Standard Observer')):
    """
    Calculates the mesopic weighting function factor at given wavelength
    :math:`\lambda` using the photopic luminance :math:`L_p`.

    Parameters
    ----------
    wavelength : numeric
        Wavelength :math:`\lambda` to calculate the mesopic weighting function
        factor.
    Lp : numeric
        Photopic luminance :math:`L_p`.
    source : unicode
        ('Blue Heavy', 'Red Heavy'),
        Light source colour temperature.
    method : unicode
        ('MOVE', 'LRC'),
        Method to calculate the weighting factor.
    photopic_lef : SpectralPowerDistribution
        :math:`V(\lambda)` photopic luminous efficiency function.
    scotopic_lef : SpectralPowerDistribution
        :math:`V^\prime(\lambda)` scotopic luminous efficiency function.

    Returns
    -------
    numeric
        Mesopic weighting function factor.

    Raises
    ------
    KeyError
        If wavelength :math:`\lambda` is not available in either luminous
        efficiency function.

    Examples
    --------
    >>> mesopic_weighting_function(500, 0.2)  # doctest: +ELLIPSIS
    0.7052200...
    """

    for function in (photopic_lef, scotopic_lef):
        if function.get(wavelength) is None:
            raise KeyError(
                ('"{0} nm" wavelength not available in "{1}" '
                 'luminous efficiency function with "{2}" shape!').format(
                     wavelength, function.name, function.shape))

    mesopic_x_luminance_values = sorted(MESOPIC_X_DATA.keys())
    index = mesopic_x_luminance_values.index(
        closest(mesopic_x_luminance_values, Lp))
    x = MESOPIC_X_DATA.get(
        mesopic_x_luminance_values[index]).get(source).get(method)

    Vm = ((1 - x) * scotopic_lef.get(wavelength) +
          x * photopic_lef.get(wavelength))

    return Vm