TofuPilotTofuPilot

Aggregations

Compute statistics on numeric measurement arrays.

WiFi Enabled
True
x==True
Pass
Motor Torque
Pass
Output Voltage
5.02V
4.8<x<5.2
Pass

You can use aggregations to compute statistics on numeric arrays and validate the results.

measurements:
  - name: Temperature
    unit: °C
    aggregations: 
      - type: mean
        validators: 
          - operator: ">="
            expected_value: 20

You can set the measurement value as a numeric array:

def measure_temperature(run, measurements, sensor):
    temperatures = []

    for _ in range(60):
        temperatures.append(sensor.read_temperature())

    measurements.temperature = temperatures 

TofuPilot will compute the mean from the array and validate it against the specified criteria.

Definition

You can configure the aggregation type and validation.

PropertyTypeRequiredDescription
typestringYesAggregation function name
unitstringNoUnit for aggregated result
validatorsarrayNoValidators to apply to aggregated value

Functions

You can use the following aggregation functions:

FunctionDescriptionOutput
meanArithmetic meanSingle number
minMinimum valueSingle number
maxMaximum valueSingle number
sumSum of all valuesSingle number
stdPopulation standard deviationSingle number
countNumber of valuesSingle number

TofuPilot will compute the aggregation and set the outcome to Pass if validators are met, Fail if not.

Examples

Temperature Stability

You can validate temperature stability using mean and standard deviation aggregations:

phases:
  - name: Temperature Stability Test
    python:
      module: measure_temperature
    measurements:
      - name: Temperature
        unit: °C
        description: Operating temperature over 60 second test
        validators:
          - operator: "<="
            expected_value: 85
        aggregations:
          - type: mean
            validators:
              - operator: ">="
                expected_value: 20
              - operator: "<="
                expected_value: 80
          - type: std
            validators:
              - operator: "<="
                expected_value: 2.0

You can set the measurement value as a numeric array:

import time

def measure_temperature(run, sensor):
    temperatures = []

    for _ in range(60):
        temp = sensor.read_temperature()
        temperatures.append(temp)
        time.sleep(1)

    measurements.temperature = temperatures

TofuPilot will compute the mean and standard deviation, then validate both aggregations and set the measurement outcome.

Resistance Statistics

You can validate the average resistance across multiple test points:

phases:
  - name: Resistance Test
    python:
      module: measure_resistance
    measurements:
      - name: Resistance
        unit: Ω
        description: Resistance measurements across 10 test points
        validators:
          - operator: ">="
            expected_value: 95
          - operator: "<="
            expected_value: 105
        aggregations:
          - type: mean
            unit: Ω
            validators:
              - operator: ">="
                expected_value: 98
              - operator: "<="
                expected_value: 102
          - type: std
            validators:
              - operator: "<="
                expected_value: 1.5

You can set the measurement value as a numeric array:

def measure_resistance(run, dmm):
    resistances = []

    for point in range(10):
        r = dmm.measure_resistance(point)
        resistances.append(r)
        log.info(f"Point {point}: {r:.2f} Ω")

    measurements.resistance = resistances

TofuPilot will compute the mean and standard deviation, then validate the aggregations and set the measurement outcome.

Multiple Statistics

You can compute multiple aggregations on the same measurement:

phases:
  - name: Voltage Monitoring
    python:
      module: monitor_voltage
    measurements:
      - name: Voltage Samples
        unit: V
        aggregations:
          - type: mean
            validators:
              - operator: ">="
                expected_value: 4.9
              - operator: "<="
                expected_value: 5.1
          - type: min
            validators:
              - operator: ">="
                expected_value: 4.8
          - type: max
            validators:
              - operator: "<="
                expected_value: 5.2
          - type: std
            validators:
              - operator: "<="
                expected_value: 0.05

You can set the measurement value as a numeric array:

import time

def monitor_voltage(run, multimeter):
    samples = []

    for _ in range(100):
        v = multimeter.read_voltage()
        samples.append(v)
        time.sleep(0.1)

    measurements.voltage_samples = samples

TofuPilot will compute mean, min, max, and standard deviation, then validate each aggregation and set the measurement outcome.

How is this guide?