Пример #1
0
    def test_spectral_to_XYZ_integration(self):
        """
        Tests :func:`colour.colorimetry.tristimulus.\
spectral_to_XYZ_integration`
        definition.
        """

        cmfs = CMFS['CIE 1931 2 Degree Standard Observer']
        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(SAMPLE_SPD, cmfs,
                                        ILLUMINANTS_RELATIVE_SPDS['A']),
            np.array([14.46365624, 10.85827910, 2.04662343]),
            decimal=7)

        cmfs = CMFS['CIE 1964 10 Degree Standard Observer']
        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(SAMPLE_SPD, cmfs,
                                        ILLUMINANTS_RELATIVE_SPDS['C']),
            np.array([10.77031004, 9.44863775, 6.62745989]),
            decimal=7)

        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(SAMPLE_SPD, cmfs,
                                        ILLUMINANTS_RELATIVE_SPDS['F2']),
            np.array([11.57834054, 9.98738373, 3.95462625]),
            decimal=7)
Пример #2
0
    def test_spectral_to_XYZ_integration(self):
        """
        Tests :func:`colour.colorimetry.tristimulus.\
spectral_to_XYZ_integration`
        definition.
        """

        cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                SAMPLE_SPD,
                cmfs,
                ILLUMINANTS_RELATIVE_SPDS.get('A')),
            np.array([14.46365624, 10.85827910, 2.04662343]),
            decimal=7)

        cmfs = CMFS.get('CIE 1964 10 Degree Standard Observer')
        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                SAMPLE_SPD,
                cmfs,
                ILLUMINANTS_RELATIVE_SPDS.get('C')),
            np.array([10.77031004, 9.44863775, 6.62745989]),
            decimal=7)

        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                SAMPLE_SPD,
                cmfs,
                ILLUMINANTS_RELATIVE_SPDS.get('F2')),
            np.array([11.57834054, 9.98738373, 3.95462625]),
            decimal=7)
Пример #3
0
    def function_constraint(a):
        """
        Function defining the constraint.
        """

        spd[:] = a
        return spectral_to_XYZ_integration(
            spd, cmfs=cmfs, illuminant=illuminant) - XYZ
Пример #4
0
    def test_XYZ_to_spectral_Meng2015(self):
        """
        Tests :func:`colour.recovery.meng2015.XYZ_to_spectral_Meng2015`
        definition.
        """

        cmfs = STANDARD_OBSERVERS_CMFS['CIE 1931 2 Degree Standard Observer']
        shape = SpectralShape(cmfs.shape.start, cmfs.shape.end, 5)
        cmfs_c = cmfs.copy().align(shape)

        XYZ = np.array([0.07049534, 0.10080000, 0.09558313])
        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                XYZ_to_spectral_Meng2015(XYZ), cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)

        shape = SpectralShape(cmfs.shape.start, cmfs.shape.end, 10)
        cmfs_c = cmfs.copy().align(shape)

        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                XYZ_to_spectral_Meng2015(XYZ, interval=10), cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)

        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                XYZ_to_spectral_Meng2015(XYZ, interval=10, tolerance=1e-3),
                cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)

        shape = SpectralShape(400, 700, 5)
        cmfs_c = cmfs.copy().align(shape)
        np.testing.assert_almost_equal(
            spectral_to_XYZ_integration(
                XYZ_to_spectral_Meng2015(XYZ, cmfs=cmfs_c), cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)