示例#1
0
文件: lefs.py 项目: aforsythe/colour
def mesopic_luminous_efficiency_function(
        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')):
    """
    Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for
    given photopic luminance :math:`L_p`.

    Parameters
    ----------
    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
    -------
    SpectralPowerDistribution
        Mesopic luminous efficiency function :math:`V_m(\lambda)`.

    Examples
    --------
    >>> mesopic_luminous_efficiency_function(0.2)  # doctest: +ELLIPSIS
    <colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
    """

    photopic_lef_shape = photopic_lef.shape
    scotopic_lef_shape = scotopic_lef.shape
    shape = SpectralShape(
        max(photopic_lef_shape.start, scotopic_lef_shape.start),
        min(photopic_lef_shape.end, scotopic_lef_shape.end),
        max(photopic_lef_shape.steps, scotopic_lef_shape.steps))

    spd_data = dict((i,
                     mesopic_weighting_function(
                         i,
                         Lp,
                         source,
                         method,
                         photopic_lef,
                         scotopic_lef))
                    for i in shape)

    spd = SpectralPowerDistribution(
        '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp),
        spd_data)

    return spd.normalise()
示例#2
0
文件: lefs.py 项目: crowsonkb/colour
def mesopic_luminous_efficiency_function(
        Lp,
        source='Blue Heavy',
        method='MOVE',
        photopic_lef=PHOTOPIC_LEFS['CIE 1924 Photopic Standard Observer'],
        scotopic_lef=SCOTOPIC_LEFS['CIE 1951 Scotopic Standard Observer']):
    """
    Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for
    given photopic luminance :math:`L_p`.

    Parameters
    ----------
    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
    -------
    SpectralPowerDistribution
        Mesopic luminous efficiency function :math:`V_m(\lambda)`.

    Examples
    --------
    >>> print(mesopic_luminous_efficiency_function(0.2))
    SpectralPowerDistribution(\
'0.2 Lp Mesopic Luminous Efficiency Function', (380.0, 780.0, 1.0))
    """

    photopic_lef_shape = photopic_lef.shape
    scotopic_lef_shape = scotopic_lef.shape
    shape = SpectralShape(
        max(photopic_lef_shape.start, scotopic_lef_shape.start),
        min(photopic_lef_shape.end, scotopic_lef_shape.end),
        max(photopic_lef_shape.interval, scotopic_lef_shape.interval))

    wavelengths = shape.range()

    spd_data = dict(
        zip(
            wavelengths,
            mesopic_weighting_function(wavelengths, Lp, source, method,
                                       photopic_lef, scotopic_lef)))

    spd = SpectralPowerDistribution(
        '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp), spd_data)

    return spd.normalise()
示例#3
0
文件: lefs.py 项目: canavandl/colour
def mesopic_luminous_efficiency_function(
    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')):
    """
    Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for
    given photopic luminance :math:`L_p`.

    Parameters
    ----------
    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
    -------
    SpectralPowerDistribution
        Mesopic luminous efficiency function :math:`V_m(\lambda)`.

    Examples
    --------
    >>> mesopic_luminous_efficiency_function(0.2)  # doctest: +ELLIPSIS
    <colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
    """

    photopic_lef_shape = photopic_lef.shape
    scotopic_lef_shape = scotopic_lef.shape
    shape = SpectralShape(
        max(photopic_lef_shape.start, scotopic_lef_shape.start),
        min(photopic_lef_shape.end, scotopic_lef_shape.end),
        max(photopic_lef_shape.steps, scotopic_lef_shape.steps))

    spd_data = dict((i,
                     mesopic_weighting_function(i, Lp, source, method,
                                                photopic_lef, scotopic_lef))
                    for i in shape)

    spd = SpectralPowerDistribution(
        '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp), spd_data)

    return spd.normalise()
示例#4
0
    def test_read(self, spd=None):
        """
        Tests :attr:`colour.io.iestm2714.IES_TM2714_Spd.read` method.

        Parameters
        ----------
        spd : IES_TM2714_Spd, optional
            Optional *IES TM-27-14* spectral power distribution for read tests.
        """

        if spd is None:
            spd = IES_TM2714_Spd(
                os.path.join(RESOURCES_DIRECTORY, 'Fluorescent.spdx'))

        self.assertTrue(spd.read())

        spd_r = SpectralPowerDistribution(FLUORESCENT_FILE_SPECTRAL_DATA)

        np.testing.assert_array_equal(spd_r.domain, spd.domain)
        np.testing.assert_almost_equal(spd_r.values, spd.values, decimal=7)

        for test, read in ((FLUORESCENT_FILE_HEADER, spd.header),
                           (FLUORESCENT_FILE_SPECTRAL_DESCRIPTION, spd)):
            for key, value in test.items():
                for specification in read.mapping.elements:
                    if key == specification.element:
                        self.assertEquals(
                            getattr(read, specification.attribute), value)
示例#5
0
def rayleigh_scattering_spd(shape=DEFAULT_SPECTRAL_SHAPE,
                            CO2_concentration=STANDARD_CO2_CONCENTRATION,
                            temperature=STANDARD_AIR_TEMPERATURE,
                            pressure=AVERAGE_PRESSURE_MEAN_SEA_LEVEL,
                            latitude=DEFAULT_LATITUDE,
                            altitude=DEFAULT_ALTITUDE,
                            avogadro_constant=AVOGADRO_CONSTANT,
                            n_s=air_refraction_index_Bodhaine1999,
                            F_air=F_air_Bodhaine1999):
    """
    Returns the *Rayleigh* spectral power distribution for given spectral
    shape.

    Parameters
    ----------
    shape : SpectralShape, optional
        Spectral shape used to create the *Rayleigh* scattering spectral power
        distribution.
    CO2_concentration : numeric or array_like, optional
        :math:`CO_2` concentration in parts per million (ppm).
    temperature : numeric or array_like, optional
        Air temperature :math:`T[K]` in kelvin degrees.
    pressure : numeric or array_like
        Surface pressure :math:`P` of the measurement site.
    latitude : numeric or array_like, optional
        Latitude of the site in degrees.
    altitude : numeric or array_like, optional
        Altitude of the site in meters.
    avogadro_constant : numeric or array_like, optional
        *Avogadro*'s number (molecules :math:`mol^{-1}`).
    n_s : object
        Air refraction index :math:`n_s` computation method.
    F_air : object
        :math:`(6+3_p)/(6-7_p)`, the depolarisation term :math:`F(air)` or
        *King Factor* computation method.

    Returns
    -------
    SpectralPowerDistribution
        *Rayleigh* optical depth spectral power distribution.

    Examples
    --------
    >>> print(rayleigh_scattering_spd())
    SpectralPowerDistribution('Rayleigh Scattering - 300 ppm, 288.15 K, \
101325 Pa, 0 Degrees, 0 m', (360.0, 780.0, 1.0))
    """

    wavelengths = shape.range()
    return SpectralPowerDistribution(
        name=('Rayleigh Scattering - {0} ppm, {1} K, {2} Pa, {3} Degrees, '
              '{4} m').format(CO2_concentration, temperature, pressure,
                              latitude, altitude),
        data=dict(
            zip(
                wavelengths,
                rayleigh_optical_depth(wavelengths * 10e-8, CO2_concentration,
                                       temperature, pressure, latitude,
                                       altitude, avogadro_constant, n_s,
                                       F_air))))
示例#6
0
    def setUp(self):
        """
        Initialises common tests attributes.
        """

        self._spd = SAMPLE_SPD.copy()
        self._cmfs = CMFS['CIE 1931 2 Degree Standard Observer']
        wl = self._cmfs.shape.range()
        self._A = SpectralPowerDistribution(dict(
            zip(wl, CIE_standard_illuminant_A_function(wl))),
                                            name='A (360, 830, 1)')
示例#7
0
    def test_D_illuminant_relative_spd(self):
        """
        Tests :func:`colour.colorimetry.illuminants.D_illuminant_relative_spd`
        definition.
        """

        spd_r = SpectralPowerDistribution(D60_SPD_DATA)
        spd_t = D_illuminant_relative_spd(np.array([0.32168, 0.33767]))

        np.testing.assert_array_equal(spd_r.domain, spd_t.domain)
        np.testing.assert_almost_equal(spd_r.values, spd_t.values, decimal=7)
示例#8
0
    def test_bandpass_correction_Stearns1988(self):
        """
        Tests :func:`colour.colorimetry.correction.\
bandpass_correction_Stearns1988` definition.
        """

        spd = SpectralPowerDistribution(
            'Spd', dict(zip(range(len(SPD_DATA)), SPD_DATA)))

        np.testing.assert_almost_equal(
            bandpass_correction_Stearns1988(spd).values,
            BANDPASS_CORRECTED_STEARNS_SPD_DATA)
示例#9
0
def blackbody_spd(temperature,
                  shape=DEFAULT_SPECTRAL_SHAPE,
                  c1=C1,
                  c2=C2,
                  n=N):
    """
    Returns the spectral power distribution of the planckian radiator for given
    temperature :math:`T[K]`.

    Parameters
    ----------
    temperature : numeric
        Temperature :math:`T[K]` in kelvin degrees.
    shape : SpectralShape, optional
        Spectral shape used to create the spectral power distribution of the
        planckian radiator.
    c1 : numeric, optional
        The official value of :math:`c1` is provided by the Committee on Data
        for Science and Technology (CODATA), and is
        :math:`c1=3,741771x10.16\ W/m_2` (Mohr and Taylor, 2000).
    c2 : numeric, optional
        Since :math:`T` is measured on the International Temperature Scale,
        the value of :math:`c2` used in colorimetry should follow that adopted
        in the current International Temperature Scale (ITS-90)
        (Preston-Thomas, 1990; Mielenz et aI., 1991), namely
        :math:`c2=1,4388x10.2\ m/K`.
    n : numeric, optional
        Medium index of refraction. For dry air at 15°C and 101 325 Pa,
        containing 0,03 percent by volume of carbon dioxide, it is
        approximately 1,00028 throughout the visible region although
        CIE 15:2004 recommends using :math:`n=1`.

    Returns
    -------
    SpectralPowerDistribution
        Blackbody spectral power distribution.

    Examples
    --------
    >>> from colour import STANDARD_OBSERVERS_CMFS
    >>> cmfs = STANDARD_OBSERVERS_CMFS.get(
    ...     'CIE 1931 2 Degree Standard Observer')
    >>> print(blackbody_spd(5000, cmfs.shape))
    SpectralPowerDistribution('5000K Blackbody', (360.0, 830.0, 1.0))
    """

    wavelengths = shape.range()
    return SpectralPowerDistribution(
        name='{0}K Blackbody'.format(temperature),
        data=dict(
            zip(wavelengths,
                planck_law(wavelengths * 1e-9, temperature, c1, c2, n))))
示例#10
0
    def test_read_spds_from_csv_file(self):
        """
        Tests :func:`colour.io.tabular.read_spds_from_csv_file` definition.
        """

        colorchecker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                           'colorchecker_n_ohta.csv')
        spds = read_spds_from_csv_file(colorchecker_n_ohta)
        for spd in spds.values():
            self.assertIsInstance(spd, SpectralPowerDistribution)

        self.assertEqual(spds['1'],
                         SpectralPowerDistribution('1', COLORCHECKER_N_OHTA_1))
示例#11
0
    def test_read_spds_from_xrite_file(self):
        """
        Tests :func:`colour.io.xrite.read_spds_from_xrite_file` definition.
        """

        colour_checker_xrite = os.path.join(
            RESOURCES_DIRECTORY, 'xrite_digital_colour_checker.txt')
        spds = read_spds_from_xrite_file(colour_checker_xrite)
        for spd in spds.values():
            self.assertIsInstance(spd, SpectralPowerDistribution)

        self.assertEqual(
            spds['X1'], SpectralPowerDistribution('X1', COLOURCHECKER_XRITE_1))
示例#12
0
def read_spds_from_csv_file(path,
                            delimiter=',',
                            fields=None,
                            default=0):
    """
    Reads the spectral data from given *CSV* file and return its content as an
    *OrderedDict* of
    :class:`colour.colorimetry.spectrum.SpectralPowerDistribution` classes.

    Parameters
    ----------
    path : unicode
        Absolute *CSV* file path.
    delimiter : unicode, optional
        *CSV* file content delimiter.
    fields : array_like, optional
        *CSV* file spectral data fields names. If no value is provided the
        first line of the file will be used for as spectral data fields names.
    default : numeric
        Default value for fields row with missing value.

    Returns
    -------
    OrderedDict
        :class:`colour.colorimetry.spectrum.SpectralPowerDistribution`
        classes of given *CSV* file.

    Examples
    --------
    >>> import os
    >>> csv_file = os.path.join(
    ...     os.path.dirname(__file__),
    ...     'tests',
    ...     'resources',
    ...     'colorchecker_n_ohta.csv')
    >>> spds = read_spds_from_csv_file(csv_file)
    >>> print(tuple(spds.keys()))
    ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', \
'14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24')
    >>> print(spds['1'])
    SpectralPowerDistribution('1', (380.0, 780.0, 5.0))
    """

    data = read_spectral_data_from_csv_file(path,
                                            delimiter,
                                            fields,
                                            default)

    spds = OrderedDict(((key, SpectralPowerDistribution(key, value))
                        for key, value in data.items()))
    return spds
示例#13
0
def D_illuminant_relative_spd(xy):
    """
    Returns the relative spectral power distribution of given
    *CIE Standard Illuminant D Series* using given *xy* chromaticity
    coordinates.

    References
    ----------
    .. [1]  Wyszecki, G., & Stiles, W. S. (2000). CIE Method of Calculating
            D-Illuminants. In Color Science: Concepts and Methods,
            Quantitative Data and Formulae (pp. 145–146). Wiley.
            ISBN:978-0471399186
    .. [2]  Lindbloom, B. (2007). Spectral Power Distribution of a
            CIE D-Illuminant. Retrieved April 05, 2014, from
            http://www.brucelindbloom.com/Eqn_DIlluminant.html

    Parameters
    ----------
    xy : array_like
        *xy* chromaticity coordinates.

    Returns
    -------
    SpectralPowerDistribution
        *CIE Standard Illuminant D Series* relative spectral power
        distribution.

    Examples
    --------
    >>> xy = np.array([0.34570, 0.35850])
    >>> print(D_illuminant_relative_spd(xy))
    SpectralPowerDistribution(\
'CIE Standard Illuminant D Series', (300.0, 830.0, 10.0))
    """

    M = 0.0241 + 0.2562 * xy[0] - 0.7341 * xy[1]
    M1 = (-1.3515 - 1.7703 * xy[0] + 5.9114 * xy[1]) / M
    M2 = (0.0300 - 31.4424 * xy[0] + 30.0717 * xy[1]) / M

    distribution = {}
    for i in D_ILLUMINANTS_S_SPDS['S0'].shape:
        S0 = D_ILLUMINANTS_S_SPDS['S0'][i]
        S1 = D_ILLUMINANTS_S_SPDS['S1'][i]
        S2 = D_ILLUMINANTS_S_SPDS['S2'][i]
        distribution[i] = S0 + M1 * S1 + M2 * S2

    return SpectralPowerDistribution('CIE Standard Illuminant D Series',
                                     distribution)
示例#14
0
def D_illuminant_relative_spd(xy):
    """
    Returns the relative spectral power distribution of given
    *CIE Standard Illuminant D Series* using given *xy* chromaticity
    coordinates.

    References
    ----------
    .. [1]  **Wyszecki & Stiles**,
            *Color Science - Concepts and Methods Data and Formulae -
            Second Edition*,
            Wiley Classics Library Edition, published 2000,
            ISBN-10: 0-471-39918-3,
            page  146.
    .. [2]  http://www.brucelindbloom.com/Eqn_DIlluminant.html
            (Last accessed 5 April 2014)

    Parameters
    ----------
    xy : array_like
        *xy* chromaticity coordinates.

    Returns
    -------
    SpectralPowerDistribution
        *CIE Standard Illuminant D Series* relative spectral power
        distribution.

    Examples
    --------
    >>> D_illuminant_relative_spd((0.34567, 0.35850))  # doctest: +ELLIPSIS
    <colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
    """

    M = 0.0241 + 0.2562 * xy[0] - 0.7341 * xy[1]
    M1 = (-1.3515 - 1.7703 * xy[0] + 5.9114 * xy[1]) / M
    M2 = (0.0300 - 31.4424 * xy[0] + 30.0717 * xy[1]) / M

    distribution = {}
    for i in D_ILLUMINANTS_S_SPDS.get('S0').shape:
        S0 = D_ILLUMINANTS_S_SPDS.get('S0').get(i)
        S1 = D_ILLUMINANTS_S_SPDS.get('S1').get(i)
        S2 = D_ILLUMINANTS_S_SPDS.get('S2').get(i)
        distribution[i] = S0 + M1 * S1 + M2 * S2

    return SpectralPowerDistribution('CIE Standard Illuminant D Series',
                                     distribution)
示例#15
0
    def test_tristimulus_weighting_factors_ASTME202211(self):
        """
        Tests :func:`colour.colorimetry.tristimulus.\
tristimulus_weighting_factors_ASTME202211` definition.

        Notes
        -----
        :attr:`A_CIE_1964_10_10_TWF`, :attr:`A_CIE_1964_10_20_TWF` and
        :attr:`D65_CIE_1931_2_20_TWF` attributes data is matching [1]_.

        References
        ----------
        .. [1]  ASTM International. (2015). ASTM E308–15 - Standard Practice
                for Computing the Colors of Objects by Using the CIE System,
                1–47. doi:10.1520/E0308-15
        """

        cmfs = CMFS.get('CIE 1964 10 Degree Standard Observer')
        wl = cmfs.shape.range()
        A = SpectralPowerDistribution(
            'A (360, 830, 1)',
            dict(zip(wl, CIE_standard_illuminant_A_function(wl))))

        twf = tristimulus_weighting_factors_ASTME202211(
            cmfs, A, SpectralShape(360, 830, 10))
        np.testing.assert_almost_equal(
            np.round(twf, 3),
            A_CIE_1964_10_10_TWF,
            decimal=3)

        twf = tristimulus_weighting_factors_ASTME202211(
            cmfs, A, SpectralShape(360, 830, 20))
        np.testing.assert_almost_equal(
            np.round(twf, 3),
            A_CIE_1964_10_20_TWF,
            decimal=3)

        cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
        D65 = ILLUMINANTS_RELATIVE_SPDS['D65'].clone().align(
            cmfs.shape, interpolation_method='Linear')
        twf = tristimulus_weighting_factors_ASTME202211(
            cmfs, D65, SpectralShape(360, 830, 20))
        np.testing.assert_almost_equal(
            np.round(twf, 3),
            D65_CIE_1931_2_20_TWF,
            decimal=3)
示例#16
0
    def test_colour_rendering_index(self):
        """
        Tests :func:`colour.quality.cri.colour_rendering_index` definition.
        """

        self.assertAlmostEqual(colour_rendering_index(
            ILLUMINANTS_RELATIVE_SPDS.get('F2')),
                               64.1507331494,
                               places=7)

        self.assertAlmostEqual(colour_rendering_index(
            ILLUMINANTS_RELATIVE_SPDS.get('A')),
                               99.9978916846,
                               places=7)

        self.assertAlmostEqual(colour_rendering_index(
            SpectralPowerDistribution('Sample', SAMPLE_SPD_DATA)),
                               70.805836753503698,
                               places=7)
示例#17
0
    def test_colour_rendering_index(self):
        """
        Tests :func:`colour.quality.cri.colour_rendering_index` definition.
        """

        self.assertAlmostEqual(colour_rendering_index(
            ILLUMINANTS_RELATIVE_SPDS['F2']),
                               64.151520202968015,
                               places=7)

        self.assertAlmostEqual(colour_rendering_index(
            ILLUMINANTS_RELATIVE_SPDS['A']),
                               99.996732643006169,
                               places=7)

        self.assertAlmostEqual(colour_rendering_index(
            SpectralPowerDistribution(SAMPLE_SPD_DATA)),
                               70.805386570659394,
                               places=7)
示例#18
0
    def test_colour_rendering_index(self):
        """
        Tests :func:`colour.quality.cri.colour_rendering_index` definition.
        """

        self.assertAlmostEqual(colour_rendering_index(
            ILLUMINANTS_RELATIVE_SPDS.get('F2')),
                               64.149547892010048,
                               places=7)

        self.assertAlmostEqual(colour_rendering_index(
            ILLUMINANTS_RELATIVE_SPDS.get('A')),
                               99.996736287811871,
                               places=7)

        self.assertAlmostEqual(colour_rendering_index(
            SpectralPowerDistribution('Sample', SAMPLE_SPD_DATA)),
                               70.802983235772103,
                               places=7)
示例#19
0
    def test_tristimulus_weighting_factors_ASTME202211(self):
        """
        Tests :func:`colour.colorimetry.tristimulus.\
tristimulus_weighting_factors_ASTME202211` definition.

        Notes
        -----
        :attr:`A_CIE_1964_10_10_TWF`, :attr:`A_CIE_1964_10_20_TWF` and
        :attr:`D65_CIE_1931_2_20_TWF` attributes data is matching
        :cite:`ASTMInternational2015b`.

        References
        ----------
        -   :cite:`ASTMInternational2015b`
        """

        cmfs = CMFS['CIE 1964 10 Degree Standard Observer']
        wl = cmfs.shape.range()
        A = SpectralPowerDistribution(dict(
            zip(wl, CIE_standard_illuminant_A_function(wl))),
                                      name='A (360, 830, 1)')

        twf = tristimulus_weighting_factors_ASTME202211(
            cmfs, A, SpectralShape(360, 830, 10))
        np.testing.assert_almost_equal(np.round(twf, 3),
                                       A_CIE_1964_10_10_TWF,
                                       decimal=3)

        twf = tristimulus_weighting_factors_ASTME202211(
            cmfs, A, SpectralShape(360, 830, 20))
        np.testing.assert_almost_equal(np.round(twf, 3),
                                       A_CIE_1964_10_20_TWF,
                                       decimal=3)

        cmfs = CMFS['CIE 1931 2 Degree Standard Observer']
        D65 = ILLUMINANTS_RELATIVE_SPDS['D65'].copy().align(
            cmfs.shape, interpolator=LinearInterpolator)
        twf = tristimulus_weighting_factors_ASTME202211(
            cmfs, D65, SpectralShape(360, 830, 20))
        np.testing.assert_almost_equal(np.round(twf, 3),
                                       D65_CIE_1931_2_20_TWF,
                                       decimal=3)
示例#20
0
def XYZ_to_spectral_Meng2015(
        XYZ,
        cmfs=STANDARD_OBSERVERS_CMFS['CIE 1931 2 Degree Standard Observer'],
        interval=5,
        tolerance=1e-10,
        maximum_iterations=2000):
    """
    Recovers the spectral power distribution of given *CIE XYZ* tristimulus
    values using *Meng et alii (2015)* method.

    Parameters
    ----------
    XYZ : array_like, (3,)
        *CIE XYZ* tristimulus values to recover the spectral power distribution
        from.
    cmfs : XYZ_ColourMatchingFunctions
        Standard observer colour matching functions.
    interval : numeric, optional
        Wavelength :math:`\lambda_{i}` range interval in nm. The smaller
        ``interval`` is, the longer the computations will be.
    tolerance : numeric, optional
        Tolerance for termination. The lower ``tolerance`` is, the smoother
        the recovered spectral power distribution will be.
    maximum_iterations : int, optional
        Maximum number of iterations to perform.

    Returns
    -------
    SpectralPowerDistribution
        Recovered spectral power distribution.

    Notes
    -----
    -   The definition used to convert spectrum to *CIE XYZ* tristimulus
        values is :func:`colour.colorimetry.spectral_to_XYZ_integration`
        definition because it processes any measurement interval opposed to
        :func:`colour.colorimetry.spectral_to_XYZ_ASTME30815` definition that
        handles only measurement interval of 1, 5, 10 or 20nm.

    References
    ----------
    -   :cite:`Meng2015c`

    Examples
    --------
    >>> from colour.utilities import numpy_print_options
    >>> XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
    >>> spd = XYZ_to_spectral_Meng2015(XYZ, interval=10)
    >>> with numpy_print_options(suppress=True):
    ...     spd  # doctest: +ELLIPSIS
    SpectralPowerDistribution([[ 360.        ,    0.0788075...],
                               [ 370.        ,    0.0788543...],
                               [ 380.        ,    0.0788825...],
                               [ 390.        ,    0.0788714...],
                               [ 400.        ,    0.0788911...],
                               [ 410.        ,    0.07893  ...],
                               [ 420.        ,    0.0797471...],
                               [ 430.        ,    0.0813339...],
                               [ 440.        ,    0.0840145...],
                               [ 450.        ,    0.0892826...],
                               [ 460.        ,    0.0965359...],
                               [ 470.        ,    0.1053176...],
                               [ 480.        ,    0.1150921...],
                               [ 490.        ,    0.1244252...],
                               [ 500.        ,    0.1326083...],
                               [ 510.        ,    0.1390282...],
                               [ 520.        ,    0.1423548...],
                               [ 530.        ,    0.1414636...],
                               [ 540.        ,    0.1365195...],
                               [ 550.        ,    0.1277319...],
                               [ 560.        ,    0.1152622...],
                               [ 570.        ,    0.1004513...],
                               [ 580.        ,    0.0844187...],
                               [ 590.        ,    0.0686863...],
                               [ 600.        ,    0.0543013...],
                               [ 610.        ,    0.0423486...],
                               [ 620.        ,    0.0333861...],
                               [ 630.        ,    0.0273558...],
                               [ 640.        ,    0.0233407...],
                               [ 650.        ,    0.0211208...],
                               [ 660.        ,    0.0197248...],
                               [ 670.        ,    0.0187157...],
                               [ 680.        ,    0.0181510...],
                               [ 690.        ,    0.0179691...],
                               [ 700.        ,    0.0179247...],
                               [ 710.        ,    0.0178665...],
                               [ 720.        ,    0.0178005...],
                               [ 730.        ,    0.0177570...],
                               [ 740.        ,    0.0177090...],
                               [ 750.        ,    0.0175743...],
                               [ 760.        ,    0.0175058...],
                               [ 770.        ,    0.0174492...],
                               [ 780.        ,    0.0174984...],
                               [ 790.        ,    0.0175667...],
                               [ 800.        ,    0.0175657...],
                               [ 810.        ,    0.0175319...],
                               [ 820.        ,    0.0175184...],
                               [ 830.        ,    0.0175390...]],
                              interpolator=SpragueInterpolator,
                              interpolator_args={},
                              extrapolator=Extrapolator,
                              extrapolator_args={...})
    >>> spectral_to_XYZ_integration(spd) / 100  # doctest: +ELLIPSIS
    array([ 0.0705100...,  0.1007987...,  0.0956738...])
    """

    XYZ = np.asarray(XYZ)
    shape = SpectralShape(cmfs.shape.start, cmfs.shape.end, interval)
    cmfs = cmfs.copy().align(shape)
    illuminant = ones_spd(shape)
    spd = ones_spd(shape)

    def function_objective(a):
        """
        Objective function.
        """

        return np.sum(np.diff(a) ** 2)

    def function_constraint(a):
        """
        Function defining the constraint.
        """

        spd[:] = a
        return spectral_to_XYZ_integration(
            spd, cmfs=cmfs, illuminant=illuminant) - XYZ

    wavelengths = spd.wavelengths
    bins = wavelengths.size

    constraints = {'type': 'eq', 'fun': function_constraint}

    bounds = np.tile(np.array([0, 1000]), (bins, 1))

    result = minimize(
        function_objective,
        spd.values,
        method='SLSQP',
        constraints=constraints,
        bounds=bounds,
        options={'ftol': tolerance,
                 'maxiter': maximum_iterations})

    if not result.success:
        raise RuntimeError(
            'Optimization failed for {0} after {1} iterations: "{2}".'.format(
                XYZ, result.nit, result.message))

    return SpectralPowerDistribution(
        dict(zip(wavelengths, result.x * 100)),
        name='Meng (2015) - {0}'.format(XYZ))
示例#21
0
def read_spds_from_csv_file(path, delimiter=',', fields=None, default=0):
    """
    Reads the spectral data from given *CSV* file and return its content as an
    *OrderedDict* of :class:`colour.SpectralPowerDistribution` classes.

    Parameters
    ----------
    path : unicode
        Absolute *CSV* file path.
    delimiter : unicode, optional
        *CSV* file content delimiter.
    fields : array_like, optional
        *CSV* file spectral data fields names. If no value is provided the
        first line of the file will be used for as spectral data fields names.
    default : numeric
        Default value for fields row with missing value.

    Returns
    -------
    OrderedDict
        :class:`colour.SpectralPowerDistribution` classes of given *CSV* file.

    Examples
    --------
    >>> from colour.utilities import numpy_print_options
    >>> import os
    >>> csv_file = os.path.join(os.path.dirname(__file__), 'tests',
    ...                         'resources', 'colorchecker_n_ohta.csv')
    >>> spds = read_spds_from_csv_file(csv_file)
    >>> print(tuple(spds.keys()))
    ('1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', \
'14', '15', '16', '17', '18', '19', '20', '21', '22', '23', '24')
    >>> with numpy_print_options(suppress=True):
    ...     spds['1']  # doctest: +ELLIPSIS
    SpectralPowerDistribution([[ 380.   ,    0.048],
                               [ 385.   ,    0.051],
                               [ 390.   ,    0.055],
                               [ 395.   ,    0.06 ],
                               [ 400.   ,    0.065],
                               [ 405.   ,    0.068],
                               [ 410.   ,    0.068],
                               [ 415.   ,    0.067],
                               [ 420.   ,    0.064],
                               [ 425.   ,    0.062],
                               [ 430.   ,    0.059],
                               [ 435.   ,    0.057],
                               [ 440.   ,    0.055],
                               [ 445.   ,    0.054],
                               [ 450.   ,    0.053],
                               [ 455.   ,    0.053],
                               [ 460.   ,    0.052],
                               [ 465.   ,    0.052],
                               [ 470.   ,    0.052],
                               [ 475.   ,    0.053],
                               [ 480.   ,    0.054],
                               [ 485.   ,    0.055],
                               [ 490.   ,    0.057],
                               [ 495.   ,    0.059],
                               [ 500.   ,    0.061],
                               [ 505.   ,    0.062],
                               [ 510.   ,    0.065],
                               [ 515.   ,    0.067],
                               [ 520.   ,    0.07 ],
                               [ 525.   ,    0.072],
                               [ 530.   ,    0.074],
                               [ 535.   ,    0.075],
                               [ 540.   ,    0.076],
                               [ 545.   ,    0.078],
                               [ 550.   ,    0.079],
                               [ 555.   ,    0.082],
                               [ 560.   ,    0.087],
                               [ 565.   ,    0.092],
                               [ 570.   ,    0.1  ],
                               [ 575.   ,    0.107],
                               [ 580.   ,    0.115],
                               [ 585.   ,    0.122],
                               [ 590.   ,    0.129],
                               [ 595.   ,    0.134],
                               [ 600.   ,    0.138],
                               [ 605.   ,    0.142],
                               [ 610.   ,    0.146],
                               [ 615.   ,    0.15 ],
                               [ 620.   ,    0.154],
                               [ 625.   ,    0.158],
                               [ 630.   ,    0.163],
                               [ 635.   ,    0.167],
                               [ 640.   ,    0.173],
                               [ 645.   ,    0.18 ],
                               [ 650.   ,    0.188],
                               [ 655.   ,    0.196],
                               [ 660.   ,    0.204],
                               [ 665.   ,    0.213],
                               [ 670.   ,    0.222],
                               [ 675.   ,    0.231],
                               [ 680.   ,    0.242],
                               [ 685.   ,    0.251],
                               [ 690.   ,    0.261],
                               [ 695.   ,    0.271],
                               [ 700.   ,    0.282],
                               [ 705.   ,    0.294],
                               [ 710.   ,    0.305],
                               [ 715.   ,    0.318],
                               [ 720.   ,    0.334],
                               [ 725.   ,    0.354],
                               [ 730.   ,    0.372],
                               [ 735.   ,    0.392],
                               [ 740.   ,    0.409],
                               [ 745.   ,    0.42 ],
                               [ 750.   ,    0.436],
                               [ 755.   ,    0.45 ],
                               [ 760.   ,    0.462],
                               [ 765.   ,    0.465],
                               [ 770.   ,    0.448],
                               [ 775.   ,    0.432],
                               [ 780.   ,    0.421]],
                              interpolator=SpragueInterpolator,
                              interpolator_args={},
                              extrapolator=Extrapolator,
                              extrapolator_args={...})
    """

    data = read_spectral_data_from_csv_file(path, delimiter, fields, default)

    spds = OrderedDict(((key, SpectralPowerDistribution(value, name=key))
                        for key, value in data.items()))
    return spds
示例#22
0
        690: 8.3,
        700: 9.6,
        710: 8.5,
        720: 7.0,
        730: 7.6,
        740: 8.0,
        750: 6.7,
        760: 5.2,
        770: 7.4,
        780: 6.8,
        790: 7.0,
        800: 6.4,
        810: 5.5,
        820: 6.1,
        830: 6.5}}

D_ILLUMINANTS_S_SPDS = CaseInsensitiveMapping(
    {'S0': SpectralPowerDistribution('S0',
                                     D_ILLUMINANTS_S_SPDS_DATA.get('S0')),
     'S1': SpectralPowerDistribution('S1',
                                     D_ILLUMINANTS_S_SPDS_DATA.get('S1')),
     'S2': SpectralPowerDistribution('S2',
                                     D_ILLUMINANTS_S_SPDS_DATA.get('S2'))})
"""
*CIE Standard Illuminant D Series* :math:`S_n(\lambda)` spectral power
distributions

D_ILLUMINANTS_S_SPDS : CaseInsensitiveMapping
   **{'S0', 'S1', 'S1'}**
"""
示例#23
0
def rayleigh_scattering_spd(shape=DEFAULT_SPECTRAL_SHAPE,
                            CO2_concentration=STANDARD_CO2_CONCENTRATION,
                            temperature=STANDARD_AIR_TEMPERATURE,
                            pressure=AVERAGE_PRESSURE_MEAN_SEA_LEVEL,
                            latitude=DEFAULT_LATITUDE,
                            altitude=DEFAULT_ALTITUDE,
                            avogadro_constant=AVOGADRO_CONSTANT,
                            n_s=air_refraction_index_bodhaine1999,
                            F_air=F_air_bodhaine1999):
    """
    Returns the rayleigh spectral power distribution for given spectral shape.

    Parameters
    ----------
    shape : SpectralShape, optional
        Spectral shape used to create the rayleigh scattering spectral power
        distribution.
    CO2_concentration : numeric, optional
        :math:`CO_2` concentration in parts per million (ppm).
    temperature : numeric, optional
        Air temperature :math:`T[K]` in kelvin degrees.
    pressure : numeric
        Surface pressure :math:`P` of the measurement site.
    latitude : numeric, optional
        Latitude of the site in degrees.
    altitude : numeric, optional
        Altitude of the site in meters.
    avogadro_constant : numeric, optional
        *Avogadro*'s number (molecules :math:`mol^{-1}`).
    n_s : object
        Air refraction index :math:`n_s` computation method.
    F_air : object
        :math:`(6+3_p)/(6-7_p)`, the depolarisation term :math:`F(air)` or
        *King Factor* computation method.

    Returns
    -------
    SpectralPowerDistribution
        Rayleigh optical depth spectral power distribution.

    Examples
    --------
    >>> rayleigh_scattering_spd()  # doctest: +ELLIPSIS
    <colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
    """

    return SpectralPowerDistribution(
        name=('Rayleigh Scattering - {0} ppm, {1} K, {2} Pa, {3} Degrees, '
              '{4} m').format(CO2_concentration,
                              temperature,
                              pressure,
                              latitude,
                              altitude),
        data=dict((wavelength, rayleigh_scattering(wavelength * 10e-8,
                                                   CO2_concentration,
                                                   temperature,
                                                   pressure,
                                                   latitude,
                                                   altitude,
                                                   avogadro_constant,
                                                   n_s,
                                                   F_air))
                  for wavelength in shape))
示例#24
0
文件: vs.py 项目: nick-shaw/colour
        730: 0.6662,
        735: 0.6726,
        740: 0.6774,
        745: 0.6834,
        750: 0.6808,
        755: 0.6838,
        760: 0.6874,
        765: 0.6955,
        770: 0.7012,
        775: 0.6996,
        780: 0.7023,
        785: 0.7022,
        790: 0.7144,
        795: 0.7062,
        800: 0.7075,
        805: 0.7075,
        810: 0.7075,
        815: 0.7075,
        820: 0.7075,
        825: 0.7075,
        830: 0.7075}}

