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:
objectCompute severity for a rule that involves one float value with multiple threshold levels.
- Parameters:
warning_level (
float|None) – Warning level. None to not use this level.serious_level (
float|None) – Serious level. None to not use this level.critical_level (
float|None) – Critical level. None to not use this level.warning_period (
float) – Period after which a warning alarm is raised.serious_period (
float) – Period after which a serious alarm is raised.critical_period (
float) – Period after which a critical alarm is raised.hysteresis (
float) – The amount by which the measurement must decrease below (or increase above ifbig_is_badfalse) a severity level, before alarm severity is decreased.big_is_bad (
bool) – 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_name (
str) – Name of the value, e.g. “humidity” or “dew point depression”.units (
str) – Units of measurement.value_format (
str, optional) – Format for float value (threshold level or measured value) without a leading colon, e.g. “0.2f”warning_msg (
str, optional) – The first part of the reason string for a warning alarm. This should say what the operators should do.serious_msg (
str, optional) – The first part of the reason string for a serious alarm. This should say what the operators should do.critical_msg (
str, 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. *
hysteresisis not positive. * The non-None levels are not strictly ordered, or are separated by less thanhysteresis* 1.1. * hysteresis or any non-None level is not finite.
Methods Summary
Get the current TAI time [UNIX seconds].
get_severity_reason(value, current_severity, ...)Compute alarm severity and reason string.
Get a list of (value, expected_severity), for testing.
Methods Documentation
- get_current_tai()#
Get the current TAI time [UNIX seconds].
This method is designed to be overridden in unit tests.
- Returns:
The current TAI time [UNIX seconds].
- Return type:
- get_severity_reason(value, current_severity, source_descr)#
Compute alarm severity and reason string.
- Parameters:
value (
float) – Value to test, in the same units as the severity levels.current_severity (
AlarmSeverity) – Current alarm severity.source_descr (
str) – 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