ElectricFieldStrengthAccumulator

class lsst.ts.ess.csc.ElectricFieldStrengthAccumulator(num_samples: int)

Bases: object

Accumulate electric field data from a detector.

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

Parameters:
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 electricFieldStrength 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).

strengthlist of float

List of electric field strength (kV / m).

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, strength, 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, strength: float, isok: bool) None

Add a sample.

Parameters:
timestampfloat

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

strengthfloat

Electric field strength (kV / m).

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 electricFieldStrength 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:

  • strength

  • strengthStdDev

  • strengthMax