colour.continuous.MultiSignal

class colour.continuous.MultiSignal(data=None, domain=None, labels=None, **kwargs)[source]

Defines the base class for multi-continuous signal, a container for multiple colour.continuous.Signal sub-class instances.

Parameters:
Other Parameters:
 
  • name (unicode, optional) – Multi-continuous signal name.
  • dtype (type, optional) – {np.float16, np.float32, np.float64, np.float128}, Floating point data type.
  • interpolator (object, optional) – Interpolator class type to use as interpolating function for the colour.continuous.Signal sub-class instances.
  • interpolator_args (dict_like, optional) – Arguments to use when instantiating the interpolating function of the colour.continuous.Signal sub-class instances.
  • extrapolator (object, optional) – Extrapolator class type to use as extrapolating function for the colour.continuous.Signal sub-class instances.
  • extrapolator_args (dict_like, optional) – Arguments to use when instantiating the extrapolating function of the colour.continuous.Signal sub-class instances.
  • signal_type (type, optional) – The colour.continuous.Signal sub-class type used for instances.
dtype
domain
range
interpolator
interpolator_args
extrapolator
extrapolator_args
function
signals
labels
__str__()[source]
__repr__()[source]
__getitem__()[source]
__setitem__()[source]
__contains__()[source]
__eq__()[source]
__ne__()[source]
arithmetical_operation()[source]
multi_signal_unpack_data()[source]
fill_nan()[source]
to_dataframe()[source]

Examples

Instantiation with implicit domain and a single signal:

>>> range_ = np.linspace(10, 100, 10)
>>> print(MultiSignal(range_))
[[   0.   10.]
 [   1.   20.]
 [   2.   30.]
 [   3.   40.]
 [   4.   50.]
 [   5.   60.]
 [   6.   70.]
 [   7.   80.]
 [   8.   90.]
 [   9.  100.]]

Instantiation with explicit domain and a single signal:

>>> domain = np.arange(100, 1100, 100)
>>> print(MultiSignal(range_, domain))
[[  100.    10.]
 [  200.    20.]
 [  300.    30.]
 [  400.    40.]
 [  500.    50.]
 [  600.    60.]
 [  700.    70.]
 [  800.    80.]
 [  900.    90.]
 [ 1000.   100.]]

Instantiation with multiple signals:

>>> range_ = tstack([np.linspace(10, 100, 10)] * 3)
>>> range_ += np.array([0, 10, 20])
>>> print(MultiSignal(range_, domain))
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]

Instantiation with a dict:

>>> print(MultiSignal(dict(zip(domain, range_))))
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]

Instantiation using a Signal sub-class:

>>> class NotSignal(Signal):
...     pass
>>> multi_signal = MultiSignal(range_, domain, signal_type=NotSignal)
>>> print(multi_signal)
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]
 >>> type(multi_signal.signals[0])  
 <class 'multi_signal.NotSignal'>

Instantiation with a Pandas Series:

>>> if is_pandas_installed():
...     from pandas import Series
...     print(MultiSignal(  
...         Series(dict(zip(domain, np.linspace(10, 100, 10))))))
[[  100.    10.]
 [  200.    20.]
 [  300.    30.]
 [  400.    40.]
 [  500.    50.]
 [  600.    60.]
 [  700.    70.]
 [  800.    80.]
 [  900.    90.]
 [ 1000.   100.]]

Instantiation with a Pandas Dataframe:

>>> if is_pandas_installed():
...     from pandas import DataFrame
...     data = dict(zip(['a', 'b', 'c'], tsplit(range_)))
...     print(MultiSignal(  
...         DataFrame(data, domain)))
[[  100.    10.    20.    30.]
 [  200.    20.    30.    40.]
 [  300.    30.    40.    50.]
 [  400.    40.    50.    60.]
 [  500.    50.    60.    70.]
 [  600.    60.    70.    80.]
 [  700.    70.    80.    90.]
 [  800.    80.    90.   100.]
 [  900.    90.   100.   110.]
 [ 1000.   100.   110.   120.]]

Retrieving domain y variable for arbitrary range x variable:

>>> x = 150
>>> range_ = tstack([np.sin(np.linspace(0, 1, 10))] * 3)
>>> range_ += np.array([0.0, 0.25, 0.5])
>>> MultiSignal(range_, domain)[x]  
array([ 0.0359701...,  0.2845447...,  0.5331193...])
>>> x = np.linspace(100, 1000, 3)
>>> MultiSignal(range_, domain)[x]  
array([[  4.4085384...e-20,   2.5000000...e-01,   5.0000000...e-01],
       [  4.7669395...e-01,   7.2526859...e-01,   9.7384323...e-01],
       [  8.4147098...e-01,   1.0914709...e+00,   1.3414709...e+00]])

Using an alternative interpolating function:

>>> x = 150
>>> from colour.algebra import CubicSplineInterpolator
>>> MultiSignal(
...     range_,
...     domain,
...     interpolator=CubicSplineInterpolator)[x]  
array([ 0.0555274...,  0.3055274...,  0.5555274...])
>>> x = np.linspace(100, 1000, 3)
>>> MultiSignal(
...     range_,
...     domain,
...     interpolator=CubicSplineInterpolator)[x]  
array([[ 0.       ...,  0.25     ...,  0.5      ...],
       [ 0.4794253...,  0.7294253...,  0.9794253...],
       [ 0.8414709...,  1.0914709...,  1.3414709...]])
__init__(data=None, domain=None, labels=None, **kwargs)[source]

Methods

__init__([data, domain, labels])
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.
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.
fill_nan([method, default]) Fill NaNs in independent domain \(x\) variable and corresponding range \(y\) variable using given method.
is_uniform() Returns if independent domain \(x\) variable is uniform.
multi_signal_unpack_data([data, domain, …]) Unpack given data for multi-continuous signal instantiation.
to_dataframe() Converts the continuous signal to a Pandas DataFrame class instance.