コード例 #1
0
ファイル: test_tabular.py プロジェクト: colour-science/colour
    def test_write_sds_to_csv_file(self):
        """
        Tests :func:`colour.io.tabular.write_sds_to_csv_file` definition.
        """

        colour_checker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                             'colorchecker_n_ohta.csv')
        sds = read_sds_from_csv_file(colour_checker_n_ohta)
        colour_checker_n_ohta_test = os.path.join(self._temporary_directory,
                                                  'colorchecker_n_ohta.csv')
        write_sds_to_csv_file(sds, colour_checker_n_ohta_test)
        sds_test = read_sds_from_csv_file(colour_checker_n_ohta_test)
        for key, value in sds.items():
            if PY2:
                # Running into precision issues with Python 2.x, applying
                # conservative rounding.
                value.wavelengths = np.around(value.wavelengths, decimals=7)
                value.values = np.around(value.values, decimals=7)
                sds_test[key].wavelengths = np.around(
                    sds_test[key].wavelengths, decimals=7)
                sds_test[key].values = np.around(
                    sds_test[key].values, decimals=7)

            self.assertEqual(value, sds_test[key])

        write_sds_to_csv_file(sds, colour_checker_n_ohta_test, fields=['1'])
        sds_test = read_sds_from_csv_file(colour_checker_n_ohta_test)
        self.assertEqual(len(sds_test), 1)
コード例 #2
0
    def test_write_sds_to_csv_file(self):
        """
        Tests :func:`colour.io.tabular.write_sds_to_csv_file` definition.
        """

        colour_checker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                             'colorchecker_n_ohta.csv')
        sds = read_sds_from_csv_file(colour_checker_n_ohta)
        colour_checker_n_ohta_test = os.path.join(self._temporary_directory,
                                                  'colorchecker_n_ohta.csv')
        write_sds_to_csv_file(sds, colour_checker_n_ohta_test)
        sds_test = read_sds_from_csv_file(colour_checker_n_ohta_test)
        for key, value in sds.items():
            if PY2:
                # Running into precision issues with Python 2.x, applying
                # conservative rounding.
                value.wavelengths = np.around(value.wavelengths, decimals=7)
                value.values = np.around(value.values, decimals=7)
                sds_test[key].wavelengths = np.around(
                    sds_test[key].wavelengths, decimals=7)
                sds_test[key].values = np.around(sds_test[key].values,
                                                 decimals=7)

            self.assertEqual(value, sds_test[key])

        write_sds_to_csv_file(sds, colour_checker_n_ohta_test, fields=['1'])
        sds_test = read_sds_from_csv_file(colour_checker_n_ohta_test)
        self.assertEqual(len(sds_test), 1)
コード例 #3
0
ファイル: test_tabular.py プロジェクト: colour-science/colour
    def test_write_sds_to_csv_file(self):
        """Test :func:`colour.io.tabular.write_sds_to_csv_file` definition."""

        colour_checker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                             "colorchecker_n_ohta.csv")
        sds = read_sds_from_csv_file(colour_checker_n_ohta)
        colour_checker_n_ohta_test = os.path.join(self._temporary_directory,
                                                  "colorchecker_n_ohta.csv")
        write_sds_to_csv_file(sds, colour_checker_n_ohta_test)
        sds_test = read_sds_from_csv_file(colour_checker_n_ohta_test)
        for key, value in sds.items():
            self.assertEqual(value, sds_test[key])
コード例 #4
0
def read_training_data_rawtoaces_v1() -> MultiSpectralDistributions:
    """
    Read the *RAW to ACES* v1 190 patches.

    Returns
    -------
    :class:`colour.MultiSpectralDistributions`
        *RAW to ACES* v1 190 patches.

    References
    ----------
    :cite:`Dyer2017`

    Examples
    --------
    >>> len(read_training_data_rawtoaces_v1().labels)
    190
    """

    global _TRAINING_DATA_RAWTOACES_V1

    if _TRAINING_DATA_RAWTOACES_V1 is not None:
        training_data = _TRAINING_DATA_RAWTOACES_V1
    else:
        path = os.path.join(RESOURCES_DIRECTORY_RAWTOACES, "190_Patches.csv")
        training_data = sds_and_msds_to_msds(
            list(read_sds_from_csv_file(path).values()))

        _TRAINING_DATA_RAWTOACES_V1 = training_data

    return training_data
