ThresholdHandler

class lsst.ts.watcher.ThresholdHandler(warning_level, serious_level, critical_level, 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 or None

Warning level. None to not use this level.

serious_levelfloat

Serious level. None to not use this level.

critical_levelfloat

Critical level. None to not use this level.

hysteresisfloat

Hysteresis.

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_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_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