saleae.measurements package

AnalogMeasurer is the base class of all custom measurer classes.

A measurer processes a span of contiguous analog samples and produces:

To implement a custom measurer:

The measure_range method is passed a range of analog samples to process and is where it does its work. The declared measures and annotations should be set within this method.

A basic measurer
from saleae.data import AnalogSpan
from saleae.measurements import AnalogMeasurer, Annotation, HorizontalRule, Measure

class MyMeasurer(AnalogMeasurer):
    min_measure = Measure('min', description='Minimum Value')
    max_measure = Measure('max', description='Maximum Value')
    mid_measure = Measure('mid', description='Mid-point')

    # This annotation will only be shown if the user has enabled `mid_measure`
    mid_annotation = Annotation(measures=[mid_measure])

    def measure_range(self, data: AnalogSpan):
        self.min_measure.value = data.min
        self.max_measure.value = data.max
        self.mid_measure.value = (data.max + data.min) / 2

        self.mid_annotation.value = HorizontalRule(value=self.mid_measure.value)
class saleae.measurements.analog_measurer.AnalogMeasurer

AnalogMeasurer base class.

measure_range must be implemented.

measure_range(data)

This method is called when running a measurement over a span of analog data.

This must be overridden by subclasses.

Parameters

data (AnalogSpan) – The span of data to run the measurement on.

class saleae.measurements.measure.Measure

Measure declaration that appears as a class property of an analog_measurer.AnalogMeasurer

__init__(label, *, type=<class 'float'>, description='', units='')
Parameters
  • label (str) – Short label used to identify this measure.

  • type (Type[TypeVar(MeasureType, float, int, SaleaeTimeDelta)]) – Type of value that this measure will be assigned.

  • description (str) – Description of the measure.

  • units (str) – Unit of this measure.

enabled()

True if this Measure has been enabled

Return type

bool

property error: Optional[saleae.measurements.measure.MeasureError]

Mark this measure as having an error.

This can be useful if the measure can not be calculated for the given data passed to measure_range().

Return type

Optional[MeasureError]

property value: Optional[saleae.measurements.measure.MeasureType]

The value of this measure.

Return type

Optional[TypeVar(MeasureType, float, int, SaleaeTimeDelta)]

class saleae.measurements.annotation.Annotation

Annotation declaration that appears as a class property of an analog_measurer.AnalogMeasurer

__init__(*, measures)
Parameters

measures (List[Measure]) – The list of measures that this annotation depends on. If those measures are all disabled, this anotation will not be shown.

class saleae.measurements.annotation.HorizontalRule

An annotation value represented as a horizontal rule.

This can be assigned to an annotation value while processing data in saleae.measurements.analog_measurer.AnalogMeasurer.measure_range().

__init__(*, value)
Parameters

value (Union[int, float]) – The vertical value of the rule.

class saleae.measurements.annotation.VerticalRule

An annotation value represented as a vertical rule, as an absolute time.

This can be assigned to an annotation value while processing data in saleae.measurements.analog_measurer.AnalogMeasurer.measure_range().

__init__(*, time)
Parameters

value – The time value of the rule.