VS_SPDS = CaseInsensitiveMapping(
    dict((key, SpectralPowerDistribution(key, value)) for key, value in
         VS_SPDS_DATA.items()))
"""
CQS test colour samples spectral power distributions.

VS_SPDS : CaseInsensitiveMapping
"""
示例#25
0
def blackbody_spd(temperature,
                  shape=DEFAULT_SPECTRAL_SHAPE,
                  c1=C1,
                  c2=C2,
                  n=N):
    """
    Returns the spectral power distribution of the planckian radiator for given
    temperature :math:`T[K]`.

    Parameters
    ----------
    temperature : numeric
        Temperature :math:`T[K]` in kelvin degrees.
    shape : SpectralShape, optional
        Spectral shape used to create the spectral power distribution of the
        planckian radiator.
    c1 : numeric, optional
        The official value of :math:`c1` is provided by the Committee on Data
        for Science and Technology (CODATA) and is
        :math:`c1=3,741771x10.16\ W/m_2` *(Mohr and Taylor, 2000)*.
    c2 : numeric, optional
        Since :math:`T` is measured on the International Temperature Scale,
        the value of :math:`c2` used in colorimetry should follow that adopted
        in the current International Temperature Scale (ITS-90)
        *(Preston-Thomas, 1990; Mielenz et aI., 1991)*, namely
        :math:`c2=1,4388x10.2\ m/K`.
    n : numeric, optional
        Medium index of refraction. For dry air at 15C and 101 325 Pa,
        containing 0,03 percent by volume of carbon dioxide, it is
        approximately 1,00028 throughout the visible region although
        *CIE 15:2004* recommends using :math:`n=1`.

    Returns
    -------
    SpectralPowerDistribution
        Blackbody spectral power distribution.

    Examples
    --------
    >>> from colour import STANDARD_OBSERVERS_CMFS
    >>> from colour.utilities import numpy_print_options
    >>> cmfs = STANDARD_OBSERVERS_CMFS['CIE 1931 2 Degree Standard Observer']
    >>> with numpy_print_options(suppress=True):
    ...     blackbody_spd(5000, cmfs.shape)  # doctest: +ELLIPSIS
    SpectralPowerDistribution([[  3.60000000e+02,   6.65427827e+12],
                               [  3.61000000e+02,   6.70960528e+12],
                               [  3.62000000e+02,   6.76482512e+12],
                               [  3.63000000e+02,   6.81993308e+12],
                               [  3.64000000e+02,   6.87492449e+12],
                               [  3.65000000e+02,   6.92979475e+12],
                               [  3.66000000e+02,   6.98453932e+12],
                               [  3.67000000e+02,   7.03915372e+12],
                               [  3.68000000e+02,   7.09363351e+12],
                               [  3.69000000e+02,   7.14797433e+12],
                               [  3.70000000e+02,   7.20217187e+12],
                               [  3.71000000e+02,   7.25622190e+12],
                               [  3.72000000e+02,   7.31012021e+12],
                               [  3.73000000e+02,   7.36386268e+12],
                               [  3.74000000e+02,   7.41744525e+12],
                               [  3.75000000e+02,   7.47086391e+12],
                               [  3.76000000e+02,   7.52411471e+12],
                               [  3.77000000e+02,   7.57719377e+12],
                               [  3.78000000e+02,   7.63009726e+12],
                               [  3.79000000e+02,   7.68282141e+12],
                               [  3.80000000e+02,   7.73536252e+12],
                               [  3.81000000e+02,   7.78771695e+12],
                               [  3.82000000e+02,   7.83988111e+12],
                               [  3.83000000e+02,   7.89185148e+12],
                               [  3.84000000e+02,   7.94362458e+12],
                               [  3.85000000e+02,   7.99519703e+12],
                               [  3.86000000e+02,   8.04656547e+12],
                               [  3.87000000e+02,   8.09772662e+12],
                               [  3.88000000e+02,   8.14867726e+12],
                               [  3.89000000e+02,   8.19941421e+12],
                               [  3.90000000e+02,   8.24993438e+12],
                               [  3.91000000e+02,   8.30023471e+12],
                               [  3.92000000e+02,   8.35031222e+12],
                               [  3.93000000e+02,   8.40016398e+12],
                               [  3.94000000e+02,   8.44978711e+12],
                               [  3.95000000e+02,   8.49917881e+12],
                               [  3.96000000e+02,   8.54833632e+12],
                               [  3.97000000e+02,   8.59725693e+12],
                               [  3.98000000e+02,   8.64593802e+12],
                               [  3.99000000e+02,   8.69437700e+12],
                               [  4.00000000e+02,   8.74257133e+12],
                               [  4.01000000e+02,   8.79051856e+12],
                               [  4.02000000e+02,   8.83821626e+12],
                               [  4.03000000e+02,   8.88566209e+12],
                               [  4.04000000e+02,   8.93285373e+12],
                               [  4.05000000e+02,   8.97978893e+12],
                               [  4.06000000e+02,   9.02646551e+12],
                               [  4.07000000e+02,   9.07288133e+12],
                               [  4.08000000e+02,   9.11903431e+12],
                               [  4.09000000e+02,   9.16492240e+12],
                               [  4.10000000e+02,   9.21054364e+12],
                               [  4.11000000e+02,   9.25589609e+12],
                               [  4.12000000e+02,   9.30097789e+12],
                               [  4.13000000e+02,   9.34578722e+12],
                               [  4.14000000e+02,   9.39032230e+12],
                               [  4.15000000e+02,   9.43458143e+12],
                               [  4.16000000e+02,   9.47856292e+12],
                               [  4.17000000e+02,   9.52226517e+12],
                               [  4.18000000e+02,   9.56568661e+12],
                               [  4.19000000e+02,   9.60882571e+12],
                               [  4.20000000e+02,   9.65168102e+12],
                               [  4.21000000e+02,   9.69425111e+12],
                               [  4.22000000e+02,   9.73653461e+12],
                               [  4.23000000e+02,   9.77853020e+12],
                               [  4.24000000e+02,   9.82023659e+12],
                               [  4.25000000e+02,   9.86165257e+12],
                               [  4.26000000e+02,   9.90277693e+12],
                               [  4.27000000e+02,   9.94360856e+12],
                               [  4.28000000e+02,   9.98414634e+12],
                               [  4.29000000e+02,   1.00243892e+13],
                               [  4.30000000e+02,   1.00643363e+13],
                               [  4.31000000e+02,   1.01039864e+13],
                               [  4.32000000e+02,   1.01433388e+13],
                               [  4.33000000e+02,   1.01823926e+13],
                               [  4.34000000e+02,   1.02211468e+13],
                               [  4.35000000e+02,   1.02596009e+13],
                               [  4.36000000e+02,   1.02977539e+13],
                               [  4.37000000e+02,   1.03356052e+13],
                               [  4.38000000e+02,   1.03731541e+13],
                               [  4.39000000e+02,   1.04104000e+13],
                               [  4.40000000e+02,   1.04473423e+13],
                               [  4.41000000e+02,   1.04839805e+13],
                               [  4.42000000e+02,   1.05203140e+13],
                               [  4.43000000e+02,   1.05563424e+13],
                               [  4.44000000e+02,   1.05920652e+13],
                               [  4.45000000e+02,   1.06274821e+13],
                               [  4.46000000e+02,   1.06625927e+13],
                               [  4.47000000e+02,   1.06973967e+13],
                               [  4.48000000e+02,   1.07318937e+13],
                               [  4.49000000e+02,   1.07660835e+13],
                               [  4.50000000e+02,   1.07999660e+13],
                               [  4.51000000e+02,   1.08335408e+13],
                               [  4.52000000e+02,   1.08668080e+13],
                               [  4.53000000e+02,   1.08997673e+13],
                               [  4.54000000e+02,   1.09324187e+13],
                               [  4.55000000e+02,   1.09647621e+13],
                               [  4.56000000e+02,   1.09967975e+13],
                               [  4.57000000e+02,   1.10285249e+13],
                               [  4.58000000e+02,   1.10599443e+13],
                               [  4.59000000e+02,   1.10910559e+13],
                               [  4.60000000e+02,   1.11218598e+13],
                               [  4.61000000e+02,   1.11523560e+13],
                               [  4.62000000e+02,   1.11825447e+13],
                               [  4.63000000e+02,   1.12124262e+13],
                               [  4.64000000e+02,   1.12420006e+13],
                               [  4.65000000e+02,   1.12712681e+13],
                               [  4.66000000e+02,   1.13002292e+13],
                               [  4.67000000e+02,   1.13288840e+13],
                               [  4.68000000e+02,   1.13572329e+13],
                               [  4.69000000e+02,   1.13852762e+13],
                               [  4.70000000e+02,   1.14130144e+13],
                               [  4.71000000e+02,   1.14404478e+13],
                               [  4.72000000e+02,   1.14675768e+13],
                               [  4.73000000e+02,   1.14944020e+13],
                               [  4.74000000e+02,   1.15209237e+13],
                               [  4.75000000e+02,   1.15471425e+13],
                               [  4.76000000e+02,   1.15730590e+13],
                               [  4.77000000e+02,   1.15986736e+13],
                               [  4.78000000e+02,   1.16239869e+13],
                               [  4.79000000e+02,   1.16489996e+13],
                               [  4.80000000e+02,   1.16737122e+13],
                               [  4.81000000e+02,   1.16981253e+13],
                               [  4.82000000e+02,   1.17222397e+13],
                               [  4.83000000e+02,   1.17460559e+13],
                               [  4.84000000e+02,   1.17695747e+13],
                               [  4.85000000e+02,   1.17927969e+13],
                               [  4.86000000e+02,   1.18157230e+13],
                               [  4.87000000e+02,   1.18383540e+13],
                               [  4.88000000e+02,   1.18606904e+13],
                               [  4.89000000e+02,   1.18827333e+13],
                               [  4.90000000e+02,   1.19044832e+13],
                               [  4.91000000e+02,   1.19259412e+13],
                               [  4.92000000e+02,   1.19471079e+13],
                               [  4.93000000e+02,   1.19679843e+13],
                               [  4.94000000e+02,   1.19885712e+13],
                               [  4.95000000e+02,   1.20088695e+13],
                               [  4.96000000e+02,   1.20288802e+13],
                               [  4.97000000e+02,   1.20486041e+13],
                               [  4.98000000e+02,   1.20680421e+13],
                               [  4.99000000e+02,   1.20871953e+13],
                               [  5.00000000e+02,   1.21060645e+13],
                               [  5.01000000e+02,   1.21246508e+13],
                               [  5.02000000e+02,   1.21429552e+13],
                               [  5.03000000e+02,   1.21609785e+13],
                               [  5.04000000e+02,   1.21787220e+13],
                               [  5.05000000e+02,   1.21961865e+13],
                               [  5.06000000e+02,   1.22133731e+13],
                               [  5.07000000e+02,   1.22302829e+13],
                               [  5.08000000e+02,   1.22469170e+13],
                               [  5.09000000e+02,   1.22632763e+13],
                               [  5.10000000e+02,   1.22793620e+13],
                               [  5.11000000e+02,   1.22951752e+13],
                               [  5.12000000e+02,   1.23107171e+13],
                               [  5.13000000e+02,   1.23259886e+13],
                               [  5.14000000e+02,   1.23409909e+13],
                               [  5.15000000e+02,   1.23557252e+13],
                               [  5.16000000e+02,   1.23701926e+13],
                               [  5.17000000e+02,   1.23843943e+13],
                               [  5.18000000e+02,   1.23983314e+13],
                               [  5.19000000e+02,   1.24120051e+13],
                               [  5.20000000e+02,   1.24254166e+13],
                               [  5.21000000e+02,   1.24385670e+13],
                               [  5.22000000e+02,   1.24514576e+13],
                               [  5.23000000e+02,   1.24640896e+13],
                               [  5.24000000e+02,   1.24764641e+13],
                               [  5.25000000e+02,   1.24885824e+13],
                               [  5.26000000e+02,   1.25004457e+13],
                               [  5.27000000e+02,   1.25120552e+13],
                               [  5.28000000e+02,   1.25234122e+13],
                               [  5.29000000e+02,   1.25345178e+13],
                               [  5.30000000e+02,   1.25453735e+13],
                               [  5.31000000e+02,   1.25559803e+13],
                               [  5.32000000e+02,   1.25663396e+13],
                               [  5.33000000e+02,   1.25764527e+13],
                               [  5.34000000e+02,   1.25863207e+13],
                               [  5.35000000e+02,   1.25959449e+13],
                               [  5.36000000e+02,   1.26053268e+13],
                               [  5.37000000e+02,   1.26144674e+13],
                               [  5.38000000e+02,   1.26233681e+13],
                               [  5.39000000e+02,   1.26320302e+13],
                               [  5.40000000e+02,   1.26404551e+13],
                               [  5.41000000e+02,   1.26486438e+13],
                               [  5.42000000e+02,   1.26565979e+13],
                               [  5.43000000e+02,   1.26643185e+13],
                               [  5.44000000e+02,   1.26718071e+13],
                               [  5.45000000e+02,   1.26790648e+13],
                               [  5.46000000e+02,   1.26860930e+13],
                               [  5.47000000e+02,   1.26928930e+13],
                               [  5.48000000e+02,   1.26994662e+13],
                               [  5.49000000e+02,   1.27058138e+13],
                               [  5.50000000e+02,   1.27119372e+13],
                               [  5.51000000e+02,   1.27178376e+13],
                               [  5.52000000e+02,   1.27235164e+13],
                               [  5.53000000e+02,   1.27289750e+13],
                               [  5.54000000e+02,   1.27342146e+13],
                               [  5.55000000e+02,   1.27392366e+13],
                               [  5.56000000e+02,   1.27440423e+13],
                               [  5.57000000e+02,   1.27486330e+13],
                               [  5.58000000e+02,   1.27530100e+13],
                               [  5.59000000e+02,   1.27571748e+13],
                               [  5.60000000e+02,   1.27611285e+13],
                               [  5.61000000e+02,   1.27648725e+13],
                               [  5.62000000e+02,   1.27684083e+13],
                               [  5.63000000e+02,   1.27717370e+13],
                               [  5.64000000e+02,   1.27748600e+13],
                               [  5.65000000e+02,   1.27777787e+13],
                               [  5.66000000e+02,   1.27804943e+13],
                               [  5.67000000e+02,   1.27830082e+13],
                               [  5.68000000e+02,   1.27853217e+13],
                               [  5.69000000e+02,   1.27874362e+13],
                               [  5.70000000e+02,   1.27893529e+13],
                               [  5.71000000e+02,   1.27910732e+13],
                               [  5.72000000e+02,   1.27925984e+13],
                               [  5.73000000e+02,   1.27939299e+13],
                               [  5.74000000e+02,   1.27950689e+13],
                               [  5.75000000e+02,   1.27960167e+13],
                               [  5.76000000e+02,   1.27967747e+13],
                               [  5.77000000e+02,   1.27973442e+13],
                               [  5.78000000e+02,   1.27977264e+13],
                               [  5.79000000e+02,   1.27979228e+13],
                               [  5.80000000e+02,   1.27979346e+13],
                               [  5.81000000e+02,   1.27977630e+13],
                               [  5.82000000e+02,   1.27974095e+13],
                               [  5.83000000e+02,   1.27968753e+13],
                               [  5.84000000e+02,   1.27961617e+13],
                               [  5.85000000e+02,   1.27952700e+13],
                               [  5.86000000e+02,   1.27942015e+13],
                               [  5.87000000e+02,   1.27929575e+13],
                               [  5.88000000e+02,   1.27915392e+13],
                               [  5.89000000e+02,   1.27899480e+13],
                               [  5.90000000e+02,   1.27881852e+13],
                               [  5.91000000e+02,   1.27862519e+13],
                               [  5.92000000e+02,   1.27841495e+13],
                               [  5.93000000e+02,   1.27818793e+13],
                               [  5.94000000e+02,   1.27794424e+13],
                               [  5.95000000e+02,   1.27768403e+13],
                               [  5.96000000e+02,   1.27740741e+13],
                               [  5.97000000e+02,   1.27711451e+13],
                               [  5.98000000e+02,   1.27680546e+13],
                               [  5.99000000e+02,   1.27648037e+13],
                               [  6.00000000e+02,   1.27613938e+13],
                               [  6.01000000e+02,   1.27578261e+13],
                               [  6.02000000e+02,   1.27541018e+13],
                               [  6.03000000e+02,   1.27502222e+13],
                               [  6.04000000e+02,   1.27461885e+13],
                               [  6.05000000e+02,   1.27420020e+13],
                               [  6.06000000e+02,   1.27376637e+13],
                               [  6.07000000e+02,   1.27331750e+13],
                               [  6.08000000e+02,   1.27285371e+13],
                               [  6.09000000e+02,   1.27237512e+13],
                               [  6.10000000e+02,   1.27188185e+13],
                               [  6.11000000e+02,   1.27137402e+13],
                               [  6.12000000e+02,   1.27085175e+13],
                               [  6.13000000e+02,   1.27031516e+13],
                               [  6.14000000e+02,   1.26976436e+13],
                               [  6.15000000e+02,   1.26919949e+13],
                               [  6.16000000e+02,   1.26862064e+13],
                               [  6.17000000e+02,   1.26802795e+13],
                               [  6.18000000e+02,   1.26742153e+13],
                               [  6.19000000e+02,   1.26680149e+13],
                               [  6.20000000e+02,   1.26616795e+13],
                               [  6.21000000e+02,   1.26552103e+13],
                               [  6.22000000e+02,   1.26486085e+13],
                               [  6.23000000e+02,   1.26418751e+13],
                               [  6.24000000e+02,   1.26350113e+13],
                               [  6.25000000e+02,   1.26280183e+13],
                               [  6.26000000e+02,   1.26208972e+13],
                               [  6.27000000e+02,   1.26136491e+13],
                               [  6.28000000e+02,   1.26062751e+13],
                               [  6.29000000e+02,   1.25987764e+13],
                               [  6.30000000e+02,   1.25911540e+13],
                               [  6.31000000e+02,   1.25834092e+13],
                               [  6.32000000e+02,   1.25755429e+13],
                               [  6.33000000e+02,   1.25675563e+13],
                               [  6.34000000e+02,   1.25594505e+13],
                               [  6.35000000e+02,   1.25512265e+13],
                               [  6.36000000e+02,   1.25428855e+13],
                               [  6.37000000e+02,   1.25344285e+13],
                               [  6.38000000e+02,   1.25258566e+13],
                               [  6.39000000e+02,   1.25171709e+13],
                               [  6.40000000e+02,   1.25083724e+13],
                               [  6.41000000e+02,   1.24994622e+13],
                               [  6.42000000e+02,   1.24904413e+13],
                               [  6.43000000e+02,   1.24813108e+13],
                               [  6.44000000e+02,   1.24720718e+13],
                               [  6.45000000e+02,   1.24627252e+13],
                               [  6.46000000e+02,   1.24532721e+13],
                               [  6.47000000e+02,   1.24437136e+13],
                               [  6.48000000e+02,   1.24340506e+13],
                               [  6.49000000e+02,   1.24242842e+13],
                               [  6.50000000e+02,   1.24144153e+13],
                               [  6.51000000e+02,   1.24044450e+13],
                               [  6.52000000e+02,   1.23943743e+13],
                               [  6.53000000e+02,   1.23842042e+13],
                               [  6.54000000e+02,   1.23739356e+13],
                               [  6.55000000e+02,   1.23635696e+13],
                               [  6.56000000e+02,   1.23531072e+13],
                               [  6.57000000e+02,   1.23425492e+13],
                               [  6.58000000e+02,   1.23318967e+13],
                               [  6.59000000e+02,   1.23211506e+13],
                               [  6.60000000e+02,   1.23103120e+13],
                               [  6.61000000e+02,   1.22993816e+13],
                               [  6.62000000e+02,   1.22883606e+13],
                               [  6.63000000e+02,   1.22772498e+13],
                               [  6.64000000e+02,   1.22660502e+13],
                               [  6.65000000e+02,   1.22547627e+13],
                               [  6.66000000e+02,   1.22433883e+13],
                               [  6.67000000e+02,   1.22319278e+13],
                               [  6.68000000e+02,   1.22203821e+13],
                               [  6.69000000e+02,   1.22087523e+13],
                               [  6.70000000e+02,   1.21970391e+13],
                               [  6.71000000e+02,   1.21852435e+13],
                               [  6.72000000e+02,   1.21733664e+13],
                               [  6.73000000e+02,   1.21614087e+13],
                               [  6.74000000e+02,   1.21493712e+13],
                               [  6.75000000e+02,   1.21372548e+13],
                               [  6.76000000e+02,   1.21250605e+13],
                               [  6.77000000e+02,   1.21127890e+13],
                               [  6.78000000e+02,   1.21004413e+13],
                               [  6.79000000e+02,   1.20880182e+13],
                               [  6.80000000e+02,   1.20755205e+13],
                               [  6.81000000e+02,   1.20629491e+13],
                               [  6.82000000e+02,   1.20503049e+13],
                               [  6.83000000e+02,   1.20375887e+13],
                               [  6.84000000e+02,   1.20248012e+13],
                               [  6.85000000e+02,   1.20119434e+13],
                               [  6.86000000e+02,   1.19990161e+13],
                               [  6.87000000e+02,   1.19860200e+13],
                               [  6.88000000e+02,   1.19729560e+13],
                               [  6.89000000e+02,   1.19598249e+13],
                               [  6.90000000e+02,   1.19466275e+13],
                               [  6.91000000e+02,   1.19333646e+13],
                               [  6.92000000e+02,   1.19200370e+13],
                               [  6.93000000e+02,   1.19066454e+13],
                               [  6.94000000e+02,   1.18931907e+13],
                               [  6.95000000e+02,   1.18796736e+13],
                               [  6.96000000e+02,   1.18660949e+13],
                               [  6.97000000e+02,   1.18524554e+13],
                               [  6.98000000e+02,   1.18387558e+13],
                               [  6.99000000e+02,   1.18249969e+13],
                               [  7.00000000e+02,   1.18111794e+13],
                               [  7.01000000e+02,   1.17973040e+13],
                               [  7.02000000e+02,   1.17833716e+13],
                               [  7.03000000e+02,   1.17693829e+13],
                               [  7.04000000e+02,   1.17553385e+13],
                               [  7.05000000e+02,   1.17412392e+13],
                               [  7.06000000e+02,   1.17270858e+13],
                               [  7.07000000e+02,   1.17128789e+13],
                               [  7.08000000e+02,   1.16986192e+13],
                               [  7.09000000e+02,   1.16843075e+13],
                               [  7.10000000e+02,   1.16699445e+13],
                               [  7.11000000e+02,   1.16555309e+13],
                               [  7.12000000e+02,   1.16410673e+13],
                               [  7.13000000e+02,   1.16265544e+13],
                               [  7.14000000e+02,   1.16119930e+13],
                               [  7.15000000e+02,   1.15973836e+13],
                               [  7.16000000e+02,   1.15827271e+13],
                               [  7.17000000e+02,   1.15680240e+13],
                               [  7.18000000e+02,   1.15532749e+13],
                               [  7.19000000e+02,   1.15384807e+13],
                               [  7.20000000e+02,   1.15236419e+13],
                               [  7.21000000e+02,   1.15087591e+13],
                               [  7.22000000e+02,   1.14938331e+13],
                               [  7.23000000e+02,   1.14788644e+13],
                               [  7.24000000e+02,   1.14638537e+13],
                               [  7.25000000e+02,   1.14488017e+13],
                               [  7.26000000e+02,   1.14337088e+13],
                               [  7.27000000e+02,   1.14185759e+13],
                               [  7.28000000e+02,   1.14034034e+13],
                               [  7.29000000e+02,   1.13881921e+13],
                               [  7.30000000e+02,   1.13729424e+13],
                               [  7.31000000e+02,   1.13576551e+13],
                               [  7.32000000e+02,   1.13423307e+13],
                               [  7.33000000e+02,   1.13269698e+13],
                               [  7.34000000e+02,   1.13115730e+13],
                               [  7.35000000e+02,   1.12961409e+13],
                               [  7.36000000e+02,   1.12806741e+13],
                               [  7.37000000e+02,   1.12651731e+13],
                               [  7.38000000e+02,   1.12496385e+13],
                               [  7.39000000e+02,   1.12340710e+13],
                               [  7.40000000e+02,   1.12184710e+13],
                               [  7.41000000e+02,   1.12028391e+13],
                               [  7.42000000e+02,   1.11871759e+13],
                               [  7.43000000e+02,   1.11714819e+13],
                               [  7.44000000e+02,   1.11557577e+13],
                               [  7.45000000e+02,   1.11400038e+13],
                               [  7.46000000e+02,   1.11242208e+13],
                               [  7.47000000e+02,   1.11084092e+13],
                               [  7.48000000e+02,   1.10925695e+13],
                               [  7.49000000e+02,   1.10767023e+13],
                               [  7.50000000e+02,   1.10608080e+13],
                               [  7.51000000e+02,   1.10448872e+13],
                               [  7.52000000e+02,   1.10289405e+13],
                               [  7.53000000e+02,   1.10129683e+13],
                               [  7.54000000e+02,   1.09969711e+13],
                               [  7.55000000e+02,   1.09809495e+13],
                               [  7.56000000e+02,   1.09649039e+13],
                               [  7.57000000e+02,   1.09488348e+13],
                               [  7.58000000e+02,   1.09327427e+13],
                               [  7.59000000e+02,   1.09166282e+13],
                               [  7.60000000e+02,   1.09004917e+13],
                               [  7.61000000e+02,   1.08843336e+13],
                               [  7.62000000e+02,   1.08681545e+13],
                               [  7.63000000e+02,   1.08519548e+13],
                               [  7.64000000e+02,   1.08357350e+13],
                               [  7.65000000e+02,   1.08194956e+13],
                               [  7.66000000e+02,   1.08032370e+13],
                               [  7.67000000e+02,   1.07869596e+13],
                               [  7.68000000e+02,   1.07706640e+13],
                               [  7.69000000e+02,   1.07543506e+13],
                               [  7.70000000e+02,   1.07380198e+13],
                               [  7.71000000e+02,   1.07216721e+13],
                               [  7.72000000e+02,   1.07053078e+13],
                               [  7.73000000e+02,   1.06889276e+13],
                               [  7.74000000e+02,   1.06725317e+13],
                               [  7.75000000e+02,   1.06561206e+13],
                               [  7.76000000e+02,   1.06396947e+13],
                               [  7.77000000e+02,   1.06232545e+13],
                               [  7.78000000e+02,   1.06068004e+13],
                               [  7.79000000e+02,   1.05903327e+13],
                               [  7.80000000e+02,   1.05738520e+13],
                               [  7.81000000e+02,   1.05573585e+13],
                               [  7.82000000e+02,   1.05408527e+13],
                               [  7.83000000e+02,   1.05243351e+13],
                               [  7.84000000e+02,   1.05078060e+13],
                               [  7.85000000e+02,   1.04912657e+13],
                               [  7.86000000e+02,   1.04747147e+13],
                               [  7.87000000e+02,   1.04581535e+13],
                               [  7.88000000e+02,   1.04415822e+13],
                               [  7.89000000e+02,   1.04250014e+13],
                               [  7.90000000e+02,   1.04084115e+13],
                               [  7.91000000e+02,   1.03918127e+13],
                               [  7.92000000e+02,   1.03752055e+13],
                               [  7.93000000e+02,   1.03585902e+13],
                               [  7.94000000e+02,   1.03419672e+13],
                               [  7.95000000e+02,   1.03253369e+13],
                               [  7.96000000e+02,   1.03086995e+13],
                               [  7.97000000e+02,   1.02920556e+13],
                               [  7.98000000e+02,   1.02754053e+13],
                               [  7.99000000e+02,   1.02587492e+13],
                               [  8.00000000e+02,   1.02420874e+13],
                               [  8.01000000e+02,   1.02254204e+13],
                               [  8.02000000e+02,   1.02087485e+13],
                               [  8.03000000e+02,   1.01920720e+13],
                               [  8.04000000e+02,   1.01753913e+13],
                               [  8.05000000e+02,   1.01587067e+13],
                               [  8.06000000e+02,   1.01420186e+13],
                               [  8.07000000e+02,   1.01253271e+13],
                               [  8.08000000e+02,   1.01086328e+13],
                               [  8.09000000e+02,   1.00919358e+13],
                               [  8.10000000e+02,   1.00752366e+13],
                               [  8.11000000e+02,   1.00585353e+13],
                               [  8.12000000e+02,   1.00418324e+13],
                               [  8.13000000e+02,   1.00251282e+13],
                               [  8.14000000e+02,   1.00084228e+13],
                               [  8.15000000e+02,   9.99171677e+12],
                               [  8.16000000e+02,   9.97501023e+12],
                               [  8.17000000e+02,   9.95830354e+12],
                               [  8.18000000e+02,   9.94159699e+12],
                               [  8.19000000e+02,   9.92489086e+12],
                               [  8.20000000e+02,   9.90818544e+12],
                               [  8.21000000e+02,   9.89148102e+12],
                               [  8.22000000e+02,   9.87477789e+12],
                               [  8.23000000e+02,   9.85807631e+12],
                               [  8.24000000e+02,   9.84137658e+12],
                               [  8.25000000e+02,   9.82467896e+12],
                               [  8.26000000e+02,   9.80798374e+12],
                               [  8.27000000e+02,   9.79129116e+12],
                               [  8.28000000e+02,   9.77460152e+12],
                               [  8.29000000e+02,   9.75791506e+12],
                               [  8.30000000e+02,   9.74123205e+12]],
                              interpolator=SpragueInterpolator,
                              interpolator_args={},
                              extrapolator=Extrapolator,
                              extrapolator_args={...})
    """

    wavelengths = shape.range()
    return SpectralPowerDistribution(data=dict(
        zip(wavelengths, planck_law(wavelengths * 1e-9, temperature, c1, c2,
                                    n))),
                                     name='{0}K Blackbody'.format(temperature))