コード例 #5
0
ファイル: test_tabular.py プロジェクト: colour-science/colour
    def test_read_sds_from_csv_file(self):
        """Test :func:`colour.io.tabular.read_sds_from_csv_file` definition."""

        colour_checker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                             "colorchecker_n_ohta.csv")
        sds = read_sds_from_csv_file(colour_checker_n_ohta)
        for sd in sds.values():
            self.assertIsInstance(sd, SpectralDistribution)

        self.assertEqual(
            sds["1"], SpectralDistribution(COLOURCHECKER_N_OHTA_1, name="1"))
コード例 #6
0
ファイル: test_tabular.py プロジェクト: colour-science/colour
    def test_read_sds_from_csv_file(self):
        """
        Tests :func:`colour.io.tabular.read_sds_from_csv_file` definition.
        """

        colour_checker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                             'colorchecker_n_ohta.csv')
        sds = read_sds_from_csv_file(colour_checker_n_ohta)
        for sd in sds.values():
            self.assertIsInstance(sd, SpectralDistribution)

        self.assertEqual(
            sds['1'], SpectralDistribution(COLOURCHECKER_N_OHTA_1, name='1'))
コード例 #7
0
ファイル: test_tabular.py プロジェクト: colour-science/colour
    def test_raise_exception_write_sds_to_csv_file(self):
        """
        Test :func:`colour.io.tabular.write_sds_to_csv_file` definition
        raised exception.
        """

        colour_checker_n_ohta = os.path.join(RESOURCES_DIRECTORY,
                                             "colorchecker_n_ohta.csv")
        sds = read_sds_from_csv_file(colour_checker_n_ohta)
        key = list(sds.keys())[0]
        sds[key] = sds[key].align(SpectralShape(400, 700, 10))

        self.assertRaises(ValueError, write_sds_to_csv_file, sds, "")
コード例 #8
0
    "TestWhiteBalanceMultipliers",
    "TestBestIlluminant",
    "TestNormaliseIlluminant",
    "TestTrainingDataSdsToRGB",
    "TestTrainingDataSdsToXYZ",
    "TestOptimizationFactoryRawtoacesV1",
    "TestOptimizationFactoryJzazbz",
    "TestMatrixIdt",
    "TestCamera_RGB_to_ACES2065_1",
]

MSDS_CANON_EOS_5DMARK_II: MultiSpectralDistributions = sds_and_msds_to_msds(
    list(
        read_sds_from_csv_file(
            os.path.join(
                RESOURCES_DIRECTORY_RAWTOACES,
                "CANON_EOS_5DMark_II_RGB_Sensitivities.csv",
            )).values()))

SD_AMPAS_ISO7589_STUDIO_TUNGSTEN: SpectralDistribution = (
    read_sds_from_csv_file(
        os.path.join(RESOURCES_DIRECTORY_RAWTOACES,
                     "AMPAS_ISO_7589_Tungsten.csv"))["iso7589"])


class TestSpectralToAcesRelativeExposureValues(unittest.TestCase):
    """
    Define :func:`colour.characterisation.aces_it.\
sd_to_aces_relative_exposure_values` definition unit tests methods.
    """
    def test_spectral_to_aces_relative_exposure_values(self):
コード例 #9
0
ファイル: test_aces_it.py プロジェクト: wenh06/colour
__email__ = '*****@*****.**'
__status__ = 'Production'

__all__ = [
    'MSDS_CANON_EOS_5DMARK_II', 'SD_AMPAS_ISO7589_STUDIO_TUNGSTEN',
    'TestSpectralToAcesRelativeExposureValues',
    'TestReadTrainingDataRawtoacesV1', 'TestGenerateIlluminantsRawtoacesV1',
    'TestWhiteBalanceMultipliers', 'TestBestIlluminant',
    'TestNormaliseIlluminant', 'TestTrainingDataSdsToRGB',
    'TestTrainingDataSdsToXYZ', 'TestOptimizationFactoryRawtoacesV1',
    'TestOptimizationFactoryJzAzBz', 'TestMatrixIdt'
]

