vishack.HealthCheck

class vishack.HealthCheck(config)

Bases: object

Config driven health check class.

Parameters

config (string) – Path to the config file.

alert

Some alarming results from the report.

Type

dict

checklist

A dictionary of tests checklist

Type

dict

config

The config parser

Type

configparser.ConfigParser

config_path

The path to the config file

Type

string

paths

A list of paths to the diaggui XML files to be checked.

Type

list of strings

report_header

The report message of the health check

Type

string

report

The report of the health check

Type

dict

__init__(config)

Initiate HealthCheck class with a config file.

Parameters

config (string) – Path to the config file.

Methods

__init__(config)

Initiate HealthCheck class with a config file.

alert_to_string()

Convert alert dictionary to human readable string

check([new_measurement, typelist])

Perform diagnosis checks (health checks).

data_evaluate(data, listof_references, method)

Calculate mean and standard deviation of the evaluations

dict_to_string(dictionary)

Turns a report type dictionary to human readable string (rst)

evaluate_(data, reference, method[, df])

Evaluate a statistical quantity between two datasets.

get_alerts([threshold])

Store alerting results from report

print_report(path[, overwrite])

Write health check report to file with human readable format.

reference_evaluate(listof_references, method)

Cross evaluations between references

report_to_string()

Convert health check report dictionary to human readable string

alert_to_string()

Convert alert dictionary to human readable string

Returns

alert_string – The human readable alert string

Return type

string

check(new_measurement=False, typelist=['Transfer function', 'Power spectral density', 'Coherence'])

Perform diagnosis checks (health checks).

Parameters
  • new_measurement (boolean, optional.) – Trigger new measurement using the diaggui XML file. Default False.

  • typelist (list of string, optional.) – The type of checks to be performed. Defaults to check all transfer functions, power spectral density, and coherence in the diaggui XML file.

Returns

report – The health check report.

Return type

dict

Note

Specifying the type of checks here will not override the specification in the configuration file. If you wish to perform a particular type of tests, you must specify in the configuration file as well as specifying here.

data_evaluate(data, listof_references, method, df=1.0)

Calculate mean and standard deviation of the evaluations

Parameters
  • data (array) – The data to be evaluated

  • listof_references (list of arrays) – A list of references data to compare the data with.

  • method (string) – The type of quantity to be evaluated. Options are ‘RMS’, ‘WRMS’, ‘MSE’, ‘WMSE’, ‘MAE’, ‘WMAE’.

  • df (float, optional) – The frequency spacing between data points. Default to be 1. Only used when calculating RMS and WRMS.

Returns

  • mean (float) – The mean of all evaluations

  • std (float) – The standard deviation of all evaluations

dict_to_string(dictionary)

Turns a report type dictionary to human readable string (rst)

Parameters

dictionary (dict) – The health check report or the alert

Returns

rst_string – The string in reStructuredText format.

Return type

string

evaluate_(data, reference, method, df=1.0)

Evaluate a statistical quantity between two datasets.

Parameters
  • data (array) – The data to be evaluated

  • reference (array) – The reference data to be referenced

  • method (string) – The type of quantity to be evaluated. Options are ‘RMS’, ‘WRMS’, ‘MSE’, ‘WMSE’, ‘MAE’, ‘WMAE’.

  • df (float, optional) – The frequency spacing between data points. Default to be 1. Only used when calculating RMS and WRMS.

get_alerts(threshold=3)

Store alerting results from report

Parameters

threshold (float, optional.) – Alert results when the mean of the result is higher than this threshold, which has a unit of sigma. Defaults to 3. (3 sigma encloses 99.7% of the cases)

Returns

alert – Some alerting results from the health check report.

Return type

dict

print_report(path, overwrite=False)

Write health check report to file with human readable format.

Parameters
  • path (string) – path to the report

  • overwrite (boolean, optional) – Overwrite existing file. If false, path will be renamed before writing the report.

Returns

full_string – The full string of the report.

Return type

string

reference_evaluate(listof_references, method, df=1.0)

Cross evaluations between references

Parameters
  • listof_references (list of arrays) – A list of references data.

  • method (string) – The type of quantity to be evaluated. Options are ‘RMS’, ‘WRMS’, ‘MSE’, ‘WMSE’, ‘MAE’, ‘WMAE’.

  • df (float, optional) – The frequency spacing between data points. Default to be 1. Only used when calculating RMS and WRMS.

Returns

  • mean (float) – The mean of all evaluations

  • std (float) – The standard deviation of all evaluations

report_to_string()

Convert health check report dictionary to human readable string

Returns

report_string – The human readable report string

Return type

string