Bases: object
Defines the base object for spectral power distribution shape.
Parameters: |
|
---|
Examples
>>> SpectralShape(360, 830, 1)
SpectralShape(360, 830, 1)
Returns if the spectral shape contains the given wavelength \(\lambda\).
Parameters: | wavelength (numeric) – Wavelength \(\lambda\). |
---|---|
Returns: | Is wavelength \(\lambda\) in the spectral shape. |
Return type: | bool |
Notes
Examples
>>> 0.5 in SpectralShape(0, 10, 0.1)
True
>>> 0.51 in SpectralShape(0, 10, 0.1)
False
Returns the spectral shape equality with given other spectral shape.
Parameters: | shape (SpectralShape) – Spectral shape to compare for equality. |
---|---|
Returns: | Spectral shape equality. |
Return type: | bool |
Notes
Examples
>>> SpectralShape(0, 10, 0.1) == SpectralShape(0, 10, 0.1)
True
>>> SpectralShape(0, 10, 0.1) == SpectralShape(0, 10, 1)
False
Returns a generator for the spectral power distribution data.
Returns: | Spectral power distribution data generator. |
---|---|
Return type: | generator |
Notes
Examples
>>> shape = SpectralShape(0, 10, 1)
>>> for wavelength in shape: print(wavelength)
0
1
2
3
4
5
6
7
8
9
10
Returns the spectral shape wavelengths \(\lambda_n\) count.
Returns: | Spectral shape wavelengths \(\lambda_n\) count. |
---|---|
Return type: | int |
Notes
Examples
>>> len(SpectralShape(0, 10, 0.1))
101
Returns the spectral shape inequality with given other spectral shape.
Parameters: | shape (SpectralShape) – Spectral shape to compare for inequality. |
---|---|
Returns: | Spectral shape inequality. |
Return type: | bool |
Notes
Examples
>>> SpectralShape(0, 10, 0.1) != SpectralShape(0, 10, 0.1)
False
>>> SpectralShape(0, 10, 0.1) != SpectralShape(0, 10, 1)
True
Returns a formatted string representation.
Returns: | Formatted string representation. |
---|---|
Return type: | unicode |
Returns a nice formatted string representation.
Returns: | Nice formatted string representation. |
---|---|
Return type: | unicode |
Property for self.__end private attribute.
Returns: | self.__end. |
---|---|
Return type: | numeric |
Returns an iterable range for the spectral power distribution shape.
Returns: | Iterable range for the spectral power distribution shape |
---|---|
Return type: | ndarray |
Raises: | RuntimeError – If one of spectral shape start, end or steps attributes is not defined. |
Examples
>>> SpectralShape(0, 10, 0.1).range()
array([ 0. , 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8,
0.9, 1. , 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7,
1.8, 1.9, 2. , 2.1, 2.2, 2.3, 2.4, 2.5, 2.6,
2.7, 2.8, 2.9, 3. , 3.1, 3.2, 3.3, 3.4, 3.5,
3.6, 3.7, 3.8, 3.9, 4. , 4.1, 4.2, 4.3, 4.4,
4.5, 4.6, 4.7, 4.8, 4.9, 5. , 5.1, 5.2, 5.3,
5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6. , 6.1, 6.2,
6.3, 6.4, 6.5, 6.6, 6.7, 6.8, 6.9, 7. , 7.1,
7.2, 7.3, 7.4, 7.5, 7.6, 7.7, 7.8, 7.9, 8. ,
8.1, 8.2, 8.3, 8.4, 8.5, 8.6, 8.7, 8.8, 8.9,
9. , 9.1, 9.2, 9.3, 9.4, 9.5, 9.6, 9.7, 9.8,
9.9, 10. ])
Property for self.__start private attribute.
Returns: | self.__start. |
---|---|
Return type: | numeric |
Property for self.__steps private attribute.
Returns: | self.__steps. |
---|---|
Return type: | numeric |
Bases: object
Defines the base object for spectral data computations.
Parameters: |
|
---|
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.wavelengths
array([510, 520, 530, 540])
>>> spd.values
array([ 49.67, 69.59, 81.73, 88.19])
>>> spd.shape
SpectralShape(510, 540, 10)
Implements support for spectral power distribution addition.
Parameters: | x (numeric or array_like or SpectralPowerDistribution) – Variable to add. |
---|---|
Returns: | Variable added spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
SpectralPowerDistribution.__sub__(), SpectralPowerDistribution.__mul__(), SpectralPowerDistribution.__div__()
Notes
Warning
The addition operation happens in place.
Examples
Adding a single numeric variable:
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd + 10
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 59.67, 79.59, 91.73, 98.19])
Adding an array_like variable:
>>> spd + [1, 2, 3, 4]
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 60.67, 81.59, 94.73, 102.19])
Adding a SpectralPowerDistribution class variable:
>>> spd_alternate = SpectralPowerDistribution('Spd', data)
>>> spd + spd_alternate
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 110.34, 151.18, 176.46, 190.38])
Returns if the spectral power distribution contains the given wavelength \(\lambda\).
Parameters: | wavelength (numeric) – Wavelength \(\lambda\). |
---|---|
Returns: | Is wavelength \(\lambda\) in the spectral power distribution. |
Return type: | bool |
Notes
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> 510 in spd
True
Implements support for spectral power distribution division.
Parameters: | x (numeric or array_like or SpectralPowerDistribution) – Variable to divide. |
---|---|
Returns: | Variable divided spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
SpectralPowerDistribution.__add__(), SpectralPowerDistribution.__sub__(), SpectralPowerDistribution.__mul__()
Notes
Warning
The division operation happens in place.
Examples
Dividing a single numeric variable:
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd / 10
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 4.967, 6.959, 8.173, 8.819])
Dividing an array_like variable:
>>> spd / [1, 2, 3, 4]
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 4.967 , 3.4795 , 2.72433333, 2.20475 ])
Dividing a SpectralPowerDistribution class variable:
>>> spd_alternate = SpectralPowerDistribution('Spd', data)
>>> spd / spd_alternate
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 0.1 , 0.05 , 0.0333333..., 0.025 ])
Returns the spectral power distribution equality with given other spectral power distribution.
Parameters: | spd (SpectralPowerDistribution) – Spectral power distribution to compare for equality. |
---|---|
Returns: | Spectral power distribution equality. |
Return type: | bool |
Notes
Examples
>>> data1 = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> data2 = {510: 48.6700, 520: 69.5900, 530: 81.7300, 540: 88.1900}
>>> spd1 = SpectralPowerDistribution('Spd', data1)
>>> spd2 = SpectralPowerDistribution('Spd', data2)
>>> spd3 = SpectralPowerDistribution('Spd', data2)
>>> spd1 == spd2
False
>>> spd2 == spd3
True
Returns the value for given wavelength \(\lambda\).
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) to retrieve the value. |
---|---|
Returns: | Wavelength \(\lambda\) value. |
Return type: | numeric |
See also
Notes
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> spd[510]
49.67...
Returns the spectral power distribution hash value.
Returns: | Object hash. |
---|---|
Return type: | int |
Notes
Warning
SpectralPowerDistribution class is mutable and should not be hashable. However, so that it can be used as a key in some data caches, we provide a __hash__ implementation, assuming that the underlying data will not change for those specific cases.
References
[1] | http://stackoverflow.com/a/16162138/931625 (Last accessed 8 August 2014) |
Returns a generator for the spectral power distribution data.
Returns: | Spectral power distribution data generator. |
---|---|
Return type: | generator |
Notes
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> for wavelength, value in spd: print((wavelength, value))
(510, 49.6...)
(520, 69.5...)
(530, 81.7...)
(540, 88.1...)
Returns the spectral power distribution wavelengths \(\lambda_n\) count.
Returns: | Spectral power distribution wavelengths \(\lambda_n\) count. |
---|---|
Return type: | int |
Notes
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> len(spd)
4
Implements support for spectral power distribution multiplication.
Parameters: | x (numeric or array_like or SpectralPowerDistribution) – Variable to multiply. |
---|---|
Returns: | Variable multiplied spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
SpectralPowerDistribution.__add__(), SpectralPowerDistribution.__sub__(), SpectralPowerDistribution.__div__()
Notes
Warning
The multiplication operation happens in place.
Examples
Multiplying a single numeric variable:
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd * 10
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 496.7, 695.9, 817.3, 881.9])
Multiplying an array_like variable:
>>> spd * [1, 2, 3, 4]
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 496.7, 1391.8, 2451.9, 3527.6])
Multiplying a SpectralPowerDistribution class variable:
>>> spd_alternate = SpectralPowerDistribution('Spd', data)
>>> spd * spd_alternate
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 24671.089, 96855.362, 200393.787, 311099.044])
Returns the spectral power distribution inequality with given other spectral power distribution.
Parameters: | spd (SpectralPowerDistribution) – Spectral power distribution to compare for inequality. |
---|---|
Returns: | Spectral power distribution inequality. |
Return type: | bool |
Notes
Examples
>>> data1 = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> data2 = {510: 48.6700, 520: 69.5900, 530: 81.7300, 540: 88.1900}
>>> spd1 = SpectralPowerDistribution('Spd', data1)
>>> spd2 = SpectralPowerDistribution('Spd', data2)
>>> spd3 = SpectralPowerDistribution('Spd', data2)
>>> spd1 != spd2
True
>>> spd2 != spd3
False
Sets the wavelength \(\lambda\) with given value.
Parameters: |
|
---|
Notes
Examples
>>> spd = SpectralPowerDistribution('Spd', {})
>>> spd[510] = 49.6700
>>> spd.values
array([ 49.67])
Implements support for spectral power distribution subtraction.
Parameters: | x (numeric or array_like or SpectralPowerDistribution) – Variable to subtract. |
---|---|
Returns: | Variable subtracted spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
SpectralPowerDistribution.__add__(), SpectralPowerDistribution.__mul__(), SpectralPowerDistribution.__div__()
Notes
Warning
The subtraction operation happens in place.
Examples
Subtracting a single numeric variable:
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd - 10
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 39.67, 59.59, 71.73, 78.19])
Subtracting an array_like variable:
>>> spd - [1, 2, 3, 4]
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 38.67, 57.59, 68.73, 74.19])
Subtracting a SpectralPowerDistribution class variable:
>>> spd_alternate = SpectralPowerDistribution('Spd', data)
>>> spd - spd_alternate
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([-11., -12., -13., -14.])
Implements support for spectral power distribution division.
Parameters: | x (numeric or array_like or SpectralPowerDistribution) – Variable to divide. |
---|---|
Returns: | Variable divided spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
SpectralPowerDistribution.__add__(), SpectralPowerDistribution.__sub__(), SpectralPowerDistribution.__mul__()
Notes
Warning
The division operation happens in place.
Examples
Dividing a single numeric variable:
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd / 10
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 4.967, 6.959, 8.173, 8.819])
Dividing an array_like variable:
>>> spd / [1, 2, 3, 4]
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 4.967 , 3.4795 , 2.72433333, 2.20475 ])
Dividing a SpectralPowerDistribution class variable:
>>> spd_alternate = SpectralPowerDistribution('Spd', data)
>>> spd / spd_alternate
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 0.1 , 0.05 , 0.0333333..., 0.025 ])
Aligns the spectral power distribution to given spectral shape: Interpolates first then extrapolates to fit the given range.
Parameters: |
|
---|---|
Returns: | Aligned spectral power distribution. |
Return type: | SpectralPowerDistribution |
Examples
>>> data = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 86.26,
... 560: 77.18}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.align(SpectralShape(505, 565, 1))
<...SpectralPowerDistribution object at 0x...>
>>> # Doctests skip for Python 2.x compatibility.
>>> spd.wavelengths
array([505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517,
518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530,
531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543,
544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556,
557, 558, 559, 560, 561, 562, 563, 564, 565])
>>> spd.values
array([ 49.67 ..., 49.67 ..., 49.67 ..., 49.67 ...,
49.67 ..., 49.67 ..., 51.8341162..., 53.9856467...,
56.1229464..., 58.2366197..., 60.3121800..., 62.3327095...,
64.2815187..., 66.1448055..., 67.9143153..., 69.59 ...,
71.1759958..., 72.6627938..., 74.0465756..., 75.3329710...,
76.5339542..., 77.6647421..., 78.7406907..., 79.7741932...,
80.7715767..., 81.73 ..., 82.6407518..., 83.507872 ...,
84.3326333..., 85.109696 ..., 85.8292968..., 86.47944 ...,
87.0480863..., 87.525344 ..., 87.9056578..., 88.19 ...,
88.3858347..., 88.4975634..., 88.5258906..., 88.4696570...,
88.3266460..., 88.0943906..., 87.7709802..., 87.3558672...,
86.8506741..., 86.26 ..., 85.5911699..., 84.8503430...,
84.0434801..., 83.1771110..., 82.2583874..., 81.2951360...,
80.2959122..., 79.2700525..., 78.2277286..., 77.18 ...,
77.18 ..., 77.18 ..., 77.18 ..., 77.18 ..., 77.18 ])
Clones the spectral power distribution.
Most of the SpectralPowerDistribution class operations are conducted in-place. The SpectralPowerDistribution.clone() method provides a convenient way to copy the spectral power distribution to a new object.
Returns: | Cloned spectral power distribution. |
---|---|
Return type: | SpectralPowerDistribution |
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> print(spd)
<...SpectralPowerDistribution object at 0x...>
>>> spd_clone = spd.clone()
>>> print(spd_clone)
<...SpectralPowerDistribution object at 0x...>
Property for self.__data private attribute.
Returns: | self.__data. |
---|---|
Return type: | dict |
Extrapolates the spectral power distribution following CIE 15:2004 recommendation.
Parameters: |
|
---|---|
Returns: | Extrapolated spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
References
[2] | CIE 015:2004 Colorimetry, 3rd edition: 7.2.2.1 Extrapolation |
[3] | CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations: 10. EXTRAPOLATION |
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.extrapolate(SpectralShape(400, 700)).shape
SpectralShape(400, 700, 10)
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> spd[400]
49.67...
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> spd[700]
88.1...
Returns the value for given wavelength \(\lambda\).
Parameters: |
|
---|---|
Returns: | Wavelength \(\lambda\) value. |
Return type: | numeric |
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> spd.get(510)
49.67...
>>> spd.get(511)
None
Interpolates the spectral power distribution following CIE 167:2005 recommendations: the method developed by Sprague (1880) should be used for interpolating functions having a uniformly spaced independent variable and a Cubic Spline method for non-uniformly spaced independent variable.
Parameters: |
|
---|---|
Returns: | Interpolated spectral power distribution. |
Return type: | SpectralPowerDistribution |
Raises: |
|
See also
Notes
Warning
References
[4] | CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations: 9. INTERPOLATION |
Examples
Uniform data is using Sprague interpolation by default:
>>> data = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 86.26,
... 560: 77.18}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.interpolate(SpectralShape(steps=1))
<...SpectralPowerDistribution object at 0x...>
>>> spd[515]
60.3121800...
Non uniform data is using Cubic Spline interpolation by default:
>>> data = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 86.26,
... 560: 77.18}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd[511] = 31.41
>>> spd.interpolate(SpectralShape(steps=1))
<...SpectralPowerDistribution object at 0x...>
>>> spd[515]
21.4792222...
Enforcing Linear interpolation:
>>> data = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 86.26,
... 560: 77.18}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.interpolate(SpectralShape(steps=1), method='Linear')
<...SpectralPowerDistribution object at 0x...>
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> spd[515]
59.63...
Returns if the spectral power distribution has uniformly spaced data.
Returns: | Is uniform. |
---|---|
Return type: | bool |
See also
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.is_uniform()
True
Breaking the steps by introducing a new wavelength \(\lambda\) value:
>>> spd[511] = 3.1415
>>> spd.is_uniform()
False
Property for self.items attribute. This is a convenient attribute used to iterate over the spectral power distribution.
Returns: | Spectral power distribution data generator. |
---|---|
Return type: | generator |
Property for self.__name private attribute.
Returns: | self.__name. |
---|---|
Return type: | str or unicode |
Normalises the spectral power distribution with given normalization factor.
Parameters: | factor (numeric, optional) – Normalization factor |
---|---|
Returns: | Normalised spectral power distribution. |
Return type: | SpectralPowerDistribution |
Examples
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.normalise()
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 0.5632157..., 0.7890917..., 0.9267490..., 1. ])
Property for self.shape attribute.
Returns the shape of the spectral power distribution in the form of a SpectralShape class instance.
Returns: | Spectral power distribution shape. |
---|---|
Return type: | SpectralShape |
See also
Notes
Warning
SpectralPowerDistribution.shape is read only.
Examples
Uniform spectral power distribution:
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> SpectralPowerDistribution('Spd', data).shape
SpectralShape(510, 540, 10)
Non uniform spectral power distribution:
>>> data = {512.3: 49.67, 524.5: 69.59, 532.4: 81.73, 545.7: 88.19}
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> SpectralPowerDistribution('Spd', data).shape
SpectralShape(512.3, 545.7, 7...)
Property for self.values attribute.
Returns: | Spectral power distribution wavelengths \(\lambda_n\) values. |
---|---|
Return type: | ndarray |
Warning
SpectralPowerDistribution.values is read only.
Property for self.wavelengths attribute.
Returns: | Spectral power distribution wavelengths \(\lambda_n\). |
---|---|
Return type: | ndarray |
Warning
SpectralPowerDistribution.wavelengths is read only.
Zeros fills the spectral power distribution: Missing values will be replaced with zeros to fit the defined range.
Parameters: | shape (SpectralShape, optional) – Spectral shape used for zeros fill. |
---|---|
Returns: | Zeros filled spectral power distribution. |
Return type: | SpectralPowerDistribution |
Examples
>>> data = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 86.26,
... 560: 77.18}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> spd.zeros(SpectralShape(505, 565, 1))
<...SpectralPowerDistribution object at 0x...>
>>> spd.values
array([ 0. , 0. , 0. , 0. , 0. , 49.67, 0. , 0. ,
0. , 0. , 0. , 0. , 0. , 0. , 0. , 69.59,
0. , 0. , 0. , 0. , 0. , 0. , 0. , 0. ,
0. , 81.73, 0. , 0. , 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 88.19, 0. , 0. , 0. , 0. ,
0. , 0. , 0. , 0. , 0. , 86.26, 0. , 0. ,
0. , 0. , 0. , 0. , 0. , 0. , 0. , 77.18,
0. , 0. , 0. , 0. , 0. ])
Bases: object
Defines the base object for colour matching functions.
A compound of three SpectralPowerDistribution is used to store the underlying axis data.
Parameters: |
|
---|
See also
colour.colorimetry.cmfs.LMS_ConeFundamentals, colour.colorimetry.cmfs.RGB_ColourMatchingFunctions, colour.colorimetry.cmfs.XYZ_ColourMatchingFunctions
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.wavelengths
array([510, 520, 530, 540])
>>> tri_spd.values
array([[ 49.67, 90.56, 12.43],
[ 69.59, 87.34, 23.15],
[ 81.73, 45.76, 67.98],
[ 88.19, 23.45, 90.28]])
>>> tri_spd.shape
SpectralShape(510, 540, 10)
Implements support for tri-spectral power distribution addition.
Parameters: | x (numeric or array_like or TriSpectralPowerDistribution) – Variable to add. |
---|---|
Returns: | Variable added tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
TriSpectralPowerDistribution.__sub__(), TriSpectralPowerDistribution.__mul__(), TriSpectralPowerDistribution.__div__()
Notes
Warning
The addition operation happens in place.
Examples
Adding a single numeric variable:
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd + 10
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 59.67, 100.56, 22.43],
[ 79.59, 97.34, 33.15],
[ 91.73, 55.76, 77.98],
[ 98.19, 33.45, 100.28]])
Adding an array_like variable:
>>> tri_spd + [(1, 2, 3)] * 4
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 60.67, 102.56, 25.43],
[ 80.59, 99.34, 36.15],
[ 92.73, 57.76, 80.98],
[ 99.19, 35.45, 103.28]])
Adding a TriSpectralPowerDistribution class variable:
>>> data1 = {'x_bar': z_bar, 'y_bar': x_bar, 'z_bar': y_bar}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd + tri_spd1
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 73.1 , 152.23, 115.99],
[ 103.74, 168.93, 123.49],
[ 160.71, 139.49, 126.74],
[ 189.47, 123.64, 126.73]])
Returns if the tri-spectral power distribution contains the given wavelength \(\lambda\).
Parameters: | wavelength (numeric) – Wavelength \(\lambda\). |
---|---|
Returns: | Is wavelength \(\lambda\) in the tri-spectral power distribution. |
Return type: | bool |
Notes
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> 510 in tri_spd
True
Implements support for tri-spectral power distribution division.
Parameters: | x (numeric or array_like or TriSpectralPowerDistribution) – Variable to divide. |
---|---|
Returns: | Variable divided tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
TriSpectralPowerDistribution.__add__(), TriSpectralPowerDistribution.__sub__(), TriSpectralPowerDistribution.__mul__()
Notes
Warning
The division operation happens in place.
Examples
Dividing a single numeric variable:
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd / 10
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 4.967, 9.056, 1.243],
[ 6.959, 8.734, 2.315],
[ 8.173, 4.576, 6.798],
[ 8.819, 2.345, 9.028]])
Dividing an array_like variable:
>>> tri_spd / [(1, 2, 3)] * 4
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 19.868 , 18.112 , 1.6573333...],
[ 27.836 , 17.468 , 3.0866666...],
[ 32.692 , 9.152 , 9.064 ...],
[ 35.276 , 4.69 , 12.0373333...]])
Dividing a TriSpectralPowerDistribution class variable:
>>> data1 = {'x_bar': z_bar, 'y_bar': x_bar, 'z_bar': y_bar}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd / tri_spd1
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 1.5983909..., 0.3646466..., 0.0183009...],
[ 1.2024190..., 0.2510130..., 0.0353408...],
[ 0.4809061..., 0.1119784..., 0.1980769...],
[ 0.3907399..., 0.0531806..., 0.5133191...]])
Returns the tri-spectral power distribution equality with given other tri-spectral power distribution.
Parameters: | spd (TriSpectralPowerDistribution) – Tri-spectral power distribution to compare for equality. |
---|---|
Returns: | Tri-spectral power distribution equality. |
Return type: | bool |
Notes
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data1 = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> data2 = {'x_bar': y_bar, 'y_bar': x_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd2 = TriSpectralPowerDistribution('Tri Spd', data2, mpg, lbl)
>>> tri_spd3 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd1 == tri_spd2
False
>>> tri_spd1 == tri_spd3
True
Returns the values for given wavelength \(\lambda\).
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) to retrieve the values. |
---|---|
Returns: | Wavelength \(\lambda\) values. |
Return type: | ndarray, (3,) |
See also
Notes
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd[510]
array([ 49.67, 90.56, 12.43])
Returns the spectral power distribution hash value.
Returns: | Object hash. |
---|---|
Return type: | int |
Notes
Warning
See SpectralPowerDistribution.__hash__() method warning section.
References
[5] | http://stackoverflow.com/a/16162138/931625 (Last accessed 8 August 2014) |
Returns a generator for the tri-spectral power distribution data.
Returns: | Tri-spectral power distribution data generator. |
---|---|
Return type: | generator |
Notes
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> for wavelength, value in tri_spd: print((wavelength, value))
(510, array([ 49.67, 90.56, 12.43]))
(520, array([ 69.59, 87.34, 23.15]))
(530, array([ 81.73, 45.76, 67.98]))
(540, array([ 88.19, 23.45, 90.28]))
Returns the tri-spectral power distribution wavelengths \(\lambda_n\) count.
Returns: | Tri-Spectral power distribution wavelengths \(\lambda_n\) count. |
---|---|
Return type: | int |
Notes
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> len(tri_spd)
4
Implements support for tri-spectral power distribution multiplication.
Parameters: | x (numeric or array_like or TriSpectralPowerDistribution) – Variable to multiply. |
---|---|
Returns: | Variable multiplied tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
TriSpectralPowerDistribution.__add__(), TriSpectralPowerDistribution.__sub__(), TriSpectralPowerDistribution.__div__()
Notes
Warning
The multiplication operation happens in place.
Examples
Multiplying a single numeric variable:
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd * 10
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 496.7, 905.6, 124.3],
[ 695.9, 873.4, 231.5],
[ 817.3, 457.6, 679.8],
[ 881.9, 234.5, 902.8]])
Multiplying an array_like variable:
>>> tri_spd * [(1, 2, 3)] * 4
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 1986.8, 7244.8, 1491.6],
[ 2783.6, 6987.2, 2778. ],
[ 3269.2, 3660.8, 8157.6],
[ 3527.6, 1876. , 10833.6]])
Multiplying a TriSpectralPowerDistribution class variable:
>>> data1 = {'x_bar': z_bar, 'y_bar': x_bar, 'z_bar': y_bar}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd * tri_spd1
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 24695.924, 359849.216, 135079.296],
[ 64440.34 , 486239.248, 242630.52 ],
[ 222240.216, 299197.184, 373291.776],
[ 318471.728, 165444.44 , 254047.92 ]])
Returns the tri-spectral power distribution inequality with given other tri-spectral power distribution.
Parameters: | spd (TriSpectralPowerDistribution) – Tri-spectral power distribution to compare for inequality. |
---|---|
Returns: | Tri-spectral power distribution inequality. |
Return type: | bool |
Notes
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data1 = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> data2 = {'x_bar': y_bar, 'y_bar': x_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd2 = TriSpectralPowerDistribution('Tri Spd', data2, mpg, lbl)
>>> tri_spd3 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd1 != tri_spd2
True
>>> tri_spd1 != tri_spd3
False
Sets the wavelength \(\lambda\) with given value.
Parameters: |
|
---|
Notes
Examples
>>> x_bar = {}
>>> y_bar = {}
>>> z_bar = {}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd[510] = (49.6700, 49.6700, 49.6700)
>>> tri_spd.values
array([[ 49.67, 49.67, 49.67]])
Implements support for tri-spectral power distribution subtraction.
Parameters: | x (numeric or array_like or TriSpectralPowerDistribution) – Variable to subtract. |
---|---|
Returns: | Variable subtracted tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
TriSpectralPowerDistribution.__add__(), TriSpectralPowerDistribution.__mul__(), TriSpectralPowerDistribution.__div__()
Notes
Warning
The subtraction operation happens in place.
Examples
Subtracting a single numeric variable:
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd - 10
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 39.67, 80.56, 2.43],
[ 59.59, 77.34, 13.15],
[ 71.73, 35.76, 57.98],
[ 78.19, 13.45, 80.28]])
Subtracting an array_like variable:
>>> tri_spd - [(1, 2, 3)] * 4
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 38.67, 78.56, -0.57],
[ 58.59, 75.34, 10.15],
[ 70.73, 33.76, 54.98],
[ 77.19, 11.45, 77.28]])
Subtracting a TriSpectralPowerDistribution class variable:
>>> data1 = {'x_bar': z_bar, 'y_bar': x_bar, 'z_bar': y_bar}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd - tri_spd1
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 26.24, 28.89, -91.13],
[ 35.44, 5.75, -77.19],
[ 2.75, -47.97, 9.22],
[-13.09, -76.74, 53.83]])
Implements support for tri-spectral power distribution division.
Parameters: | x (numeric or array_like or TriSpectralPowerDistribution) – Variable to divide. |
---|---|
Returns: | Variable divided tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
TriSpectralPowerDistribution.__add__(), TriSpectralPowerDistribution.__sub__(), TriSpectralPowerDistribution.__mul__()
Notes
Warning
The division operation happens in place.
Examples
Dividing a single numeric variable:
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd / 10
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 4.967, 9.056, 1.243],
[ 6.959, 8.734, 2.315],
[ 8.173, 4.576, 6.798],
[ 8.819, 2.345, 9.028]])
Dividing an array_like variable:
>>> tri_spd / [(1, 2, 3)] * 4
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 19.868 , 18.112 , 1.6573333...],
[ 27.836 , 17.468 , 3.0866666...],
[ 32.692 , 9.152 , 9.064 ...],
[ 35.276 , 4.69 , 12.0373333...]])
Dividing a TriSpectralPowerDistribution class variable:
>>> data1 = {'x_bar': z_bar, 'y_bar': x_bar, 'z_bar': y_bar}
>>> tri_spd1 = TriSpectralPowerDistribution('Tri Spd', data1, mpg, lbl)
>>> tri_spd / tri_spd1
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 1.5983909..., 0.3646466..., 0.0183009...],
[ 1.2024190..., 0.2510130..., 0.0353408...],
[ 0.4809061..., 0.1119784..., 0.1980769...],
[ 0.3907399..., 0.0531806..., 0.5133191...]])
Aligns the tri-spectral power distribution to given shape: Interpolates first then extrapolates to fit the given range.
Parameters: |
|
---|---|
Returns: | Aligned tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
Examples
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.align(SpectralShape(505, 565, 1))
<...TriSpectralPowerDistribution object at 0x...>
>>> # Doctests skip for Python 2.x compatibility.
>>> tri_spd.wavelengths
array([505, 506, 507, 508, 509, 510, 511, 512, 513, 514, 515, 516, 517,
518, 519, 520, 521, 522, 523, 524, 525, 526, 527, 528, 529, 530,
531, 532, 533, 534, 535, 536, 537, 538, 539, 540, 541, 542, 543,
544, 545, 546, 547, 548, 549, 550, 551, 552, 553, 554, 555, 556,
557, 558, 559, 560, 561, 562, 563, 564, 565])
>>> tri_spd.values
array([[ 49.67 ..., 90.56 ..., 12.43 ...],
[ 49.67 ..., 90.56 ..., 12.43 ...],
[ 49.67 ..., 90.56 ..., 12.43 ...],
[ 49.67 ..., 90.56 ..., 12.43 ...],
[ 49.67 ..., 90.56 ..., 12.43 ...],
[ 49.67 ..., 90.56 ..., 12.43 ...],
[ 51.8325938..., 91.2994928..., 12.5377184...],
[ 53.9841952..., 91.9502387..., 12.7233193...],
[ 56.1205452..., 92.5395463..., 12.9651679...],
[ 58.2315395..., 93.0150037..., 13.3123777...],
[ 60.3033208..., 93.2716331..., 13.8605136...],
[ 62.3203719..., 93.1790455..., 14.7272944...],
[ 64.2676077..., 92.6085951..., 16.0282961...],
[ 66.1324679..., 91.4605335..., 17.8526544...],
[ 67.9070097..., 89.6911649..., 20.2387677...],
[ 69.59 ..., 87.34 ..., 23.15 ...],
[ 71.1837378..., 84.4868033..., 26.5150469...],
[ 72.6800056..., 81.0666018..., 30.3964852...],
[ 74.0753483..., 77.0766254..., 34.7958422...],
[ 75.3740343..., 72.6153870..., 39.6178858...],
[ 76.5856008..., 67.8490714..., 44.7026805...],
[ 77.7223995..., 62.9779261..., 49.8576432...],
[ 78.7971418..., 58.2026503..., 54.8895997...],
[ 79.8204447..., 53.6907852..., 59.6368406...],
[ 80.798376 ..., 49.5431036..., 64.0011777...],
[ 81.73 ..., 45.76 ..., 67.98 ...],
[ 82.6093606..., 42.2678534..., 71.6460893...],
[ 83.439232 ..., 39.10608 ..., 74.976976 ...],
[ 84.2220071..., 36.3063728..., 77.9450589...],
[ 84.956896 ..., 33.85464 ..., 80.552 ...],
[ 85.6410156..., 31.7051171..., 82.8203515...],
[ 86.27048 ..., 29.79448 ..., 84.785184 ...],
[ 86.8414901..., 28.0559565..., 86.4857131...],
[ 87.351424 ..., 26.43344 ..., 87.956928 ...],
[ 87.7999266..., 24.8956009..., 89.2212178...],
[ 88.19 ..., 23.45 ..., 90.28 ...],
[ 88.5265036..., 22.1424091..., 91.1039133...],
[ 88.8090803..., 20.9945234..., 91.6538035...],
[ 89.0393279..., 20.0021787..., 91.9333499...],
[ 89.2222817..., 19.1473370..., 91.9858818...],
[ 89.3652954..., 18.4028179..., 91.8811002...],
[ 89.4769231..., 17.7370306..., 91.7018000...],
[ 89.5657996..., 17.1187058..., 91.5305910...],
[ 89.6395227..., 16.5216272..., 91.4366204...],
[ 89.7035339..., 15.9293635..., 91.4622944...],
[ 89.76 ..., 15.34 ..., 91.61 ...],
[ 89.8094041..., 14.7659177..., 91.8528616...],
[ 89.8578890..., 14.2129190..., 92.2091737...],
[ 89.9096307..., 13.6795969..., 92.6929664...],
[ 89.9652970..., 13.1613510..., 93.2988377...],
[ 90.0232498..., 12.6519811..., 94.0078786...],
[ 90.0807467..., 12.1452800..., 94.7935995...],
[ 90.1351435..., 11.6366269..., 95.6278555...],
[ 90.1850956..., 11.1245805..., 96.4867724...],
[ 90.2317606..., 10.6124724..., 97.3566724...],
[ 90.28 ..., 10.11 ..., 98.24 ...],
[ 90.28 ..., 10.11 ..., 98.24 ...],
[ 90.28 ..., 10.11 ..., 98.24 ...],
[ 90.28 ..., 10.11 ..., 98.24 ...],
[ 90.28 ..., 10.11 ..., 98.24 ...],
[ 90.28 ..., 10.11 ..., 98.24 ...]])
Clones the tri-spectral power distribution.
Most of the TriSpectralPowerDistribution class operations are conducted in-place. The TriSpectralPowerDistribution.clone() method provides a convenient way to copy the tri-spectral power distribution to a new object.
Returns: | Cloned tri-spectral power distribution. |
---|---|
Return type: | TriSpectralPowerDistribution |
Examples
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> print(tri_spd)
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd_clone = tri_spd.clone()
>>> print(tri_spd_clone)
<...TriSpectralPowerDistribution object at 0x...>
Property for self.__data private attribute.
Returns: | self.__data. |
---|---|
Return type: | dict |
Extrapolates the tri-spectral power distribution following CIE 15:2004 recommendation.
Parameters: |
|
---|---|
Returns: | Extrapolated tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
References
[6] | CIE 015:2004 Colorimetry, 3rd edition: 7.2.2.1 Extrapolation |
[7] | CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations: 10. EXTRAPOLATION |
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.extrapolate(SpectralShape(400, 700)).shape
SpectralShape(400, 700, 10)
>>> tri_spd[400]
array([ 49.67, 90.56, 12.43])
>>> tri_spd[700]
array([ 88.19, 23.45, 90.28])
Returns the values for given wavelength \(\lambda\).
Parameters: |
|
---|---|
Returns: | Wavelength \(\lambda\) values. |
Return type: | numeric |
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd[510]
array([ 49.67, 90.56, 12.43])
>>> tri_spd.get(511)
None
Interpolates the tri-spectral power distribution following CIE 167:2005 recommendations: the method developed by Sprague (1880) should be used for interpolating functions having a uniformly spaced independent variable and a Cubic Spline method for non-uniformly spaced independent variable.
Parameters: |
|
---|---|
Returns: | Interpolated tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
See also
Notes
Warning
See SpectralPowerDistribution.interpolate() method warning section.
References
[4] | CIE 167:2005 Recommended Practice for Tabulating Spectral Data for Use in Colour Computations: 9. INTERPOLATION |
Examples
Uniform data is using Sprague interpolation by default:
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.interpolate(SpectralShape(steps=1))
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd[515]
array([ 60.30332087, 93.27163315, 13.86051361])
Non uniform data is using Cubic Spline interpolation by default:
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd[511] = (31.41, 95.27, 15.06)
>>> tri_spd.interpolate(SpectralShape(steps=1))
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd[515]
array([ 21.47104053, 100.64300155, 18.8165196 ])
Enforcing Linear interpolation:
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.interpolate(SpectralShape(steps=1), method='Linear')
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd[515]
array([ 59.63, 88.95, 17.79])
Returns if the tri-spectral power distribution has uniformly spaced data.
Returns: | Is uniform. |
---|---|
Return type: | bool |
See also
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.is_uniform()
True
Breaking the steps by introducing new wavelength \(\lambda\) values:
>>> tri_spd[511] = (49.6700, 49.6700, 49.6700)
>>> tri_spd.is_uniform()
False
Property for self.items attribute. This is a convenient attribute used to iterate over the tri-spectral power distribution.
Returns: | Tri-spectral power distribution data generator. |
---|---|
Return type: | generator |
Property for self.__labels private attribute.
Returns: | self.__labels. |
---|---|
Return type: | dict |
Property for self.__mapping private attribute.
Returns: | self.__mapping. |
---|---|
Return type: | dict |
Property for self.__name private attribute.
Returns: | self.__name. |
---|---|
Return type: | str or unicode |
Normalises the tri-spectral power distribution with given normalization factor.
Parameters: | factor (numeric, optional) – Normalization factor |
---|---|
Returns: | Normalised tri- spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
Notes
Examples
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.normalise()
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 0.5055985..., 0.9218241..., 0.1265268...],
[ 0.7083672..., 0.8890472..., 0.2356473...],
[ 0.8319421..., 0.4657980..., 0.6919788...],
[ 0.8976995..., 0.2387011..., 0.9189739...],
[ 0.9136807..., 0.1561482..., 0.9325122...],
[ 0.9189739..., 0.1029112..., 1. ...]])
Property for self.shape attribute.
Returns the shape of the tri-spectral power distribution in the form of a SpectralShape class instance.
Returns: | Tri-spectral power distribution shape. |
---|---|
Return type: | SpectralShape |
Warning
TriSpectralPowerDistribution.shape is read only.
Examples
>>> x_bar = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> y_bar = {510: 90.56, 520: 87.34, 530: 45.76, 540: 23.45}
>>> z_bar = {510: 12.43, 520: 23.15, 530: 67.98, 540: 90.28}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.shape
SpectralShape(510, 540, 10)
Property for self.values attribute.
Returns: | Tri-spectral power distribution wavelengths \(\lambda_n\) values. |
---|---|
Return type: | ndarray |
Warning
TriSpectralPowerDistribution.values is read only.
Property for self.wavelengths attribute.
Returns: | Tri-spectral power distribution wavelengths \(\lambda_n\). |
---|---|
Return type: | ndarray |
Warning
TriSpectralPowerDistribution.wavelengths is read only.
Property for self.x attribute.
Returns: | Spectral power distribution for x axis. |
---|---|
Return type: | SpectralPowerDistribution |
Warning
TriSpectralPowerDistribution.x is read only.
Property for self.y attribute.
Returns: | Spectral power distribution for y axis. |
---|---|
Return type: | SpectralPowerDistribution |
Warning
TriSpectralPowerDistribution.y is read only.
Property for self.z attribute.
Returns: | Spectral power distribution for z axis. |
---|---|
Return type: | SpectralPowerDistribution |
Warning
TriSpectralPowerDistribution.z is read only.
Zeros fills the tri-spectral power distribution: Missing values will be replaced with zeros to fit the defined range.
Parameters: | shape (SpectralShape, optional) – Spectral shape used for zeros fill. |
---|---|
Returns: | Zeros filled tri-spectral power distribution. |
Return type: | TriSpectralPowerDistribution |
Examples
>>> x_bar = {
... 510: 49.67,
... 520: 69.59,
... 530: 81.73,
... 540: 88.19,
... 550: 89.76,
... 560: 90.28}
>>> y_bar = {
... 510: 90.56,
... 520: 87.34,
... 530: 45.76,
... 540: 23.45,
... 550: 15.34,
... 560: 10.11}
>>> z_bar = {
... 510: 12.43,
... 520: 23.15,
... 530: 67.98,
... 540: 90.28,
... 550: 91.61,
... 560: 98.24}
>>> data = {'x_bar': x_bar, 'y_bar': y_bar, 'z_bar': z_bar}
>>> mpg = lbl = {'x': 'x_bar', 'y': 'y_bar', 'z': 'z_bar'}
>>> tri_spd = TriSpectralPowerDistribution('Tri Spd', data, mpg, lbl)
>>> tri_spd.zeros(SpectralShape(505, 565, 1))
<...TriSpectralPowerDistribution object at 0x...>
>>> tri_spd.values
array([[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 49.67, 90.56, 12.43],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 69.59, 87.34, 23.15],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 81.73, 45.76, 67.98],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 88.19, 23.45, 90.28],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 89.76, 15.34, 91.61],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 90.28, 10.11, 98.24],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ],
[ 0. , 0. , 0. ]])
Returns a spectral power distribution of given spectral shape filled with constant \(k\) values.
Parameters: |
|
---|---|
Returns: | Constant \(k\) to filled spectral power distribution. |
Return type: | SpectralPowerDistribution |
Notes
Examples
>>> spd = constant_spd(100)
>>> spd.shape
SpectralShape(360, 830, 1)
>>> spd[400]
100.0
Returns a spectral power distribution of given spectral shape filled with zeros.
Parameters: | shape (SpectralShape, optional) – Spectral shape used to create the spectral power distribution. |
---|---|
Returns: | Zeros filled spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
Notes
Examples
>>> spd = zeros_spd()
>>> spd.shape
SpectralShape(360, 830, 1)
>>> spd[400]
0.0
Returns a spectral power distribution of given spectral shape filled with ones.
Parameters: | shape (SpectralShape, optional) – Spectral shape used to create the spectral power distribution. |
---|---|
Returns: | Ones filled spectral power distribution. |
Return type: | SpectralPowerDistribution |
See also
Notes
Examples
>>> spd = ones_spd()
>>> spd.shape
SpectralShape(360, 830, 1)
>>> spd[400]
1.0
Returns the spectral power distribution of the planckian radiator for given temperature \(T[K]\).
Parameters: |
|
---|---|
Returns: | Blackbody spectral power distribution. |
Return type: | SpectralPowerDistribution |
Examples
>>> from colour import STANDARD_OBSERVERS_CMFS
>>> cmfs = STANDARD_OBSERVERS_CMFS.get('CIE 1931 2 Degree Standard Observer')
>>> blackbody_spd(5000, cmfs.shape)
<colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
Returns the spectral radiance of a blackbody at thermodynamic temperature \(T[K]\) in a medium having index of refraction \(n\).
Notes
The following form implementation is expressed in term of wavelength. The SI unit of radiance is watts per steradian per square metre.
References
[1] | CIE 015:2004 Colorimetry, 3rd edition: Appendix E. Information on the Use of Planck”s Equation for Standard Air. |
Parameters: |
|
---|---|
Returns: | Radiance in watts per steradian per square metre. |
Return type: | numeric |
Examples
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> planck_law(500 * 1e-9, 5500)
20472701909806.5...
Returns the spectral radiance of a blackbody at thermodynamic temperature \(T[K]\) in a medium having index of refraction \(n\).
Notes
The following form implementation is expressed in term of wavelength. The SI unit of radiance is watts per steradian per square metre.
References
[1] | CIE 015:2004 Colorimetry, 3rd edition: Appendix E. Information on the Use of Planck”s Equation for Standard Air. |
Parameters: |
|
---|---|
Returns: | Radiance in watts per steradian per square metre. |
Return type: | numeric |
Examples
>>> # Doctests ellipsis for Python 2.x compatibility.
>>> planck_law(500 * 1e-9, 5500)
20472701909806.5...
Bases: colour.colorimetry.spectrum.TriSpectralPowerDistribution
Implements support for the Stockman & Sharpe LMS cone fundamentals colour matching functions.
Parameters: |
|
---|
Property for self.x attribute.
Returns: | self.x |
---|---|
Return type: | SpectralPowerDistribution |
Warning
LMS_ConeFundamentals.l_bar is read only.
Property for self.y attribute.
Returns: | self.y |
---|---|
Return type: | SpectralPowerDistribution |
Warning
LMS_ConeFundamentals.m_bar is read only.
Property for self.z attribute.
Returns: | self.z |
---|---|
Return type: | SpectralPowerDistribution |
Warning
LMS_ConeFundamentals.s_bar is read only.
Bases: colour.colorimetry.spectrum.TriSpectralPowerDistribution
Implements support for the CIE RGB colour matching functions.
Parameters: |
|
---|
Property for self.z attribute.
Returns: | self.z |
---|---|
Return type: | SpectralPowerDistribution |
Warning
RGB_ColourMatchingFunctions.b_bar is read only.
Property for self.y attribute.
Returns: | self.y |
---|---|
Return type: | SpectralPowerDistribution |
Warning
RGB_ColourMatchingFunctions.g_bar is read only.
Property for self.x attribute.
Returns: | self.x |
---|---|
Return type: | SpectralPowerDistribution |
Warning
RGB_ColourMatchingFunctions.r_bar is read only.
Bases: colour.colorimetry.spectrum.TriSpectralPowerDistribution
Implements support for the CIE Standard Observers XYZ colour matching functions.
Parameters: |
|
---|
Property for self.x attribute.
Returns: | self.x |
---|---|
Return type: | SpectralPowerDistribution |
Warning
XYZ_ColourMatchingFunctions.x_bar is read only.
Property for self.y attribute.
Returns: | self.y |
---|---|
Return type: | SpectralPowerDistribution |
Warning
XYZ_ColourMatchingFunctions.y_bar is read only.
Property for self.z attribute.
Returns: | self.z |
---|---|
Return type: | SpectralPowerDistribution |
Warning
XYZ_ColourMatchingFunctions.z_bar is read only.
Implements spectral bandpass dependence correction on given spectral power distribution using given method.
Parameters: |
|
---|---|
Returns: | Spectral bandpass dependence corrected spectral power distribution. |
Return type: | SpectralPowerDistribution |
Implements spectral bandpass dependence correction on given spectral power distribution using Stearns and Stearns (1988) method.
References
[1] | Stephen Westland, Caterina Ripamonti, Vien Cheung, Computational Colour Science Using MATLAB, 2nd Edition, The Wiley-IS&T Series in Imaging Science and Technology, published July 2012, ISBN-13: 978-0-470-66569-5, page 38. |
Parameters: | spd (SpectralPowerDistribution) – Spectral power distribution. |
---|---|
Returns: | Spectral bandpass dependence corrected spectral power distribution. |
Return type: | SpectralPowerDistribution |
Examples
>>> from colour import SpectralPowerDistribution
>>> data = {510: 49.67, 520: 69.59, 530: 81.73, 540: 88.19}
>>> spd = SpectralPowerDistribution('Spd', data)
>>> corrected_spd = bandpass_correction_stearns1988(spd)
>>> corrected_spd.values
array([ 48.01664 , 70.3729688..., 82.0919506..., 88.72618 ])
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: | CIE Standard Illuminant D Series relative spectral power distribution. |
Return type: | SpectralPowerDistribution |
Examples
>>> D_illuminant_relative_spd((0.34567, 0.35850))
<colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
Returns the mesopic luminous efficiency function \(V_m(\lambda)\) for given photopic luminance \(L_p\).
Parameters: |
|
---|---|
Returns: | Mesopic luminous efficiency function \(V_m(\lambda)\). |
Return type: | SpectralPowerDistribution |
Examples
>>> mesopic_luminous_efficiency_function(0.2)
<colour.colorimetry.spectrum.SpectralPowerDistribution object at 0x...>
Calculates the mesopic weighting function factor at given wavelength \(\lambda\) using the photopic luminance \(L_p\).
Parameters: |
|
---|---|
Returns: | Mesopic weighting function factor. |
Return type: | numeric |
Raises: | KeyError – If wavelength \(\lambda\) is not available in either luminous efficiency function. |
Examples
>>> mesopic_weighting_function(500, 0.2)
0.7052200...
Returns the Lightness \(L^*\) using given method.
Parameters: |
|
---|---|
Returns: | Lightness \(L^*\). |
Return type: | numeric |
Notes
Examples
>>> lightness(10.08)
37.9856290...
>>> lightness(10.08, Yn=100)
37.9856290...
>>> lightness(10.08, Yn=95)
38.9165987...
>>> lightness(10.08, method='Glasser 1958')
36.2505626...
>>> lightness(10.08, method='Wyszecki 1964')
37.0041149...
Returns the Lightness \(L^*\) of given luminance \(Y\) using Glasser et al. (1958) method.
Parameters: |
|
---|---|
Returns: | Lightness \(L^*\). |
Return type: | numeric |
Notes
References
[1] | http://en.wikipedia.org/wiki/Lightness (Last accessed 13 April 2014) |
Examples
>>> lightness_glasser1958(10.08)
36.2505626...
Returns the Lightness \(W^*\) of given luminance \(Y\) using Wyszecki (1964) method.
Parameters: |
|
---|---|
Returns: | Lightness \(W^*\). |
Return type: | numeric |
Notes
References
[1] | http://en.wikipedia.org/wiki/Lightness (Last accessed 13 April 2014) |
Examples
>>> lightness_wyszecki1964(10.08)
37.0041149...
Returns the Lightness \(L^*\) of given luminance \(Y\) using given reference white luminance \(Y_n\) as per CIE Lab implementation.
Parameters: |
|
---|---|
Returns: | Lightness \(L^*\). |
Return type: | numeric |
Notes
References
[2] | http://www.poynton.com/PDFs/GammaFAQ.pdf (Last accessed 12 April 2014) |
Examples
>>> lightness_1976(10.08)
37.9856290...
Returns the luminance \(Y\) of given Lightness \(L^*\) or given Munsell value \(V\).
Parameters: |
|
---|---|
Returns: | luminance \(Y\). |
Return type: | numeric |
Notes
Examples
>>> luminance(37.9856290977)
10.0800000...
>>> luminance(37.9856290977, Yn=100)
10.0800000...
>>> luminance(37.9856290977, Yn=95)
9.5760000...
>>> luminance(3.74629715382, method='Newhall 1943')
10.4089874...
>>> luminance(3.74629715382, method='ASTM D1535-08')
10.1488096...
Returns the luminance \(Y\) of given Munsell value \(V\) using Newhall, Nickerson, and Judd (1943) method.
Parameters: |
|
---|---|
Returns: | luminance \(Y\). |
Return type: | numeric |
Notes
References
[1] | http://en.wikipedia.org/wiki/Lightness (Last accessed 13 April 2014) |
Examples
>>> luminance_newhall1943(3.74629715382)
10.4089874...
Returns the luminance \(Y\) of given Lightness \(L^*\) with given reference white luminance \(Y_n\).
Parameters: |
|
---|---|
Returns: | luminance \(Y\). |
Return type: | numeric |
Notes
References
[2] | http://www.poynton.com/PDFs/GammaFAQ.pdf (Last accessed 12 April 2014) |
Examples
>>> luminance_1976(37.9856290977)
10.0800000...
Returns the luminance \(Y\) of given Munsell value \(V\) using ASTM D1535-08e1 (2008) method.
Parameters: |
|
---|---|
Returns: | luminance \(Y\). |
Return type: | numeric |
Notes
References
Examples
>>> luminance_ASTM_D1535_08(3.74629715382)
10.1488096...
Converts Stiles & Burch 1959 10 Degree RGB CMFs colour matching functions into the Stockman & Sharpe 10 Degree Cone Fundamentals spectral sensitivity functions.
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) in nm. |
---|---|
Returns: | Stockman & Sharpe 10 Degree Cone Fundamentals spectral tristimulus values. |
Return type: | ndarray, (3,) |
Raises: | KeyError – If wavelength \(\lambda\) is not available in the colour matching functions. |
Notes
References
[3] | CIE 170-1:2006 Fundamental Chromaticity Diagram with Physiological Axes - Part 1 |
Examples
>>> RGB_10_degree_cmfs_to_LMS_10_degree_cmfs(700)
array([ 0.0052860..., 0.0003252..., 0. ])
Converts Wright & Guild 1931 2 Degree RGB CMFs colour matching functions into the CIE 1931 2 Degree Standard Observer colour matching functions.
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) in nm. |
---|---|
Returns: | CIE 1931 2 Degree Standard Observer spectral tristimulus values. |
Return type: | ndarray, (3,) |
Raises: | KeyError – If wavelength \(\lambda\) is not available in the colour matching functions. |
Notes
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, pages 138, 139. |
Examples
>>> RGB_2_degree_cmfs_to_XYZ_2_degree_cmfs(700)
array([ 0.0113577..., 0.004102 , 0. ])
Converts Stiles & Burch 1959 10 Degree RGB CMFs colour matching functions into the CIE 1964 10 Degree Standard Observer colour matching functions.
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) in nm. |
---|---|
Returns: | CIE 1964 10 Degree Standard Observer spectral tristimulus values. |
Return type: | ndarray, (3,) |
Raises: | KeyError – If wavelength \(\lambda\) is not available in the colour matching functions. |
Notes
References
[2] | 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 141. |
Examples
>>> RGB_10_degree_cmfs_to_XYZ_10_degree_cmfs(700)
array([ 9.6432150...e-03, 3.7526317...e-03, -4.1078830...e-06])
Converts Stockman & Sharpe 2 Degree Cone Fundamentals colour matching functions into the CIE 2012 2 Degree Standard Observer colour matching functions.
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) in nm. |
---|---|
Returns: | CIE 2012 2 Degree Standard Observer spectral tristimulus values. |
Return type: | ndarray, (3,) |
Raises: | KeyError – If wavelength \(\lambda\) is not available in the colour matching functions. |
Notes
References
[4] | http://www.cvrl.org/database/text/cienewxyz/cie2012xyz2.htm (Last accessed 25 June 2014) |
Examples
>>> LMS_2_degree_cmfs_to_XYZ_2_degree_cmfs(700)
array([ 0.0109677..., 0.0041959..., 0. ])
Converts Stockman & Sharpe 10 Degree Cone Fundamentals colour matching functions into the CIE 2012 10 Degree Standard Observer colour matching functions.
Parameters: | wavelength (numeric) – Wavelength \(\lambda\) in nm. |
---|---|
Returns: | CIE 2012 10 Degree Standard Observer spectral tristimulus values. |
Return type: | ndarray, (3,) |
Raises: | KeyError – If wavelength \(\lambda\) is not available in the colour matching functions. |
Notes
References
[5] | http://www.cvrl.org/database/text/cienewxyz/cie2012xyz10.htm (Last accessed 25 June 2014) |
Examples
>>> LMS_10_degree_cmfs_to_XYZ_10_degree_cmfs(700)
array([ 0.0098162..., 0.0037761..., 0. ])
Converts given spectral power distribution to CIE XYZ colourspace using given colour matching functions and illuminant.
Parameters: |
|
---|---|
Returns: | CIE XYZ colourspace matrix. |
Return type: | ndarray, (3,) |
Warning
The output domain of that definition is non standard!
Notes
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 158. |
Examples
>>> from colour import CMFS, ILLUMINANTS_RELATIVE_SPDS, SpectralPowerDistribution
>>> cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
>>> data = {380: 0.0600, 390: 0.0600}
>>> spd = SpectralPowerDistribution('Custom', data)
>>> illuminant = ILLUMINANTS_RELATIVE_SPDS.get('D50')
>>> spectral_to_XYZ(spd, cmfs, illuminant)
array([ 4.5764852...e-04, 1.2964866...e-05, 2.1615807...e-03])
Converts given wavelength \(\lambda\) to CIE XYZ colourspace using given colour matching functions.
If the wavelength \(\lambda\) is not available in the colour matching function, its value will be calculated using CIE recommendations: The method developed by Sprague (1880) should be used for interpolating functions having a uniformly spaced independent variable and a Cubic Spline method for non-uniformly spaced independent variable.
Parameters: |
|
---|---|
Returns: | CIE XYZ colourspace matrix. |
Return type: | ndarray, (3,) |
Raises: | ValueError – If wavelength \(\lambda\) is not in the colour matching functions domain. |
Notes
Examples
>>> from colour import CMFS
>>> cmfs = CMFS.get('CIE 1931 2 Degree Standard Observer')
>>> wavelength_to_XYZ(480)
array([ 0.09564 , 0.13902 , 0.812950...])