Measurement¶
-
class
lsst.verify.Measurement(metric, quantity=None, blobs=None, extras=None, notes=None)[source]¶ Bases:
lsst.verify.jsonmixin.JsonSerializationMixinA measurement of a single
Metric.A measurement is associated with a single
Metricand consists of aastropy.units.Quantityvalue. In addition, a measurement can be augmented withBlobs (either shared, or directly associated with the measurement’sMeasurement.extras) and metadata (Measurement.notes).Parameters: metric :
str,lsst.verify.Name, orlsst.verify.Metricquantity :
astropy.units.Quantity, optionalThe measured value as an Astropy
Quantity. If aMetricinstance is provided, the units ofquantityare compared to theMetric‘s units for compatibility. Thequantitycan also be set, updated, or read with theMeasurement.quantityattribute.blobs :
listofBlobs, optionalList of
lsst.verify.Blobinstances that are associated with a measurement. Blobs are datasets that can be associated with many measurements and provide context to a measurement.extras :
dictoflsst.verify.Datuminstances, optionalDatuminstances can be attached to a measurement. Extras can be accessed from theMeasurement.extrasattribute.notes :
dict, optionalMeasurement annotations. These key-value pairs are automatically available from
Job.meta, though keys are prefixed with the metric’s name. This metadata can be queried by specifications, so that specifications can be written to test only certain types of measurements.Raises: TypeError
Raised if arguments are not valid types.
Attributes Summary
blobsdictoflsst.verify.Blobs associated with this measurement.datumRepresentation of this measurement as a Datum.descriptionDescription of the metric ( str, orNoneifMeasurement.metricis not set).extrasBlobassociated solely to this measurement.identifierUnique UUID4-based identifier for this measurement ( str, immutable).jsonA dictthat can be serialized as semantic SQUASH JSON.metricMetric associated with the measurement ( lsst.verify.MetricorNone, mutable).metric_nameName of the corresponding metric ( lsst.verify.Name, mutable).notesMeasurement annotations as key-value pairs ( dict).quantityastropy.units.Quantitycomponent of the measurement (mutable).Methods Summary
deserialize([metric, identifier, value, ...])Create a Measurement instance from a parsed YAML/JSON document. jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. link_blob(blob)Link a Blobto this measurement.write_json(filepath)Write JSON to a file. Attributes Documentation
-
blobs= None¶ dictoflsst.verify.Blobs associated with this measurement.See also
-
description¶ Description of the metric (
str, orNoneifMeasurement.metricis not set).
-
extras= None¶ Blobassociated solely to this measurement.Notes
extraswork just likeBlobs, but they’re automatically created with eachMeasurement. AddDatums toextrasif thoseDatums only make sense in the context of thatMeasurement. IfDatums are relevant to multiple measurements, add them to an externalBlobinstance and attach them to each measurements’sMeasurement.blobsattribute through theMeasurement.link_blobmethod.
-
json¶ A
dictthat can be serialized as semantic SQUASH JSON.Fields:
metric(str) Name of the metric the measurement measures.identifier(str) Unique identifier for this measurement.value(float) Value of the measurement.unit(str) Units of thevalue, as anastropy.units-compatible string.blob_refs(listofstr) List ofBlob.identifiers for Blobs associated with this measurement.
Note
Blobs are not serialized with a measurement, only their identifiers. Thelsst.verify.Jobclass handles serialization of blobs alongside measurements.Likewise,
Measurement.notesare not serialized with the measurement. They are included withlsst.verify.Job‘s serialization, alongside job-level metadata.
-
metric¶ Metric associated with the measurement (
lsst.verify.MetricorNone, mutable).
-
metric_name¶ Name of the corresponding metric (
lsst.verify.Name, mutable).
-
notes¶ Measurement annotations as key-value pairs (
dict).These key-value pairs are automatically available from
Job.meta, though keys are prefixed with theMetric‘s name. This metadata can be queried bySpecifications, so thatSpecifications can be written to test only certain types ofMeasurements.
-
quantity¶ astropy.units.Quantitycomponent of the measurement (mutable).
Methods Documentation
-
classmethod
deserialize(metric=None, identifier=None, value=None, unit=None, blob_refs=None, blobs=None, **kwargs)[source]¶ Create a Measurement instance from a parsed YAML/JSON document.
Parameters: metric :
strName of the metric the measurement measures.
identifier :
strUnique identifier for this measurement.
value :
floatValue of the measurement.
unit :
strUnits of the
value, as anastropy.units-compatible string.List of
Blob.identifiers for Blob associated with this measurement.blobs :
BlobSetReturns: measurement :
MeasurementMeasurement instance.
-
jsonify_dict(d)¶ Recursively build JSON-renderable objects on all values in a dict.
Parameters: d :
dictDictionary to convert into a JSON-serializable object. Values are recursively JSON-ified.
Returns: json_dict :
dictDictionary that can be serialized to JSON.
Examples
Subclasses can use this method to prepare output in their
json-method implementation. For example:def json(self): return JsonSerializationMixin.jsonify_dict({ 'value': self.value, })
-
link_blob(blob)[source]¶ Link a
Blobto this measurement.Blobs can be linked to a measurement so that they can be retrieved by analysis and visualization tools post-serialization. Blob data is not copied, and one blob can be linked to multiple measurements.
Parameters: blob :
lsst.verify.BlobA
Blobinstance.Notes
After linking, the
Blobinstance can be accessed by name (Blob.name) through theMeasurement.blobsdict.
-