示例#26
0
def rayleigh_scattering_spd(shape=DEFAULT_SPECTRAL_SHAPE,
                            CO2_concentration=STANDARD_CO2_CONCENTRATION,
                            temperature=STANDARD_AIR_TEMPERATURE,
                            pressure=AVERAGE_PRESSURE_MEAN_SEA_LEVEL,
                            latitude=DEFAULT_LATITUDE,
                            altitude=DEFAULT_ALTITUDE,
                            avogadro_constant=AVOGADRO_CONSTANT,
                            n_s=air_refraction_index_Bodhaine1999,
                            F_air=F_air_Bodhaine1999):
    """
    Returns the *Rayleigh* spectral power distribution for given spectral
    shape.

    Parameters
    ----------
    shape : SpectralShape, optional
        Spectral shape used to create the *Rayleigh* scattering spectral power
        distribution.
    CO2_concentration : numeric or array_like, optional
        :math:`CO_2` concentration in parts per million (ppm).
    temperature : numeric or array_like, optional
        Air temperature :math:`T[K]` in kelvin degrees.
    pressure : numeric or array_like
        Surface pressure :math:`P` of the measurement site.
    latitude : numeric or array_like, optional
        Latitude of the site in degrees.
    altitude : numeric or array_like, optional
        Altitude of the site in meters.
    avogadro_constant : numeric or array_like, optional
        *Avogadro*'s number (molecules :math:`mol^{-1}`).
    n_s : object
        Air refraction index :math:`n_s` computation method.
    F_air : object
        :math:`(6+3_p)/(6-7_p)`, the depolarisation term :math:`F(air)` or
        *King Factor* computation method.

    Returns
    -------
    SpectralPowerDistribution
        *Rayleigh* optical depth spectral power distribution.

    References
    ----------
    -   :cite:`Bodhaine1999a`
    -   :cite:`Wikipediabx`

    Examples
    --------
    >>> from colour.utilities import numpy_print_options
    >>> with numpy_print_options(suppress=True):
    ...     rayleigh_scattering_spd()  # doctest: +ELLIPSIS
    SpectralPowerDistribution([[ 360.        ,    0.5991013...],
                               [ 361.        ,    0.5921706...],
                               [ 362.        ,    0.5853410...],
                               [ 363.        ,    0.5786105...],
                               [ 364.        ,    0.5719774...],
                               [ 365.        ,    0.5654401...],
                               [ 366.        ,    0.5589968...],
                               [ 367.        ,    0.5526460...],
                               [ 368.        ,    0.5463860...],
                               [ 369.        ,    0.5402153...],
                               [ 370.        ,    0.5341322...],
                               [ 371.        ,    0.5281354...],
                               [ 372.        ,    0.5222234...],
                               [ 373.        ,    0.5163946...],
                               [ 374.        ,    0.5106476...],
                               [ 375.        ,    0.5049812...],
                               [ 376.        ,    0.4993939...],
                               [ 377.        ,    0.4938844...],
                               [ 378.        ,    0.4884513...],
                               [ 379.        ,    0.4830934...],
                               [ 380.        ,    0.4778095...],
                               [ 381.        ,    0.4725983...],
                               [ 382.        ,    0.4674585...],
                               [ 383.        ,    0.4623891...],
                               [ 384.        ,    0.4573889...],
                               [ 385.        ,    0.4524566...],
                               [ 386.        ,    0.4475912...],
                               [ 387.        ,    0.4427917...],
                               [ 388.        ,    0.4380568...],
                               [ 389.        ,    0.4333856...],
                               [ 390.        ,    0.4287771...],
                               [ 391.        ,    0.4242302...],
                               [ 392.        ,    0.4197439...],
                               [ 393.        ,    0.4153172...],
                               [ 394.        ,    0.4109493...],
                               [ 395.        ,    0.4066391...],
                               [ 396.        ,    0.4023857...],
                               [ 397.        ,    0.3981882...],
                               [ 398.        ,    0.3940458...],
                               [ 399.        ,    0.3899576...],
                               [ 400.        ,    0.3859227...],
                               [ 401.        ,    0.3819402...],
                               [ 402.        ,    0.3780094...],
                               [ 403.        ,    0.3741295...],
                               [ 404.        ,    0.3702996...],
                               [ 405.        ,    0.366519 ...],
                               [ 406.        ,    0.3627868...],
                               [ 407.        ,    0.3591025...],
                               [ 408.        ,    0.3554651...],
                               [ 409.        ,    0.3518740...],
                               [ 410.        ,    0.3483286...],
                               [ 411.        ,    0.344828 ...],
                               [ 412.        ,    0.3413716...],
                               [ 413.        ,    0.3379587...],
                               [ 414.        ,    0.3345887...],
                               [ 415.        ,    0.3312609...],
                               [ 416.        ,    0.3279747...],
                               [ 417.        ,    0.3247294...],
                               [ 418.        ,    0.3215245...],
                               [ 419.        ,    0.3183593...],
                               [ 420.        ,    0.3152332...],
                               [ 421.        ,    0.3121457...],
                               [ 422.        ,    0.3090962...],
                               [ 423.        ,    0.3060841...],
                               [ 424.        ,    0.3031088...],
                               [ 425.        ,    0.3001699...],
                               [ 426.        ,    0.2972668...],
                               [ 427.        ,    0.2943989...],
                               [ 428.        ,    0.2915657...],
                               [ 429.        ,    0.2887668...],
                               [ 430.        ,    0.2860017...],
                               [ 431.        ,    0.2832697...],
                               [ 432.        ,    0.2805706...],
                               [ 433.        ,    0.2779037...],
                               [ 434.        ,    0.2752687...],
                               [ 435.        ,    0.2726650...],
                               [ 436.        ,    0.2700922...],
                               [ 437.        ,    0.2675500...],
                               [ 438.        ,    0.2650377...],
                               [ 439.        ,    0.2625551...],
                               [ 440.        ,    0.2601016...],
                               [ 441.        ,    0.2576770...],
                               [ 442.        ,    0.2552807...],
                               [ 443.        ,    0.2529124...],
                               [ 444.        ,    0.2505716...],
                               [ 445.        ,    0.2482581...],
                               [ 446.        ,    0.2459713...],
                               [ 447.        ,    0.2437110...],
                               [ 448.        ,    0.2414768...],
                               [ 449.        ,    0.2392683...],
                               [ 450.        ,    0.2370851...],
                               [ 451.        ,    0.2349269...],
                               [ 452.        ,    0.2327933...],
                               [ 453.        ,    0.2306841...],
                               [ 454.        ,    0.2285989...],
                               [ 455.        ,    0.2265373...],
                               [ 456.        ,    0.2244990...],
                               [ 457.        ,    0.2224838...],
                               [ 458.        ,    0.2204912...],
                               [ 459.        ,    0.2185211...],
                               [ 460.        ,    0.2165730...],
                               [ 461.        ,    0.2146467...],
                               [ 462.        ,    0.2127419...],
                               [ 463.        ,    0.2108583...],
                               [ 464.        ,    0.2089957...],
                               [ 465.        ,    0.2071536...],
                               [ 466.        ,    0.2053320...],
                               [ 467.        ,    0.2035304...],
                               [ 468.        ,    0.2017487...],
                               [ 469.        ,    0.1999865...],
                               [ 470.        ,    0.1982436...],
                               [ 471.        ,    0.1965198...],
                               [ 472.        ,    0.1948148...],
                               [ 473.        ,    0.1931284...],
                               [ 474.        ,    0.1914602...],
                               [ 475.        ,    0.1898101...],
                               [ 476.        ,    0.1881779...],
                               [ 477.        ,    0.1865633...],
                               [ 478.        ,    0.1849660...],
                               [ 479.        ,    0.1833859...],
                               [ 480.        ,    0.1818227...],
                               [ 481.        ,    0.1802762...],
                               [ 482.        ,    0.1787463...],
                               [ 483.        ,    0.1772326...],
                               [ 484.        ,    0.1757349...],
                               [ 485.        ,    0.1742532...],
                               [ 486.        ,    0.1727871...],
                               [ 487.        ,    0.1713365...],
                               [ 488.        ,    0.1699011...],
                               [ 489.        ,    0.1684809...],
                               [ 490.        ,    0.1670755...],
                               [ 491.        ,    0.1656848...],
                               [ 492.        ,    0.1643086...],
                               [ 493.        ,    0.1629468...],
                               [ 494.        ,    0.1615991...],
                               [ 495.        ,    0.1602654...],
                               [ 496.        ,    0.1589455...],
                               [ 497.        ,    0.1576392...],
                               [ 498.        ,    0.1563464...],
                               [ 499.        ,    0.1550668...],
                               [ 500.        ,    0.1538004...],
                               [ 501.        ,    0.1525470...],
                               [ 502.        ,    0.1513063...],
                               [ 503.        ,    0.1500783...],
                               [ 504.        ,    0.1488628...],
                               [ 505.        ,    0.1476597...],
                               [ 506.        ,    0.1464687...],
                               [ 507.        ,    0.1452898...],
                               [ 508.        ,    0.1441228...],
                               [ 509.        ,    0.1429675...],
                               [ 510.        ,    0.1418238...],
                               [ 511.        ,    0.1406916...],
                               [ 512.        ,    0.1395707...],
                               [ 513.        ,    0.1384610...],
                               [ 514.        ,    0.1373624...],
                               [ 515.        ,    0.1362747...],
                               [ 516.        ,    0.1351978...],
                               [ 517.        ,    0.1341316...],
                               [ 518.        ,    0.1330759...],
                               [ 519.        ,    0.1320306...],
                               [ 520.        ,    0.1309956...],
                               [ 521.        ,    0.1299707...],
                               [ 522.        ,    0.1289559...],
                               [ 523.        ,    0.1279511...],
                               [ 524.        ,    0.1269560...],
                               [ 525.        ,    0.1259707...],
                               [ 526.        ,    0.1249949...],
                               [ 527.        ,    0.1240286...],
                               [ 528.        ,    0.1230717...],
                               [ 529.        ,    0.1221240...],
                               [ 530.        ,    0.1211855...],
                               [ 531.        ,    0.1202560...],
                               [ 532.        ,    0.1193354...],
                               [ 533.        ,    0.1184237...],
                               [ 534.        ,    0.1175207...],
                               [ 535.        ,    0.1166263...],
                               [ 536.        ,    0.1157404...],
                               [ 537.        ,    0.1148630...],
                               [ 538.        ,    0.1139939...],
                               [ 539.        ,    0.1131331...],
                               [ 540.        ,    0.1122804...],
                               [ 541.        ,    0.1114357...],
                               [ 542.        ,    0.1105990...],
                               [ 543.        ,    0.1097702...],
                               [ 544.        ,    0.1089492...],
                               [ 545.        ,    0.1081358...],
                               [ 546.        ,    0.1073301...],
                               [ 547.        ,    0.1065319...],
                               [ 548.        ,    0.1057411...],
                               [ 549.        ,    0.1049577...],
                               [ 550.        ,    0.1041815...],
                               [ 551.        ,    0.1034125...],
                               [ 552.        ,    0.1026507...],
                               [ 553.        ,    0.1018958...],
                               [ 554.        ,    0.1011480...],
                               [ 555.        ,    0.1004070...],
                               [ 556.        ,    0.0996728...],
                               [ 557.        ,    0.0989453...],
                               [ 558.        ,    0.0982245...],
                               [ 559.        ,    0.0975102...],
                               [ 560.        ,    0.0968025...],
                               [ 561.        ,    0.0961012...],
                               [ 562.        ,    0.0954062...],
                               [ 563.        ,    0.0947176...],
                               [ 564.        ,    0.0940352...],
                               [ 565.        ,    0.0933589...],
                               [ 566.        ,    0.0926887...],
                               [ 567.        ,    0.0920246...],
                               [ 568.        ,    0.0913664...],
                               [ 569.        ,    0.0907141...],
                               [ 570.        ,    0.0900677...],
                               [ 571.        ,    0.0894270...],
                               [ 572.        ,    0.0887920...],
                               [ 573.        ,    0.0881627...],
                               [ 574.        ,    0.0875389...],
                               [ 575.        ,    0.0869207...],
                               [ 576.        ,    0.0863079...],
                               [ 577.        ,    0.0857006...],
                               [ 578.        ,    0.0850986...],
                               [ 579.        ,    0.0845019...],
                               [ 580.        ,    0.0839104...],
                               [ 581.        ,    0.0833242...],
                               [ 582.        ,    0.0827430...],
                               [ 583.        ,    0.082167 ...],
                               [ 584.        ,    0.0815959...],
                               [ 585.        ,    0.0810298...],
                               [ 586.        ,    0.0804687...],
                               [ 587.        ,    0.0799124...],
                               [ 588.        ,    0.0793609...],
                               [ 589.        ,    0.0788142...],
                               [ 590.        ,    0.0782722...],
                               [ 591.        ,    0.0777349...],
                               [ 592.        ,    0.0772022...],
                               [ 593.        ,    0.0766740...],
                               [ 594.        ,    0.0761504...],
                               [ 595.        ,    0.0756313...],
                               [ 596.        ,    0.0751166...],
                               [ 597.        ,    0.0746063...],
                               [ 598.        ,    0.0741003...],
                               [ 599.        ,    0.0735986...],
                               [ 600.        ,    0.0731012...],
                               [ 601.        ,    0.072608 ...],
                               [ 602.        ,    0.0721189...],
                               [ 603.        ,    0.0716340...],
                               [ 604.        ,    0.0711531...],
                               [ 605.        ,    0.0706763...],
                               [ 606.        ,    0.0702035...],
                               [ 607.        ,    0.0697347...],
                               [ 608.        ,    0.0692697...],
                               [ 609.        ,    0.0688087...],
                               [ 610.        ,    0.0683515...],
                               [ 611.        ,    0.0678981...],
                               [ 612.        ,    0.0674485...],
                               [ 613.        ,    0.0670026...],
                               [ 614.        ,    0.0665603...],
                               [ 615.        ,    0.0661218...],
                               [ 616.        ,    0.0656868...],
                               [ 617.        ,    0.0652555...],
                               [ 618.        ,    0.0648277...],
                               [ 619.        ,    0.0644033...],
                               [ 620.        ,    0.0639825...],
                               [ 621.        ,    0.0635651...],
                               [ 622.        ,    0.0631512...],
                               [ 623.        ,    0.0627406...],
                               [ 624.        ,    0.0623333...],
                               [ 625.        ,    0.0619293...],
                               [ 626.        ,    0.0615287...],
                               [ 627.        ,    0.0611312...],
                               [ 628.        ,    0.0607370...],
                               [ 629.        ,    0.0603460...],
                               [ 630.        ,    0.0599581...],
                               [ 631.        ,    0.0595733...],
                               [ 632.        ,    0.0591917...],
                               [ 633.        ,    0.0588131...],
                               [ 634.        ,    0.0584375...],
                               [ 635.        ,    0.0580649...],
                               [ 636.        ,    0.0576953...],
                               [ 637.        ,    0.0573286...],
                               [ 638.        ,    0.0569649...],
                               [ 639.        ,    0.0566040...],
                               [ 640.        ,    0.0562460...],
                               [ 641.        ,    0.0558909...],
                               [ 642.        ,    0.0555385...],
                               [ 643.        ,    0.0551890...],
                               [ 644.        ,    0.0548421...],
                               [ 645.        ,    0.0544981...],
                               [ 646.        ,    0.0541567...],
                               [ 647.        ,    0.053818 ...],
                               [ 648.        ,    0.0534819...],
                               [ 649.        ,    0.0531485...],
                               [ 650.        ,    0.0528176...],
                               [ 651.        ,    0.0524894...],
                               [ 652.        ,    0.0521637...],
                               [ 653.        ,    0.0518405...],
                               [ 654.        ,    0.0515198...],
                               [ 655.        ,    0.0512017...],
                               [ 656.        ,    0.0508859...],
                               [ 657.        ,    0.0505726...],
                               [ 658.        ,    0.0502618...],
                               [ 659.        ,    0.0499533...],
                               [ 660.        ,    0.0496472...],
                               [ 661.        ,    0.0493434...],
                               [ 662.        ,    0.0490420...],
                               [ 663.        ,    0.0487428...],
                               [ 664.        ,    0.0484460...],
                               [ 665.        ,    0.0481514...],
                               [ 666.        ,    0.0478591...],
                               [ 667.        ,    0.0475689...],
                               [ 668.        ,    0.0472810...],
                               [ 669.        ,    0.0469953...],
                               [ 670.        ,    0.0467117...],
                               [ 671.        ,    0.0464302...],
                               [ 672.        ,    0.0461509...],
                               [ 673.        ,    0.0458737...],
                               [ 674.        ,    0.0455986...],
                               [ 675.        ,    0.0453255...],
                               [ 676.        ,    0.0450545...],
                               [ 677.        ,    0.0447855...],
                               [ 678.        ,    0.0445185...],
                               [ 679.        ,    0.0442535...],
                               [ 680.        ,    0.0439905...],
                               [ 681.        ,    0.0437294...],
                               [ 682.        ,    0.0434703...],
                               [ 683.        ,    0.0432131...],
                               [ 684.        ,    0.0429578...],
                               [ 685.        ,    0.0427044...],
                               [ 686.        ,    0.0424529...],
                               [ 687.        ,    0.0422032...],
                               [ 688.        ,    0.0419553...],
                               [ 689.        ,    0.0417093...],
                               [ 690.        ,    0.0414651...],
                               [ 691.        ,    0.0412226...],
                               [ 692.        ,    0.0409820...],
                               [ 693.        ,    0.0407431...],
                               [ 694.        ,    0.0405059...],
                               [ 695.        ,    0.0402705...],
                               [ 696.        ,    0.0400368...],
                               [ 697.        ,    0.0398047...],
                               [ 698.        ,    0.0395744...],
                               [ 699.        ,    0.0393457...],
                               [ 700.        ,    0.0391187...],
                               [ 701.        ,    0.0388933...],
                               [ 702.        ,    0.0386696...],
                               [ 703.        ,    0.0384474...],
                               [ 704.        ,    0.0382269...],
                               [ 705.        ,    0.0380079...],
                               [ 706.        ,    0.0377905...],
                               [ 707.        ,    0.0375747...],
                               [ 708.        ,    0.0373604...],
                               [ 709.        ,    0.0371476...],
                               [ 710.        ,    0.0369364...],
                               [ 711.        ,    0.0367266...],
                               [ 712.        ,    0.0365184...],
                               [ 713.        ,    0.0363116...],
                               [ 714.        ,    0.0361063...],
                               [ 715.        ,    0.0359024...],
                               [ 716.        ,    0.0357000...],
                               [ 717.        ,    0.0354990...],
                               [ 718.        ,    0.0352994...],
                               [ 719.        ,    0.0351012...],
                               [ 720.        ,    0.0349044...],
                               [ 721.        ,    0.0347090...],
                               [ 722.        ,    0.0345150...],
                               [ 723.        ,    0.0343223...],
                               [ 724.        ,    0.0341310...],
                               [ 725.        ,    0.0339410...],
                               [ 726.        ,    0.0337523...],
                               [ 727.        ,    0.033565 ...],
                               [ 728.        ,    0.0333789...],
                               [ 729.        ,    0.0331941...],
                               [ 730.        ,    0.0330106...],
                               [ 731.        ,    0.0328284...],
                               [ 732.        ,    0.0326474...],
                               [ 733.        ,    0.0324677...],
                               [ 734.        ,    0.0322893...],
                               [ 735.        ,    0.0321120...],
                               [ 736.        ,    0.0319360...],
                               [ 737.        ,    0.0317611...],
                               [ 738.        ,    0.0315875...],
                               [ 739.        ,    0.0314151...],
                               [ 740.        ,    0.0312438...],
                               [ 741.        ,    0.0310737...],
                               [ 742.        ,    0.0309048...],
                               [ 743.        ,    0.0307370...],
                               [ 744.        ,    0.0305703...],
                               [ 745.        ,    0.0304048...],
                               [ 746.        ,    0.0302404...],
                               [ 747.        ,    0.0300771...],
                               [ 748.        ,    0.0299149...],
                               [ 749.        ,    0.0297538...],
                               [ 750.        ,    0.0295938...],
                               [ 751.        ,    0.0294349...],
                               [ 752.        ,    0.0292771...],
                               [ 753.        ,    0.0291203...],
                               [ 754.        ,    0.0289645...],
                               [ 755.        ,    0.0288098...],
                               [ 756.        ,    0.0286561...],
                               [ 757.        ,    0.0285035...],
                               [ 758.        ,    0.0283518...],
                               [ 759.        ,    0.0282012...],
                               [ 760.        ,    0.0280516...],
                               [ 761.        ,    0.0279030...],
                               [ 762.        ,    0.0277553...],
                               [ 763.        ,    0.0276086...],
                               [ 764.        ,    0.027463 ...],
                               [ 765.        ,    0.0273182...],
                               [ 766.        ,    0.0271744...],
                               [ 767.        ,    0.0270316...],
                               [ 768.        ,    0.0268897...],
                               [ 769.        ,    0.0267487...],
                               [ 770.        ,    0.0266087...],
                               [ 771.        ,    0.0264696...],
                               [ 772.        ,    0.0263314...],
                               [ 773.        ,    0.0261941...],
                               [ 774.        ,    0.0260576...],
                               [ 775.        ,    0.0259221...],
                               [ 776.        ,    0.0257875...],
                               [ 777.        ,    0.0256537...],
                               [ 778.        ,    0.0255208...],
                               [ 779.        ,    0.0253888...],
                               [ 780.        ,    0.0252576...]],
                              interpolator=SpragueInterpolator,
                              interpolator_args={},
                              extrapolator=Extrapolator,
                              extrapolator_args={...})
    """

    wavelengths = shape.range()
    return SpectralPowerDistribution(
        data=dict(
            zip(
                wavelengths,
                rayleigh_optical_depth(wavelengths * 10e-8, CO2_concentration,
                                       temperature, pressure, latitude,
                                       altitude, avogadro_constant, n_s,
                                       F_air))),
        name=('Rayleigh Scattering - {0} ppm, {1} K, {2} Pa, {3} Degrees, '
              '{4} m').format(CO2_concentration, temperature, pressure,
                              latitude, altitude))