MSDS_CANON_EOS_5DMARK_II = sds_and_msds_to_msds(
    read_sds_from_csv_file(
        os.path.join(RESOURCES_DIRECTORY_RAWTOACES,
                     'CANON_EOS_5DMark_II_RGB_Sensitivities.csv')).values())

SD_AMPAS_ISO7589_STUDIO_TUNGSTEN = read_sds_from_csv_file(
    os.path.join(RESOURCES_DIRECTORY_RAWTOACES,
                 'AMPAS_ISO_7589_Tungsten.csv'))['iso7589']


class TestSpectralToAcesRelativeExposureValues(unittest.TestCase):
    """
    Defines :func:`colour.characterisation.aces_it.\
sd_to_aces_relative_exposure_values` definition unit tests methods.
    """
    def test_spectral_to_aces_relative_exposure_values(self):
        """
        Tests :func:`colour.characterisation.aces_it.
コード例 #10
0
def generate_illuminants_rawtoaces_v1() -> CaseInsensitiveMapping:
    """
    Generate a series of illuminants according to *RAW to ACES* v1:

    -   *CIE Illuminant D Series* in range [4000, 25000] kelvin degrees.
    -   *Blackbodies* in range [1000, 3500] kelvin degrees.
    -   A.M.P.A.S. variant of *ISO 7589 Studio Tungsten*.

    Returns
    -------
    :class:`colour.utilities.CaseInsensitiveMapping`
        Series of illuminants.

    Notes
    -----
    -   This definition introduces a few differences compared to
        *RAW to ACES* v1: *CIE Illuminant D Series* are computed in range
        [4002.15, 7003.77] kelvin degrees and the :math:`C_2` change is not
        used in *RAW to ACES* v1.

    References
    ----------
    :cite:`Dyer2017`

    Examples
    --------
    >>> list(sorted(generate_illuminants_rawtoaces_v1().keys()))
    ['1000K Blackbody', '1500K Blackbody', '2000K Blackbody', \
'2500K Blackbody', '3000K Blackbody', '3500K Blackbody', 'D100', 'D105', \
'D110', 'D115', 'D120', 'D125', 'D130', 'D135', 'D140', 'D145', 'D150', \
'D155', 'D160', 'D165', 'D170', 'D175', 'D180', 'D185', 'D190', 'D195', \
'D200', 'D205', 'D210', 'D215', 'D220', 'D225', 'D230', 'D235', 'D240', \
'D245', 'D250', 'D40', 'D45', 'D50', 'D55', 'D60', 'D65', 'D70', 'D75', \
'D80', 'D85', 'D90', 'D95', 'iso7589']
    """

    global _ILLUMINANTS_RAWTOACES_V1

    if _ILLUMINANTS_RAWTOACES_V1 is not None:
        illuminants = _ILLUMINANTS_RAWTOACES_V1
    else:
        illuminants = CaseInsensitiveMapping()

        # CIE Illuminants D Series from 4000K to 25000K.
        for i in np.arange(4000, 25000 + 500, 500):
            CCT = i * 1.4388 / 1.4380
            xy = CCT_to_xy_CIE_D(CCT)
            sd = sd_CIE_illuminant_D_series(xy)
            sd.name = f"D{int(CCT / 100):d}"
            illuminants[sd.name] = sd.align(SPECTRAL_SHAPE_RAWTOACES)

        # TODO: Remove when removing the "colour.sd_blackbody" definition
        # warning.
        with suppress_warnings(colour_usage_warnings=True):
            # Blackbody from 1000K to 4000K.
            for i in np.arange(1000, 4000, 500):
                sd = sd_blackbody(i, SPECTRAL_SHAPE_RAWTOACES)
                illuminants[sd.name] = sd

        # A.M.P.A.S. variant of ISO 7589 Studio Tungsten.
        sd = read_sds_from_csv_file(
            os.path.join(RESOURCES_DIRECTORY_RAWTOACES,
                         "AMPAS_ISO_7589_Tungsten.csv"))["iso7589"]
        illuminants.update({sd.name: sd})

        _ILLUMINANTS_RAWTOACES_V1 = illuminants

    return illuminants