colour.SpectralPowerDistribution¶
-
class
colour.
SpectralPowerDistribution
(data=None, domain=None, **kwargs)[source]¶ Defines the spectral power distribution: the base object for spectral computations.
The spectral power distribution will be initialised according to CIE 15:2004 recommendation: the method developed by Sprague (1880) will be used for interpolating functions having a uniformly spaced independent variable and the Cubic Spline method for non-uniformly spaced independent variable. Extrapolation is performed according to CIE 167:2005 recommendation.
Parameters: - data (Series or Signal, SpectralPowerDistribution or array_like or dict_like, optional) – Data to be stored in the spectral power distribution.
- domain (array_like, optional) – Values to initialise the
colour.SpectralPowerDistribution.wavelength
attribute with. If bothdata
anddomain
arguments are defined, the latter will be used to initialise thecolour.SpectralPowerDistribution.wavelength
attribute.
Other Parameters: - name (unicode, optional) – Spectral power distribution name.
- interpolator (object, optional) – Interpolator class type to use as interpolating function.
- interpolator_args (dict_like, optional) – Arguments to use when instantiating the interpolating function.
- extrapolator (object, optional) – Extrapolator class type to use as extrapolating function.
- extrapolator_args (dict_like, optional) – Arguments to use when instantiating the extrapolating function.
- strict_name (unicode, optional) – Spectral power distribution name for figures, default to
colour.SpectralPowerDistribution.name
attribute value.
-
strict_name
¶
-
wavelengths
¶
-
values
¶
-
shape
¶
References
Examples
Instantiating a spectral power distribution with a uniformly spaced independent variable:
>>> from colour.utilities import numpy_print_options >>> data = { ... 500: 0.0651, ... 520: 0.0705, ... 540: 0.0772, ... 560: 0.0870, ... 580: 0.1128, ... 600: 0.1360 ... } >>> with numpy_print_options(suppress=True): ... SpectralPowerDistribution(data) SpectralPowerDistribution([[ 500. , 0.0651], [ 520. , 0.0705], [ 540. , 0.0772], [ 560. , 0.087 ], [ 580. , 0.1128], [ 600. , 0.136 ]], interpolator=SpragueInterpolator, interpolator_args={}, extrapolator=Extrapolator, extrapolator_args={...})
Instantiating a spectral power distribution with a non-uniformly spaced independent variable:
>>> data[510] = 0.31416 >>> with numpy_print_options(suppress=True): ... SpectralPowerDistribution(data) SpectralPowerDistribution([[ 500. , 0.0651 ], [ 510. , 0.31416], [ 520. , 0.0705 ], [ 540. , 0.0772 ], [ 560. , 0.087 ], [ 580. , 0.1128 ], [ 600. , 0.136 ]], interpolator=CubicSplineInterpolator, interpolator_args={}, extrapolator=Extrapolator, extrapolator_args={...})
-
__init__
(data=None, domain=None, **kwargs)[source]
Methods
__init__
([data, domain])align
(shape[, interpolator, …])Aligns the spectral power distribution in-place to given spectral shape: Interpolates first then extrapolates to fit the given range. arithmetical_operation
(a, operation[, in_place])Performs given arithmetical operation with \(a\) operand, the operation can be either performed on a copy or in-place. clone
()copy
()Returns a copy of the sub-class instance, must be reimplemented by sub-classes. domain_distance
(a)Returns the euclidean distance between given array and independent domain \(x\) closest element. extrapolate
(shape[, extrapolator, …])Extrapolates the spectral power distribution in-place according to CIE 15:2004 and CIE 167:2005 recommendations or given extrapolation arguments. fill_nan
([method, default])Fill NaNs in independent domain \(x\) variable and corresponding range \(y\) variable using given method. get
()interpolate
(shape[, interpolator, …])Interpolates the spectral power distribution in-place according to CIE 167:2005 recommendation or given interpolation arguments. is_uniform
()Returns if independent domain \(x\) variable is uniform. normalise
([factor])Normalises the spectral power distribution using given normalization factor. signal_unpack_data
([data, domain, dtype])Unpack given data for continuous signal instantiation. to_series
()Converts the continuous signal to a Pandas Series
class instance.trim
(shape)Trims the spectral power distribution wavelengths to given spectral shape. trim_wavelengths
(shape)zeros
()