AirTurbulenceAccumulator

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

Bases: object

Accumulate air turbulence data from a 3-d anemometer.

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

Parameters:
loglogging.Logger

The logger for which to create a child logger.

num_samplesint

The number of samples to read before producing aggregate data.

Notes

To Use

For each data sample read, call add_sample. The call get_topic_kwargs`. If it returns a non-empty dict, write the airTurbulence 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[float]

List of timestamps (TAI unix seconds)

speedlist[float]

List of wind speed in x, y, z (m/s)

sonic_temperaturelist[float]

List of sonic temperature (deg C)

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, ...)

Add a sample.

clear()

Clear the accumulated data.

get_topic_kwargs()

Return data for the airTurbulence telemetry topic.

Attributes Documentation

do_report

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

Methods Documentation

add_sample(timestamp: float, speed: Sequence[float], sonic_temperature: float, isok: bool) None

Add a sample.

Parameters:
timestampfloat

Time at which data was taken (TAI unix seconds)

speedlist[float]

Wind speed in x, y, z (m/s)

sonic_temperaturefloat

Sonic temperature (deg C)

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 airTurbulence telemetry topic.

Returns:
topic_kwargsdict [str, float]

Data for the airTurbulence 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

  • speed

  • speedStdDev

  • speedMagnitude

  • speedMaxMagnitude

  • sonicTemperature

  • sonicTemperatureStdDev