ThresholdHandler

class lsst.ts.watcher.ThresholdHandler(warning_level, serious_level, critical_level, warning_period, serious_period, critical_period, hysteresis, big_is_bad, value_name, units, value_format='0.2f', warning_msg='', serious_msg='', critical_msg='')

Bases: object

Compute severity for a rule that involves one float value with multiple threshold levels.

Parameters:
warning_levelfloat | None

Warning level. None to not use this level.

serious_levelfloat | None

Serious level. None to not use this level.

critical_levelfloat | None

Critical level. None to not use this level.

warning_periodfloat

Period after which a warning alarm is raised.

serious_periodfloat

Period after which a serious alarm is raised.

critical_periodfloat

Period after which a critical alarm is raised.

hysteresisfloat

The amount by which the measurement must decrease below (or increase above if big_is_bad false) a severity level, before alarm severity is decreased.

big_is_badbool

True if measured values larger than the specified levels are bad; examples include most humidity, temperature, and vacuum measurements. False if measured values smaller than the levels are bad; the classic example is dew point depression.

value_namestr

Name of the value, e.g. “humidity” or “dew point depression”.

unitsstr

Units of measurement.

value_formatstr, optional

Format for float value (threshold level or measured value) without a leading colon, e.g. “0.2f”

warning_msgstr, optional

The first part of the reason string for a warning alarm. This should say what the operators should do.

serious_msgstr, optional

The first part of the reason string for a serious alarm. This should say what the operators should do.

critical_msgstr, optional

The first part of the reason string for a critical alarm. This should say what the operators should do.

Raises:
ValueError

If:

  • All levels are None.

  • hysteresis is not positive.

  • The non-None levels are not strictly ordered, or are separated by less than hysteresis * 1.1.

  • hysteresis or any non-None level is not finite.

Methods Summary

get_current_tai()

Get the current TAI time [UNIX seconds].

get_severity_reason(value, current_severity, ...)

Compute alarm severity and reason string.

get_test_value_severities()

Get a list of (value, expected_severity), for testing.

Methods Documentation

get_current_tai() float

Get the current TAI time [UNIX seconds].

This method is designed to be overridden in unit tests.

Returns:
float

The current TAI time [UNIX seconds].

get_severity_reason(value, current_severity, source_descr)

Compute alarm severity and reason string.

Parameters:
valuefloat

Value to test, in the same units as the severity levels.

current_severityAlarmSeverity

Current alarm severity.

source_descrstr

The source of the measurement; typcally a sensor location, for example “strut 1”. If there is only one possible source then you may specify “” to not report it.

get_test_value_severities()

Get a list of (value, expected_severity), for testing.

You must apply the values in the specified order, in order to get the expected severities.

The order is as follows (only taking into account the thresholds that are actually being used):

for starting threshold from most to least serious:
    for each threshold from starting to least serious:
        if starting threshold:
            value just above starting threshold level
        else:
            value just high enough to retain previous severity
        value just low enough to drop to the next severity
        value just high enough to retain that severity
    value just low enough to drop to severity NONE