Waveforms¶
Classes¶
- class pycircuit.post.Waveform(x=array([], dtype=float64), y=array([], dtype=float64), xlabels=None, ylabel=None, xunits=None, yunit=None)¶
The Waveform class handles swept signals. The sweep can be multi dimensional.
The waveform class can handle both n-dimensional gridded data or data where the inner dimension has variable length.
Examples:
Initiating N-dimensional gridded data:
>>> w = Waveform([array([1,2]), array([3,4])], array([[3,4],[4,5]]))
Initiating N-dimensional data where the inner dimension has variable length
>>> x0 = array([array([1,1]), array([2])], dtype=object) >>> x1 = array([array([1,2]), array([1])], dtype=object) >>> w = Waveform([x0, x1], array([array([3,4]),array([4])], dtype = object))
- apply_along_axis(func1d, axis=-1, ylabel=None, yunit=None)¶
Apply a function to 1-D slices along the given axis.
Execute func1d(a, x) where func1d operates on 1-D arrays and a is a 1-D slice of w along axis
- argmax(axis=-1)¶
Returns the x-value where the y-value attains it maximum
Examples:
>>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.argmax() Waveform(array([1, 2]), array([4, 4]))
- argmin(axis=-1)¶
Returns the x-value where the y-value attains it minimum
Examples:
>>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.argmin() Waveform(array([1, 2]), array([2, 2]))
- property astable¶
Return a table in text format
>>> print Waveform(array([1,2,3]),array([3,4,5])).astable ==== === x0 y ==== === 1 3 2 4 3 5 ==== === >>> print Waveform(array([1,2]),array([3,4]), xlabels = ('X',), ylabel = 'Y').astable === === X Y === === 1 3 2 4 === === >>> t=Waveform(array([1,2]),array([3,4]), xlabels = ['X'], ylabel = 'Y').astable
- axesiterator(axes)¶
Iterate over all combinations of given axes and return sub waveforms
Values of xlabels, xunits and x-values are also returned along with each sub waveform
Each iteration yields a tuple (subwave, xlabels, xvalues, xunits)
- binaryop(op, a, ylabel=None, yunit=None, reverse=False, sameunit=False)¶
Apply binary operator between self and a
- clip(xfrom, xto=None, axis=-1)¶
Restrict the waveform to the range defined by xfrom and xto
>>> w1 = Waveform(array([1.,2.,3.]), array([8., 6., 1.]), ylabel='a') >>> w1.clip(2,3) Waveform(array([ 2., 3.]), array([ 6., 1.])) >>> w1.clip(1.5, 3) Waveform(array([ 1.5, 2. , 3. ]), array([ 7., 6., 1.]))
- deriv()¶
Calculate derivative of a waveform with respect to the inner x-axis
- get_x(axis=None)¶
Get X vector of the given sweep dimension
If no dimension is given, a list of the sweeps in all dimensions is returned
>>> w=Waveform([array([1,2]), array([1.5,2.5])], array([[3,4],[4,5]])) >>> w.get_x(0) array([1, 2]) >>> w.get_x(1) array([ 1.5, 2.5])
- get_y()¶
Get Y vector or n-dimensional array if sweep dimension > 1
- getaxis(axis)¶
Look up axis index by name of xlabel names
- getitem(key)¶
Get item of each Y-value
>>> wave = Waveform([[1,2]], array([{'a':1, 'b':2}, {'a':3, 'b':4}])) >>> wave.getitem('a') Waveform(array([1, 2]), array([1, 3]))
- map_x(func, axis=-1, xlabel='')¶
Apply function func on x-values of the given axis
- map_xaxes(func, axes, xlabel=None, xunit=None)¶
Apply function func on x-values from the given axes
When the number of axes is greater than 1 the output waveform has a lower sweep dimension. The axis of the lowest order is preserved.
- property ndim¶
Return the number of nested sweeps
- reducedimension(axes)¶
Reduce given axes by selecting the first element
>>> w = Waveform([[1,2],[3,4]], array([[1,2],[3,4]])) >>> w.reducedimension([0]) Waveform([array([3, 4])], array([1, 2]))
- set_x(value, axis=-1)¶
Set X vector
- set_y(value)¶
Set Y multi-dimensional array
- value(x, axis=-1)¶
Returns and interpolated at the given x-value
x can be a number or a waveform where the number of dimensions of x is is one less than the waveform it is operating on
Examples:
1-d waveform
>>> w1=Waveform(array([1,2,3]),array([3,5,6])) >>> w1.value(1.5) 4.0
2-d waveform >>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.value(2.5) Waveform(array([1, 2]), array([ 4., 5.]))
x is a waveform >>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.value(Waveform([[1, 2]], array([2.5, 3.5]))) Waveform(array([1, 2]), array([ 4. , 6.5]))
- property x¶
x values
- property xlabels¶
x-axis list of labels for each dimension
- xmax(axis=-1)¶
Returns the maximum x-value over one axis
Examples:
>>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.xmax() 4
- xmin(axis=-1)¶
Returns the minimum x-value over one axis
Examples:
>>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.xmin() 2
- property xunits¶
x-axis list of units for each dimension
- xval(axis=-1)¶
Return a waveform with the x-values from the given dimension
- property y¶
y values
- property ylabel¶
y-axis label
- ymax(axis=-1)¶
Returns the maximum y-value over one axis
Examples:
>>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.ymax() Waveform(array([1, 2]), array([6, 7]))
- ymin(axis=-1)¶
Returns the minimum y-value over one axis
Examples:
>>> w2=Waveform([[1,2],[2,3,4]], array([[3,5,6], [4,6,7]])) >>> w2.ymin() Waveform(array([1, 2]), array([3, 4]))
- property yunit¶
y-axis unit
Functions¶
- pycircuit.post.astable(*waveforms)¶
Return a table of one or more waveforms with the same sweeps in text format
Examples:
>>> w1 = Waveform([range(2)], array([3,4]), ylabel='V1') >>> w2 = Waveform([range(2)], array([4,6]), ylabel='V2') >>> print astable(w1,w2) ==== ==== ==== x0 V1 V2 ==== ==== ==== 0 3 4 1 4 6 ==== ==== ====
- pycircuit.post.compatible(*args)¶
Return True if the given waveforms have the same x-values
Examples:
>>> w1 = Waveform(array([1,2,3]),array([3,5,6])) >>> w2 = Waveform(array([1,2,3]),array([1,1.5,2])) >>> w3 = Waveform(array([1,2]),array([3,5,6])) >>> compatible(w1, w2) True >>> compatible(w1, w3) False
- pycircuit.post.compose(wlist, x=None, xlabel=None)¶
Compose list of waveforms into a new waveform where the waveform list becomes the outer sweep
Examples:
>>> wlist=[Waveform(array([1,2,3]),array([3,5,6])), Waveform(array([1,2,3]),array([1,1.5,2]))] >>> w = compose(wlist, x = array([1,2]), xlabel = 'index') >>> w Waveform([array([1, 2]), array([1, 2, 3])], array([[ 3. , 5. , 6. ], [ 1. , 1.5, 2. ]])) >>> w.xlabels ('index', 'x0')