Metric¶
-
class
lsst.validate.drp.base.
Metric
(name, description, operatorStr, specs=None, dependencies=None, referenceDoc=None, referenceUrl=None, referencePage=None)[source]¶ Bases:
lsst.validate.drp.base.JsonSerializationMixin
Container for the definition of a Metric and specification levels.
Parameters: name : str
Name of the metric (e.g., PA1).
description : str
Short description about the metric.
operatorStr : str
A string, such as ‘<=’, that defines a success test for a measurement (on the left hand side) against the metric specification level (right hand side).
specs : list, optional
A list of Specification objects that define various specification levels for this metric.
referenceDoc : str, optional
The document handle that originally defined the metric (e.g. LPM-17)
referenceUrl : str, optional
The document’s URL.
referencePage : str, optional
Page where metric in defined in the reference document.
Attributes
name (str) Name of the metric description (str) Short description of the metric. referenceDoc (str) Name of the document that specifies this metric. referenceUrl (str) URL of the document that specifies this metric. referencePage (int) Page number in the document that specifies this metric. dependencies (dict) A dictionary of named Datum
values that must be known when making a measurement against metric. Dependencies can be accessed as attributes of the specification object.operator (function) Binary comparision operator that tests success of a measurement fulfilling a specification of this metric. Measured value is on left side of comparison and specification level is on right side. Attributes Summary
json
Render metric as a JSON object (dict). reference
A nicely formatted reference string. Methods Summary
checkSpec
(value, specName[, bandpass])Compare a measurement value against a named specification level ( SpecLevel
).convertOperatorString
(opStr)Convert a string representing a binary comparison operator to an operator function itself. fromYaml
(metricName[, yamlDoc, yamlPath, ...])Create a Metric instance from YAML document that defines metrics. getSpec
(name[, bandpass])Get a specification by name, and other qualitifications. getSpecNames
([bandpass])List names of all specification levels defined for this metric; optionally filtering by attributes such as bandpass. Attributes Documentation
-
json
¶ Render metric as a JSON object (dict).
-
reference
¶ A nicely formatted reference string.
Methods Documentation
-
checkSpec
(value, specName, bandpass=None)[source]¶ Compare a measurement value against a named specification level (
SpecLevel
).Returns: passed : bool
True if a value meets the specification, False otherwise.
-
static
convertOperatorString
(opStr)[source]¶ Convert a string representing a binary comparison operator to an operator function itself.
Operators are designed so that the measurement is on the left-hand side, and specification level on the right hand side.
The following operators are permitted:
opStr opFunc >= operator.ge > operator.gt, < operator.lt, <= operator.le == operator.eq != operator.ne Parameters: opStr : str
A string representing a binary operator.
Returns: opFunc : obj
An operator function from the
operator
standard library module.
-
classmethod
fromYaml
(metricName, yamlDoc=None, yamlPath=None, resolveDependencies=True)[source]¶ Create a Metric instance from YAML document that defines metrics.
Parameters: metricName : str
Name of the metric (e.g., PA1)
yamlDoc : dict, optional
The full metrics.yaml file loaded as a dict. Use this option to increase performance by eliminating redundant reads of a metrics.yaml file.
yamlPath : str, optional
The full path to a metrics.yaml file, in case a custom file is being used. The metrics.yaml file included in validate_drp is used by default.
resolveDependencies : bool, optional
If another metric is a dependency of this specification level’s definition
-
getSpec
(name, bandpass=None)[source]¶ Get a specification by name, and other qualitifications.
Parameters: name : str
Name of a specification level (design, minimum, stretch).
bandpass : str, optional
The name of the bandpass to qualify a bandpass-dependent specification level.
Returns: spec :
Specification
The
Specification
that matches the name and other qualifications.Raises: RuntimeError
If a specification cannot be found.
-
getSpecNames
(bandpass=None)[source]¶ List names of all specification levels defined for this metric; optionally filtering by attributes such as bandpass.
Parameters: bandpass : str, optional
Name of the applicable filter, if needed.
Returns: specNames : list
Specific names as a list of strings, e.g.
['design', 'minimum', 'stretch']
.
-