AirFlowAccumulator

class lsst.ts.ess.csc.AirFlowAccumulator(log: Logger, num_samples: int)

Bases: object

Accumulate air flow data from a 2-d anemometer.

This supports writing the airFlow telemetry topic, whose fields are statistics measured on a set of data.

Parameters:
loglogging.Logger

Logger.

num_samplesint

The number of samples to read before producing aggregate data.

Raises:
ValueError

In case the value of num_samples is smaller than 2.

Notes

To Use

For each data sample read, call add_sample. Then call get_topic_kwargs`. If it returns a non-empty dict, write the airFlow topic using the returned dict as keyword arguments.

get_topic_kwargs also clears the accumulated data, so you can repeat this indefinitely. You need not call clear yourself.

Bad Data

Samples with isok=False are ignored, other than to increment the num_bad_samples counter. In the unlikely event that we accumulate num_samples of bad data before that many good samples, do_report() will be true, but get_topic_kwargs() will return nan for all statistical values. The point is to publish something, since this is telemetry and it should be output at semi-regular intervals. Note that the accumulated good data will be lost.

Attributes:
num_samplesint

The number of samples to read before producing aggregate data.

timestamplist of float

List of timestamps (TAI unix seconds).

speedlist of float

List of wind speed (m/s).

directionlist of float

List of wind direction (deg).

num_bad_samplesint

Number of invalid samples.

Attributes Summary

do_report

Do we have enough data to report good or bad data?

Methods Summary

add_sample(timestamp, speed, direction, isok)

Add a sample.

clear()

Clear the accumulated data.

get_topic_kwargs()

Return data for the electricFieldStrength telemetry topic.

Attributes Documentation

do_report

Do we have enough data to report good or bad data?

Methods Documentation

add_sample(timestamp: float, speed: float, direction: float, isok: bool) None

Add a sample.

Parameters:
timestampfloat

Time at which data was taken (TAI unix seconds).

speedfloat

Wind speed (m/s).

directionfloat

Wind direction (deg).

isokbool

Is the data valid?

clear() None

Clear the accumulated data.

Note that get_topic_kwargs() automatically calls this, so you typically will not have to.

get_topic_kwargs() dict[str, float | list[float] | bool]

Return data for the electricFieldStrength telemetry topic.

Returns:
topic_kwargsdict [str, float]

Data for the airFlow telemetry topic as a keyword, arguments, or an empty dict if there are not enough samples yet. A dict with data will have these keys:

  • timestamp

  • direction

  • directionStdDev

  • speed

  • speedStdDev

  • maxSpeed