Ejemplo n.º 1
0
    def test_domain_range_scale_XYZ_to_sd_Meng2015(self):
        """
        Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition
        domain and range scale support.
        """

        XYZ_i = np.array([0.20654008, 0.12197225, 0.05136952])
        XYZ_o = sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(XYZ_i, self._cmfs, self._sd_D65),
            self._cmfs,
            self._sd_D65,
        )

        d_r = (("reference", 1, 1), ("1", 1, 0.01), ("100", 100, 1))
        for scale, factor_a, factor_b in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(
                    sd_to_XYZ_integration(
                        XYZ_to_sd_Meng2015(
                            XYZ_i * factor_a, self._cmfs, self._sd_D65
                        ),
                        self._cmfs,
                        self._sd_D65,
                    ),
                    XYZ_o * factor_b,
                    decimal=7,
                )
Ejemplo n.º 2
0
    def test_XYZ_to_sd_Meng2015(self):
        """Test :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition."""

        XYZ = np.array([0.20654008, 0.12197225, 0.05136952])
        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(XYZ, self._cmfs, self._sd_D65),
                self._cmfs,
                self._sd_D65,
            )
            / 100,
            XYZ,
            decimal=7,
        )

        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(XYZ, self._cmfs, self._sd_E),
                self._cmfs,
                self._sd_E,
            )
            / 100,
            XYZ,
            decimal=7,
        )

        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(
                    XYZ,
                    self._cmfs,
                    self._sd_D65,
                    optimisation_kwargs={
                        "options": {
                            "ftol": 1e-10,
                        }
                    },
                ),
                self._cmfs,
                self._sd_D65,
            )
            / 100,
            XYZ,
            decimal=7,
        )

        shape = SpectralShape(400, 700, 5)
        # pylint: disable=E1102
        cmfs = reshape_msds(self._cmfs, shape)
        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(XYZ, cmfs, self._sd_D65), cmfs, self._sd_D65
            )
            / 100,
            XYZ,
            decimal=7,
        )
Ejemplo n.º 3
0
    def test_XYZ_to_sd_Meng2015(self):
        """
        Tests :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015`
        definition.
        """

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

        XYZ = np.array([0.21781186, 0.12541048, 0.04697113])
        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ, cmfs_c), 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(
            sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ, cmfs_c), cmfs_c) /
            100,
            XYZ,
            decimal=7)

        np.testing.assert_almost_equal(sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(XYZ, cmfs_c, ILLUMINANTS_SDS['D65']), cmfs_c,
            ILLUMINANTS_SDS['D65']) / 100,
                                       XYZ,
                                       decimal=7)

        np.testing.assert_almost_equal(sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(
                XYZ,
                cmfs_c,
                optimisation_parameters={'options': {
                    'ftol': 1e-10,
                }}), cmfs_c) / 100,
                                       XYZ,
                                       decimal=7)

        shape = SpectralShape(400, 700, 5)
        cmfs_c = cmfs.copy().align(shape)
        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ, cmfs_c), cmfs_c) /
            100,
            XYZ,
            decimal=7)
Ejemplo n.º 4
0
    def test_domain_range_scale_XYZ_to_sd_Meng2015(self):
        """
        Tests :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015`
        definition domain and range scale support.
        """

        XYZ_i = np.array([0.21781186, 0.12541048, 0.04697113])
        XYZ_o = sd_to_XYZ_integration(XYZ_to_sd_Meng2015(XYZ_i))

        d_r = (('reference', 1, 1), (1, 1, 0.01), (100, 100, 1))
        for scale, factor_a, factor_b in d_r:
            with domain_range_scale(scale):
                np.testing.assert_almost_equal(sd_to_XYZ_integration(
                    XYZ_to_sd_Meng2015(XYZ_i * factor_a)),
                                               XYZ_o * factor_b,
                                               decimal=7)
Ejemplo n.º 5
0
    def test_XYZ_to_sd_Meng2015(self):
        """
        Tests :func:`colour.recovery.meng2015.XYZ_to_sd_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.21781186, 0.12541048, 0.04697113])
        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(XYZ_to_sd_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(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(XYZ, interval=10), cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)

        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(
                    XYZ,
                    interval=10,
                    optimisation_parameters={
                        'options': {
                            'ftol': 1e-10,
                            'maxiter': 2000
                        }
                    }),
                cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)

        shape = SpectralShape(400, 700, 5)
        cmfs_c = cmfs.copy().align(shape)
        np.testing.assert_almost_equal(
            sd_to_XYZ_integration(
                XYZ_to_sd_Meng2015(XYZ, cmfs=cmfs_c), cmfs=cmfs_c) / 100,
            XYZ,
            decimal=7)
Ejemplo n.º 6
0
    def test_XYZ_to_sd_Meng2015(self):
        """
        Tests :func:`colour.recovery.meng2015.XYZ_to_sd_Meng2015` definition.
        """

        XYZ = np.array([0.20654008, 0.12197225, 0.05136952])
        np.testing.assert_almost_equal(sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(XYZ, self._cmfs, self._sd_D65), self._cmfs,
            self._sd_D65) / 100,
                                       XYZ,
                                       decimal=7)

        np.testing.assert_almost_equal(sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(XYZ, self._cmfs, self._sd_E), self._cmfs,
            self._sd_E) / 100,
                                       XYZ,
                                       decimal=7)

        np.testing.assert_almost_equal(sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(
                XYZ,
                self._cmfs,
                self._sd_D65,
                optimisation_kwargs={'options': {
                    'ftol': 1e-10,
                }}), self._cmfs, self._sd_D65) / 100,
                                       XYZ,
                                       decimal=7)

        shape = SpectralShape(400, 700, 5)
        cmfs = self._cmfs.copy().align(shape)
        np.testing.assert_almost_equal(sd_to_XYZ_integration(
            XYZ_to_sd_Meng2015(XYZ, cmfs, self._sd_D65), cmfs, self._sd_D65) /
                                       100,
                                       XYZ,
                                       decimal=7)