Return fractions of multiple components from phasor coordinates.
Component fractions are obtained from the least-squares solution of a
linear matrix equation that relates phasor coordinates from one or
multiple harmonics to component fractions according to [2].
Up to 2*numberharmonics+1 components can be fit to multi-harmonic
phasor coordinates, that is up to three components for single harmonic
phasor coordinates.
Parameters:
mean (array_like) – Intensity of phasor coordinates.
real (array_like) – Real component of phasor coordinates.
Harmonics, if any, must be in the first dimension.
imag (array_like) – Imaginary component of phasor coordinates.
Harmonics, if any, must be in the first dimension.
component_real (array_like) – Real coordinates of components.
Must be one or two-dimensional with harmonics in the first dimension.
component_imag (array_like) – Imaginary coordinates of components.
Must be one or two-dimensional with harmonics in the first dimension.
**kwargs (optional) – Additional arguments passed to scipy.linalg.lstsq().
Returns:
fractions – Component fractions, one array per component.
Fractions may not exactly add up to 1.0.
Return type:
tuple of ndarray
Raises:
ValueError – The array shapes of real and imag do not match.
The array shapes of component_real and component_imag do not match.
The number of harmonics in the components does not
match the ones in the phasor coordinates.
The system is underdetermined; the component matrix having more
columns than rows.
For now, calculation of fractions of components from different channels
or frequencies is not supported. Only one set of components can be
analyzed and is broadcast to all channels/frequencies.
The method builds a linear matrix equation,
\(A\mathbf{x} = \mathbf{b}\), where \(A\) consists of the
phasor coordinates of individual components, \(\mathbf{x}\) are
the unknown fractions, and \(\mathbf{b}\) represents the measured
phasor coordinates in the mixture. The least-squares solution of this
linear matrix equation yields the fractions.
Return fraction of first of two components from phasor coordinates.
Return the relative distance (normalized by the distance between the two
components) to the second component for each phasor coordinate projected
onto the line between two components.
Parameters:
real (array_like) – Real component of phasor coordinates.
imag (array_like) – Imaginary component of phasor coordinates.
component_real (array_like, shape (2,)) – Real coordinates of first and second components.
component_imag (array_like, shape (2,)) – Imaginary coordinates of first and second components.
Returns:
fraction – Fractions of first component.
Return type:
ndarray
Raises:
ValueError – If the real or imaginary coordinates of the known components are
not of size 2.
The fraction of the second component is 1.0-fraction.
For now, calculation of fraction of components from different
channels or frequencies is not supported. Only one pair of components can
be analyzed and will be broadcast to all channels/frequencies.
Return fractions of two or three components from phasor coordinates.
The graphical method is based on moving circular cursors along the line
between pairs of components and quantifying the phasors for each
fraction.
Parameters:
real (array_like) – Real component of phasor coordinates.
imag (array_like) – Imaginary component of phasor coordinates.
component_real (array_like, shape (2,) or (3,)) – Real coordinates for two or three components.
component_imag (array_like, shape (2,) or (3,)) – Imaginary coordinates for two or three components.
radius (float, optional, default: 0.05) – Radius of cursor.
fractions (array_like or int, optional) – Number of equidistant fractions, or 1D array of fraction values.
Fraction values must be in range [0.0, 1.0].
If an integer, numpy.linspace(0.0,1.0,fractions) fraction values
are used.
If None (default), the number of fractions is determined from the
longest distance between any pair of components and the radius of
the cursor (see Notes below).
Returns:
counts – Counts along each line segment connecting components.
Ordered 0-1 (2 components) or 0-1, 0-2, 1-2 (3 components).
Return type:
tuple of ndarray
Raises:
ValueError – The array shapes of real and imag, or component_real and
component_imag do not match.
The number of components is not 2 or 3.
Fraction values are out of range [0.0, 1.0].
For now, calculation of fraction of components from different
channels or frequencies is not supported. Only one set of components can
be analyzed and will be broadcast to all channels/frequencies.
If no fractions are provided, the number of fractions (\(N\)) used
is determined from the longest distance between any pair of components
(\(D\)) and the radius of the cursor (\(R\)):
\[N = \frac{2 \cdot D}{R} + 1\]
The fractions can be retrieved by:
fractions=numpy.linspace(0.0,1.0,len(counts[0]))
References
Examples
Count the number of phasors between two components: