lightlab.util.data.two_dim module¶
- Two dimensional measured objects where the second abscissa variable is either
- discrete (
FunctionBundle), or - continuous (
MeasuredSurface)
- discrete (
Summary¶
Classes:
FunctionBundle |
A bundle of MeasuredFunction’s: “z” vs. |
||
FunctionalBasis |
A FunctionBundle that supports additional linear algebra methods | ||
MeasuredErrorField |
A field that hold two abscissa arrays and two ordinate matrices | ||
MeasuredSurface |
Basically a two dimensional measured function: “z” vs. | ||
Spectrogram |
|
Reference¶
-
class
FunctionBundle(measFunList=None)[source]¶ Bases:
lightlab.laboratory.HashableA bundle of
MeasuredFunction’s: “z” vs. “x”, “i”The key is that they have the same abscissa base. This class will take care of resampling in a common abscissa base.
- The bundle can be:
- iterated to get the individual :class`~lightlab.util.data.one_dim.MeasuredFunction`’s
- operated on with other
FunctionBundles - plotted with :meth`simplePlot` and
multiAxisPlot()
Feeds through callable signal processing methods to its members (type MeasuredFunction), If the method is not found in the FunctionBundle, and it is in it’s member, it will be mapped to every function in the bundle, returning a new bundle.
Distinct from a
MeasuredSurfacebecause the additional axis does not represent a continuous thing. It is discrete and sometimes unordered.Distinct from a
FunctionalBasisbecause it does not support most linear algebra-like stuff (e.g. decomposision, matrix multiplication, etc.). This is not a strict rule.Can be initialized fully, or initialized with None to be built interactively.
Parameters: measFunList (list[MeasuredFunction] or None) – list of MeasuredFunctions that must have the same abscissa. -
max()[source]¶ Returns a single MeasuredFunction(subclass) that is the maximum of all in this bundle
-
min()[source]¶ Returns a single MeasuredFunction(subclass) that is the minimum of all in this bundle
-
multiAxisPlot(*args, axList=None, titleRoot=None, **kwargs)[source]¶ titleRoot must take one argument in its format method, which is given the index :returns: The axes that were plotted upon :rtype: (list(axis))
-
histogram()[source]¶ Gives a MeasuredFunction of counts vs. ordinate values (typically voltage) Does not maintain any abscissa information
At this point, does not allow caller to set the arguments passed to np.histogram
This is mainly just for plotting
-
weightedAddition(weiVec)[source]¶ Calculates the weighted addition of the basis signals
Parameters: weiVec (array) – weights to be applied to the basis functions Returns: weighted addition of basis signals Return type: (MeasuredFunction)
-
moment(order=2, allDims=True, relativeGauss=False)[source]¶ The order’th moment of all the points in the bundle.
Parameters: - order (integer) – the polynomial moment of inertia. Don’t trust the normalization of > 2’th order. order = 1: mean order = 2: variance order = 3: skew order = 4: kurtosis
- allDims (bool) – if true, collapses all signals, returning a scalar
Returns: the specified moment(s)
Return type: (ndarray or float)
-
componentAnalysis(*args, pcaIca=True, lNorm=2, expectedComponents=None, **kwargs)[source]¶ Gives the waveform representing the principal component of the order
Parameters: - pcaIca (bool) – if True, does PCA; if False, does ICA
- lNorm (int) – how to normalize weight vectors. L1 norm uses the maximum abs weight, while L2 norm (default) is vector unit
- expectedComponents (FunctionBundle or subclass) – Used for flipping signs
- kwargs (args,) – Feed through to sklearn.decomposition.[PCA(), FastICA()]
Returns: principal component waveforms
Return type: (FunctionBundle or subclass)
-
class
FunctionalBasis(measFunList=None)[source]¶ Bases:
lightlab.util.data.two_dim.FunctionBundleA FunctionBundle that supports additional linear algebra methods
Created for weighted addition, decomposition, and component analysis
Can be initialized fully, or initialized with None to be built interactively.
Parameters: measFunList (list[MeasuredFunction] or None) – list of MeasuredFunctions that must have the same abscissa. -
classmethod
independentDefault(nDims)[source]¶ Gives a basis of non-overlapping pulses. Waveforms only
-
project(trial)[source]¶ Projects onto normalized basis If the basis is orthogonal, this is equivalent to weight decomposition
-
decompose(trial, moment=1)[source]¶ Uses the Moore-Penrose pseudoinverse to get weight decomposition without orthogonality
Parameters: - trial (MeasuredFunction) – signal to be decomposed
- moment (float) – polynomial moment of the basis to use when decomposing
-
getMoment(weiVecs=None, order=2, relativeGauss=False)[source]¶ This is actually the projected moment. Named for compatibility with bss package
Make sure weiVecs is two dimensional
-
classmethod
-
class
MeasuredSurface(absc, ordi)[source]¶ Bases:
objectBasically a two dimensional measured function: “z” vs. “x”, “y”
Useful trick when gathering data: build incrementally using
FunctionBundle.addDim(), then convert that to this class usingMeasuredSurface.fromFunctionBundle().Parameters: - absc (ndarray) – same meaning as measured function
- ordi (ndarray) – two-dimensional array or matrix
-
classmethod
fromFunctionBundle(otherBund, addedAbsc=None)[source]¶ gives back a MeasuredSurface from a function Bundle
Parameters: - otherBund (FunctionBundle) – The source. The ordering of functions matters
- addedAbsc (np.ndarray) – the second dimension abscissa array (default, integers)
Returns: (
MeasuredSurface) new object
-
class
Spectrogram(absc, ordi)[source]¶ Bases:
lightlab.util.data.two_dim.MeasuredSurfaceParameters: - absc (ndarray) – same meaning as measured function
- ordi (ndarray) – two-dimensional array or matrix