示例#27
0
文件: xrite.py 项目: scooperly/colour
def read_spds_from_xrite_file(path):
    """
    Reads the spectral data from given *X-Rite* file and returns it as an
    *OrderedDict* of
    :class:`colour.colorimetry.spectrum.SpectralPowerDistribution` classes.

    Parameters
    ----------
    path : unicode
        Absolute *X-Rite* file path.

    Returns
    -------
    OrderedDict
        :class:`colour.colorimetry.spectrum.SpectralPowerDistribution`
        classes of given *X-Rite* file.

    Notes
    -----
    -   This parser is minimalistic and absolutely not bullet proof.

    Examples
    --------
    >>> import os
    >>> from pprint import pprint
    >>> xrite_file = os.path.join(
    ...     os.path.dirname(__file__),
    ...     'tests',
    ...     'resources',
    ...     'xrite_digital_colour_checker.txt')
    >>> spds_data = read_spds_from_xrite_file(xrite_file)
    >>> pprint(list(spds_data.keys()))  # doctest: +SKIP
    ['X1', 'X2', 'X3', 'X4', 'X5', 'X6', 'X7', 'X8', 'X9', 'X10']
    """

    with codecs.open(path, encoding=XRITE_FILE_ENCODING) as xrite_file:
        lines = xrite_file.read().strip().split('\n')

        xrite_spds = OrderedDict()
        is_spectral_data_format, is_spectral_data = False, False
        for line in lines:
            line = line.strip()

            if line == 'END_DATA_FORMAT':
                is_spectral_data_format = False

            if line == 'END_DATA':
                is_spectral_data = False

            if is_spectral_data_format:
                wavelengths = [float(x) for x in re.findall('nm(\d+)', line)]
                index = len(wavelengths)

            if is_spectral_data:
                tokens = line.split()
                values = [float(x) for x in tokens[-index:]]
                xrite_spds[tokens[1]] = (SpectralPowerDistribution(
                    tokens[1], dict(zip(wavelengths, values))))

            if line == 'BEGIN_DATA_FORMAT':
                is_spectral_data_format = True

            if line == 'BEGIN_DATA':
                is_spectral_data = True

        return xrite_spds
示例#28
0
    3905.0: 0.00959,
    3910.0: 0.00952,
    3915.0: 0.00950,
    3920.0: 0.00941,
    3925.0: 0.00940,
    3930.0: 0.00932,
    3935.0: 0.00930,
    3940.0: 0.00923,
    3945.0: 0.00920,
    3950.0: 0.00911,
    3955.0: 0.00908,
    3960.0: 0.00902,
    3965.0: 0.00901,
    3970.0: 0.00893,
    3975.0: 0.00891,
    3980.0: 0.00884,
    3985.0: 0.00880,
    3990.0: 0.00878,
    3995.0: 0.00870,
    4000.0: 0.00868}

ASTM_G_173_ETR = SpectralPowerDistribution('ASTM G-173 ETR',
                                           ASTM_G_173_ETR_DATA)

"""
Extraterrestrial Radiation (solar spectrum at top of atmosphere) at mean
Earth-Sun distance.

ASTM_G_173_ETR : SpectralPowerDistribution
"""
示例#29
0
SAMPLE_SPD = SpectralPowerDistribution({
    340: 0.0000,
    345: 0.0000,
    350: 0.0000,
    355: 0.0000,
    360: 0.0000,
    365: 0.0000,
    370: 0.0000,
    375: 0.0000,
    380: 0.0000,
    385: 0.0000,
    390: 0.0000,
    395: 0.0000,
    400: 0.0641,
    405: 0.0650,
    410: 0.0654,
    415: 0.0652,
    420: 0.0645,
    425: 0.0629,
    430: 0.0605,
    435: 0.0581,
    440: 0.0562,
    445: 0.0551,
    450: 0.0543,
    455: 0.0539,
    460: 0.0537,
    465: 0.0538,
    470: 0.0541,
    475: 0.0547,
    480: 0.0559,
    485: 0.0578,
    490: 0.0603,
    495: 0.0629,
    500: 0.0651,
    505: 0.0667,
    510: 0.0680,
    515: 0.0691,
    520: 0.0705,
    525: 0.0720,
    530: 0.0736,
    535: 0.0753,
    540: 0.0772,
    545: 0.0791,
    550: 0.0809,
    555: 0.0833,
    560: 0.0870,
    565: 0.0924,
    570: 0.0990,
    575: 0.1061,
    580: 0.1128,
    585: 0.1190,
    590: 0.1251,
    595: 0.1308,
    600: 0.1360,
    605: 0.1403,
    610: 0.1439,
    615: 0.1473,
    620: 0.1511,
    625: 0.1550,
    630: 0.1590,
    635: 0.1634,
    640: 0.1688,
    645: 0.1753,
    650: 0.1828,
    655: 0.1909,
    660: 0.1996,
    665: 0.2088,
    670: 0.2187,
    675: 0.2291,
    680: 0.2397,
    685: 0.2505,
    690: 0.2618,
    695: 0.2733,
    700: 0.2852,
    705: 0.0000,
    710: 0.0000,
    715: 0.0000,
    720: 0.0000,
    725: 0.0000,
    730: 0.0000,
    735: 0.0000,
    740: 0.0000,
    745: 0.0000,
    750: 0.0000,
    755: 0.0000,
    760: 0.0000,
    765: 0.0000,
    770: 0.0000,
    775: 0.0000,
    780: 0.0000,
    785: 0.0000,
    790: 0.0000,
    795: 0.0000,
    800: 0.0000,
    805: 0.0000,
    810: 0.0000,
    815: 0.0000,
    820: 0.0000,
    825: 0.0000,
    830: 0.0000
})
示例#30
0
def D_illuminant_relative_spd(xy):
    """
    Returns the relative spectral power distribution of given
    *CIE Standard Illuminant D Series* using given *xy* chromaticity
    coordinates.

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

    Parameters
    ----------
    xy : array_like
        *xy* chromaticity coordinates.

    Returns
    -------
    SpectralPowerDistribution
        *CIE Standard Illuminant D Series* relative spectral power
        distribution.

    Examples
    --------
    >>> from colour.utilities import numpy_print_options
    >>> xy = np.array([0.34570, 0.35850])
    >>> with numpy_print_options(suppress=True):
    ...     D_illuminant_relative_spd(xy)  # doctest: +ELLIPSIS
    SpectralPowerDistribution([[ 300.        ,    0.0193039...],
                               [ 310.        ,    2.1265303...],
                               [ 320.        ,    7.9867359...],
                               [ 330.        ,   15.1666959...],
                               [ 340.        ,   18.3413202...],
                               [ 350.        ,   21.3757973...],
                               [ 360.        ,   24.2528862...],
                               [ 370.        ,   26.2782171...],
                               [ 380.        ,   24.7348842...],
                               [ 390.        ,   30.0518667...],
                               [ 400.        ,   49.458942 ...],
                               [ 410.        ,   56.6929605...],
                               [ 420.        ,   60.1981682...],
                               [ 430.        ,   57.9390276...],
                               [ 440.        ,   74.9047554...],
                               [ 450.        ,   87.3151258...],
                               [ 460.        ,   90.6691236...],
                               [ 470.        ,   91.4109985...],
                               [ 480.        ,   95.1362798...],
                               [ 490.        ,   91.9956940...],
                               [ 500.        ,   95.7488852...],
                               [ 510.        ,   96.6315995...],
                               [ 520.        ,   97.1308377...],
                               [ 530.        ,  102.0961518...],
                               [ 540.        ,  100.7580555...],
                               [ 550.        ,  102.3164095...],
                               [ 560.        ,  100.       ...],
                               [ 570.        ,   97.7339937...],
                               [ 580.        ,   98.9175842...],
                               [ 590.        ,   93.5440898...],
                               [ 600.        ,   97.7548532...],
                               [ 610.        ,   99.3559831...],
                               [ 620.        ,   99.1396431...],
                               [ 630.        ,   95.8275899...],
                               [ 640.        ,   99.0028159...],
                               [ 650.        ,   95.8307955...],
                               [ 660.        ,   98.3850717...],
                               [ 670.        ,  103.2245516...],
                               [ 680.        ,   99.3672578...],
                               [ 690.        ,   87.5676019...],
                               [ 700.        ,   91.8218781...],
                               [ 710.        ,   93.0772354...],
                               [ 720.        ,   77.0098456...],
                               [ 730.        ,   86.6795856...],
                               [ 740.        ,   92.7570922...],
                               [ 750.        ,   78.3784557...],
                               [ 760.        ,   57.8075859...],
                               [ 770.        ,   83.0873522...],
                               [ 780.        ,   78.4245724...],
                               [ 790.        ,   79.7098456...],
                               [ 800.        ,   73.5435857...],
                               [ 810.        ,   64.0424558...],
                               [ 820.        ,   70.9121958...],
                               [ 830.        ,   74.5862223...]],
                              interpolator=SpragueInterpolator,
                              interpolator_args={},
                              extrapolator=Extrapolator,
                              extrapolator_args={...})
    """

    M = 0.0241 + 0.2562 * xy[0] - 0.7341 * xy[1]
    M1 = (-1.3515 - 1.7703 * xy[0] + 5.9114 * xy[1]) / M
    M2 = (0.0300 - 31.4424 * xy[0] + 30.0717 * xy[1]) / M

    distribution = {}
    for i in D_ILLUMINANTS_S_SPDS['S0'].shape:
        S0 = D_ILLUMINANTS_S_SPDS['S0'][i]
        S1 = D_ILLUMINANTS_S_SPDS['S1'][i]
        S2 = D_ILLUMINANTS_S_SPDS['S2'][i]
        distribution[i] = S0 + M1 * S1 + M2 * S2

    return SpectralPowerDistribution(distribution,
                                     name='CIE Standard Illuminant D Series')
