bag.data.core
This module defines core data post-processing classes.
Module Contents
Classes
A (usually transient) waveform. |
- class bag.data.core.Waveform(xvec, yvec, xtol, order=3, ext=3)[source]
Bases:
object
A (usually transient) waveform.
This class provides interpolation and other convenience functions.
- Parameters:
xvec (np.multiarray.ndarray) – the X vector.
yvec (np.multiarray.ndarray) – the Y vector.
xtol (float) – the X value tolerance.
order (int) – the interpolation order. 1 for nearest, 2 for linear, 3 for spline.
ext (int or str) – interpolation extension mode. See documentation for InterpolatedUnivariateSpline.
- property ext[source]
interpolation extension mode. See documentation for InterpolatedUnivariateSpline.
- get_xrange()[source]
Returns the X vector range.
- Returns:
xmin (float) – minimum X value.
xmax (float) – maximum X value.
- shift_by(xshift)[source]
Returns a shifted version of this waveform.
- Parameters:
xshift (float) – the amount to shift by.
- Returns:
wvfm – a reference to this instance, or a copy if copy is True.
- Return type:
- get_all_crossings(threshold, start=None, stop=None, edge='both')[source]
Returns all X values at which this waveform crosses the given threshold.
- Parameters:
- Returns:
xval_list – all X values at which crossing occurs.
- Return type:
- get_crossing(threshold, start=None, stop=None, n=1, edge='both')[source]
Returns the X value at which this waveform crosses the given threshold.
- Parameters:
threshold (float) – the threshold value.
start (float or None) – if given, search for the crossing starting at this X value.’
stop (float or None) – if given, search only for crossings before this X value.
n (int) – returns the nth crossing.
edge (str) – crossing type. Valid values are ‘rising’, ‘falling’, or ‘both’.
- Returns:
xval – the X value at which the crossing occurs. None if no crossings are detected.
- Return type:
float or None
- get_eye_specs(tbit, tsample, thres=0.0, nlev=2)[source]
Compute the eye diagram spec of this waveform.
This algorithm uses the following steps.
set t_off to 0
sample the waveform at tbit interval, starting at t0 + t_off.
sort the sampled values, get gap between adjacent values.
record G, the length of the gap covering thres.
increment t_off by tsample, go to step 2 and repeat until t_off >= tbit.
find t_off with maximum G. This is the eye center.
at the eye center, compute eye height and eye opening using kmeans clustering algorithm.
return result.
- Parameters:
- Returns:
result – A dictionary from specification to value.
- Return type: