Exemple #1
0
    def setUp(self):
        """
        Initialises common tests attributes.
        """

        self._labels = ('x_bar', 'y_bar', 'z_bar')

        self._multi_spd = MultiSpectralPowerDistribution(
            CIE_1931_2_DEGREE_STANDARD_OBSERVER,
            name='Observer',
            labels=self._labels)

        spd = SpectralPowerDistribution(SAMPLE_SPD_DATA)
        domain = spd.domain
        range_ = tstack([spd.values, spd.values, spd.values])
        self._sample_multi_spd = MultiSpectralPowerDistribution(
            range_, domain, name='Sample Observer', labels=self._labels)

        spd = SpectralPowerDistribution(NON_UNIFORM_SAMPLE_SPD_DATA)
        domain = spd.domain
        range_ = tstack([spd.values, spd.values, spd.values])
        self._non_uniform_sample_multi_spd = MultiSpectralPowerDistribution(
            range_,
            domain,
            name='Non Uniform Sample Observer',
            strict_name='Strict Non Uniform Sample Observer',
            labels=self._labels,
            strict_labels=('Strict x_bar', 'Strict  y_bar', 'Strict  z_bar'))

        self._phi = (1 + np.sqrt(5)) / 2
Exemple #2
0
    def test_extrapolate(self):
        """
        Tests :func:`colour.colorimetry.spectrum.\
SpectralPowerDistribution.extrapolate` method.
        """

        data = dict(zip(range(25, 35), [0] * 5 + [1] * 5))
        spd = SpectralPowerDistribution(data)
        spd.extrapolate(SpectralShape(10, 50))

        self.assertAlmostEqual(spd[10], 0, places=7)
        self.assertAlmostEqual(spd[50], 1, places=7)

        spd = SpectralPowerDistribution(
            np.linspace(0, 1, 10), np.linspace(25, 35, 10))
        spd.extrapolate(
            SpectralShape(10, 50),
            extrapolator_args={
                'method': 'Linear',
                'left': None,
                'right': None
            })

        self.assertAlmostEqual(spd[10], -1.5000000000000004, places=7)
        self.assertAlmostEqual(spd[50], 2.4999999999999964, places=7)
Exemple #3
0
    def setUp(self):
        """
        Initialises common tests attributes.
        """

        self._spd = SpectralPowerDistribution(SAMPLE_SPD_DATA, name='Sample')

        self._non_uniform_spd = SpectralPowerDistribution(
            NON_UNIFORM_SAMPLE_SPD_DATA,
            name='Non Uniform Sample',
            strict_name='Strict Non Uniform Sample')

        self._phi = (1 + np.sqrt(5)) / 2
Exemple #4
0
    }
}

filter_warnings(True)
"""
Filtering warnings issued by Smits (1999) non-uniform wavelengths distribution.
Using `np.linspace(380, 720, 10)` does not solve the issue:

>>> colour.utilities.interval(np.linspace(380, 720, 10))
array([ 37.77777778,  37.77777778,  37.77777778])
"""

SMITS_1999_SPDS = CaseInsensitiveMapping({
    'white':
        SpectralPowerDistribution(
            SMITS_1999_SPDS_DATA['white'],
            name='white'),
    'cyan':
        SpectralPowerDistribution(
            SMITS_1999_SPDS_DATA['cyan'],
            name='cyan'),
    'magenta':
        SpectralPowerDistribution(
            SMITS_1999_SPDS_DATA['magenta'],
            name='magenta'),
    'yellow':
        SpectralPowerDistribution(
            SMITS_1999_SPDS_DATA['yellow'],
            name='yellow'),
    'red':
        SpectralPowerDistribution(
Exemple #5
0
        380.0000: 1.0000,
        417.7778: 1.0000,
        455.5556: 0.8916,
        493.3333: 0.3323,
        531.1111: 0.0000,
        568.8889: 0.0000,
        606.6667: 0.0003,
        644.4444: 0.0369,
        682.2222: 0.0483,
        720.0000: 0.0496
    }
}

SMITS_1999_SPDS = CaseInsensitiveMapping({
    'white':
    SpectralPowerDistribution('white', SMITS_1999_SPDS_DATA.get('white')),
    'cyan':
    SpectralPowerDistribution('cyan', SMITS_1999_SPDS_DATA.get('cyan')),
    'magenta':
    SpectralPowerDistribution('magenta', SMITS_1999_SPDS_DATA.get('magenta')),
    'yellow':
    SpectralPowerDistribution('yellow', SMITS_1999_SPDS_DATA.get('yellow')),
    'red':
    SpectralPowerDistribution('red', SMITS_1999_SPDS_DATA.get('red')),
    'green':
    SpectralPowerDistribution('green', SMITS_1999_SPDS_DATA.get('green')),
    'blue':
    SpectralPowerDistribution('blue', SMITS_1999_SPDS_DATA.get('blue'))
})
"""
Smits (1999) spectral power distributions.
Exemple #6
0
        380.0000: 1.0000,
        417.7778: 1.0000,
        455.5556: 0.8916,
        493.3333: 0.3323,
        531.1111: 0.0000,
        568.8889: 0.0000,
        606.6667: 0.0003,
        644.4444: 0.0369,
        682.2222: 0.0483,
        720.0000: 0.0496
    }
}

SMITS_1999_SPDS = CaseInsensitiveMapping({
    'white':
    SpectralPowerDistribution('white', SMITS_1999_SPDS_DATA['white']),
    'cyan':
    SpectralPowerDistribution('cyan', SMITS_1999_SPDS_DATA['cyan']),
    'magenta':
    SpectralPowerDistribution('magenta', SMITS_1999_SPDS_DATA['magenta']),
    'yellow':
    SpectralPowerDistribution('yellow', SMITS_1999_SPDS_DATA['yellow']),
    'red':
    SpectralPowerDistribution('red', SMITS_1999_SPDS_DATA['red']),
    'green':
    SpectralPowerDistribution('green', SMITS_1999_SPDS_DATA['green']),
    'blue':
    SpectralPowerDistribution('blue', SMITS_1999_SPDS_DATA['blue'])
})
"""
*Smits (1999)* spectral power distributions.