示例#31
0
        720: 7.0,
        730: 7.6,
        740: 8.0,
        750: 6.7,
        760: 5.2,
        770: 7.4,
        780: 6.8,
        790: 7.0,
        800: 6.4,
        810: 5.5,
        820: 6.1,
        830: 6.5
    }
}

D_ILLUMINANTS_S_SPDS = CaseInsensitiveMapping({
    'S0':
    SpectralPowerDistribution('S0', D_ILLUMINANTS_S_SPDS_DATA['S0']),
    'S1':
    SpectralPowerDistribution('S1', D_ILLUMINANTS_S_SPDS_DATA['S1']),
    'S2':
    SpectralPowerDistribution('S2', D_ILLUMINANTS_S_SPDS_DATA['S2'])
})
"""
*CIE Standard Illuminant D Series* :math:`S_n(\lambda)` spectral power
distributions

D_ILLUMINANTS_S_SPDS : CaseInsensitiveMapping
   **{'S0', 'S1', 'S1'}**
"""
示例#32
0
文件: lefs.py 项目: Nick-Shaw/colour
def mesopic_luminous_efficiency_function(
        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')):
    """
    Returns the mesopic luminous efficiency function :math:`V_m(\lambda)` for
    given photopic luminance :math:`L_p`.

    Parameters
    ----------
    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
    -------
    SpectralPowerDistribution
        Mesopic luminous efficiency function :math:`V_m(\lambda)`.

    Examples
    --------
    >>> print(mesopic_luminous_efficiency_function(0.2))
    SpectralPowerDistribution(\
'0.2 Lp Mesopic Luminous Efficiency Function', (380.0, 780.0, 1.0))
    """

    photopic_lef_shape = photopic_lef.shape
    scotopic_lef_shape = scotopic_lef.shape
    shape = SpectralShape(
        max(photopic_lef_shape.start, scotopic_lef_shape.start),
        min(photopic_lef_shape.end, scotopic_lef_shape.end),
        max(photopic_lef_shape.interval, scotopic_lef_shape.interval))

    wavelengths = shape.range()

    spd_data = dict(zip(wavelengths,
                        mesopic_weighting_function(
                            wavelengths,
                            Lp,
                            source,
                            method,
                            photopic_lef,
                            scotopic_lef)))

    spd = SpectralPowerDistribution(
        '{0} Lp Mesopic Luminous Efficiency Function'.format(Lp),
        spd_data)

    return spd.normalise()