bag.data.core

This module defines core data post-processing classes.

Module Contents

Classes

Waveform

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 xvec[source]

the X vector

property yvec[source]

the Y vector

property order[source]

the interpolation order. 1 for nearest, 2 for linear, 3 for spline.

property xtol[source]

the X value tolerance.

property ext[source]

interpolation extension mode. See documentation for InterpolatedUnivariateSpline.

__call__(*arg, **kwargs)[source]

Evaluate the waveform at the given points.

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:

bag.data.core.Waveform

get_all_crossings(threshold, start=None, stop=None, edge='both')[source]

Returns all X values at which this waveform crosses the given threshold.

Parameters:
  • threshold (float) – the threshold value.

  • start (float or None) – if given, search for crossings starting at this X value.

  • stop (float or None) – if given, search only for crossings before this X value.

  • edge (string) – crossing type. Valid values are ‘rising’, ‘falling’, or ‘both’.

Returns:

xval_list – all X values at which crossing occurs.

Return type:

list[float]

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

to_arrays(xmin=None, xmax=None)[source]

Returns the X and Y arrays representing this waveform.

Parameters:
  • xmin (float or None) – If given, will start from this value.

  • xmax (float or None) – If given, will end at this value.

Returns:

  • xvec (np.multiarray.ndarray) – the X array

  • yvec (np.multiarray.ndarray) – the Y array

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.

  1. set t_off to 0

  2. sample the waveform at tbit interval, starting at t0 + t_off.

  3. sort the sampled values, get gap between adjacent values.

  4. record G, the length of the gap covering thres.

  5. increment t_off by tsample, go to step 2 and repeat until t_off >= tbit.

  6. find t_off with maximum G. This is the eye center.

  7. at the eye center, compute eye height and eye opening using kmeans clustering algorithm.

  8. return result.

Parameters:
  • tbit (float) – eye period.

  • tsample (float) – the resolution to sample the eye. Used to find optimal time shift and maximum eye opening.

  • thres (float) – the eye vertical threshold.

  • nlev (int) – number of expected levels. 2 for NRZ, 4 for PAM4.

Returns:

result – A dictionary from specification to value.

Return type:

dict

_add_xy(other)[source]
__add__(other)[source]
__neg__()[source]
__mul__(scale)[source]
__rmul__(scale)[source]