colour.SpectralDistribution

class colour.SpectralDistribution(data=None, domain=None, **kwargs)[source]

Defines the spectral distribution: the base object for spectral computations.

The spectral 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, SpectralDistribution or array_like or dict_like, optional) – Data to be stored in the spectral distribution.
  • domain (array_like, optional) – Values to initialise the colour.SpectralDistribution.wavelength attribute with. If both data and domain arguments are defined, the latter will be used to initialise the colour.SpectralDistribution.wavelength attribute.
Other Parameters:
 
  • name (unicode, optional) – Spectral 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 distribution name for figures, default to colour.SpectralDistribution.name attribute value.
strict_name
wavelengths
values
shape
__init__()[source]
extrapolate()[source]
interpolate()[source]
align()[source]
trim()[source]
normalise()[source]

References

[CIET13805a], [CIET13805c], [CIET14804h]

Examples

Instantiating a spectral 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):
...     SpectralDistribution(data)  # doctest: +ELLIPSIS
SpectralDistribution([[ 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 distribution with a non-uniformly spaced independent variable:

>>> data[510] = 0.31416
>>> with numpy_print_options(suppress=True):
...     SpectralDistribution(data)  # doctest: +ELLIPSIS
SpectralDistribution([[ 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]

Initialize self. See help(type(self)) for accurate signature.

Methods

__init__([data, domain]) Initialize self.
align(shape[, interpolator, …]) Aligns the spectral 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.
domain_distance(a) Returns the euclidean distance between given array and independent domain \(x\) closest element.
extrapolate(shape[, extrapolator, …]) Extrapolates the spectral 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 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 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 distribution wavelengths to given spectral shape.
trim_wavelengths(shape)
zeros()

Attributes

data
domain Getter and setter property for the continuous signal independent domain \(x\) variable.
dtype Getter and setter property for the continuous signal dtype.
extrapolator Getter and setter property for the continuous signal extrapolator type.
extrapolator_args Getter and setter property for the continuous signal extrapolator instantiation time arguments.
function Getter and setter property for the continuous signal callable.
interpolator Getter and setter property for the continuous signal interpolator type.
interpolator_args Getter and setter property for the continuous signal interpolator instantiation time arguments.
items
name Getter and setter property for the abstract continuous function name.
range Getter and setter property for the continuous signal corresponding range \(y\) variable.
shape Getter and setter property for the spectral distribution shape.
strict_name Getter and setter property for the spectral distribution strict name.
title
values Getter and setter property for the spectral distribution values.
wavelengths Getter and setter property for the spectral distribution wavelengths \(\lambda_n\).