Specification

class lsst.validate.base.Specification(name, quantity, unit=None, filter_names=None, dependencies=None)[source]

Bases: lsst.validate.base.QuantityAttributeMixin, lsst.validate.base.jsonmixin.JsonSerializationMixin

A specification level, or threshold, associated with a Metric.

Parameters:

name : str

Name of the specification level for a metric. LPM-17, for example, uses 'design', 'minimum' and 'stretch' terminology.

quantity : astropy.units.Quantity, float, or int

The specification threshold level.

unit : str, optional

astropy.units.Unit-compatible str describing the units of value (only necessary if quantity is a float). An empty string ('') describes a unitless quantity.

filter_names : list, optional

A list of optical filter names that this specification applies to. Set only if the specification level is dependent on the filter.

dependencies : dict, optional

A dictionary of named Datum values that must be known when making a measurement against a specification level. Dependencies can be accessed as attributes of the specification object. The names of class attributes match keys in dependencies.

Attributes Summary

datum Representation of this Specification as a Datum.
dependencies dict of named Datum values that must be known when making a
filter_names list of names of optical filters that this Specification level
json dict that can be serialized as semantic JSON, compatible with
latex_unit Units as a LaTeX string, wrapped in $.
name Name of the specification level for a metric.
quantity The specification threshold level (astropy.units.Quantity).
unit Read-only astropy.units.Unit of the quantity.
unit_str Read-only astropy.units.Unit-compatible str indicating units of quantity.

Methods Summary

from_json(json_data) Construct a Specification from a JSON document.
jsonify_dict(d) Recursively build JSON-renderable objects on all values in a dict.
write_json(filepath) Write JSON to a file.

Attributes Documentation

datum

Representation of this Specification as a Datum.

dependencies = None

dict of named Datum values that must be known when making a measurement against a specification level.

Dependencies can also be accessed as attributes of the Specification object. The names of class attributes match keys in dependencies.

filter_names = None

list of names of optical filters that this Specification level applies to.

Default is None if the Specification is filter-independent.

json

dict that can be serialized as semantic JSON, compatible with the SQUASH metric service.

latex_unit

Units as a LaTeX string, wrapped in $.

name = None

Name of the specification level for a metric.

LPM-17, for example, uses 'design', 'minimum' and 'stretch' terminology.

quantity = None

The specification threshold level (astropy.units.Quantity).

unit

Read-only astropy.units.Unit of the quantity.

If the quantity is a str or bool, the unit is None.

unit_str

Read-only astropy.units.Unit-compatible str indicating units of quantity.

Methods Documentation

classmethod from_json(json_data)[source]

Construct a Specification from a JSON document.

Parameters:

json_data : dict

Specification JSON object.

Returns:

specification : Specification

Specification from JSON.

jsonify_dict(d)

Recursively build JSON-renderable objects on all values in a dict.

Parameters:

d : dict

Dictionary ito convert into a JSON-serializable object. Values are recursively JSON-ified.

Returns:

json_dict : dict

Dictionary 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,
    })
write_json(filepath)

Write JSON to a file.

Parameters:

filepath : str

Destination file name for JSON output.