Datum¶
-
class
lsst.validate.base.Datum(quantity=None, unit=None, label=None, description=None)[source]¶ Bases:
lsst.validate.base.QuantityAttributeMixin,lsst.validate.base.jsonmixin.JsonSerializationMixinA value annotated with units, a plot label and description.
Datum supports natively support Astropy
Quantityand units. In addition, a Datum can also wrap strings, booleans and integers. A Datums’s value can also beNone.Parameters: quantity :
astropy.units.Quantity,int,floator iterable.Value of the
Datum.unit :
strUnits of
quantityas astrifquantityis not supplied as anastropy.units.Quantity. See http://docs.astropy.org/en/stable/units/. Units are not used bystr,bool,intorNonetypes.label :
str, optionalLabel suitable for plot axes (without units).
description :
str, optionalExtended description of the
Datum.Attributes Summary
descriptionExtended description. jsonDatum as a dictcompatible with overallJobJSON schema.labelLabel for plotting (without units). latex_unitUnits as a LaTeX string, wrapped in $.quantityValue of the datum ( astropy.units.Quantity,str,bool,None).unitRead-only astropy.units.Unitof thequantity.unit_strRead-only astropy.units.Unit-compatiblestrindicating units ofquantity.Methods Summary
from_json(json_data)Construct a Datum from a JSON dataset. jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. write_json(filepath)Write JSON to a file. Attributes Documentation
-
description¶ Extended description.
-
label¶ Label for plotting (without units).
-
latex_unit¶ Units as a LaTeX string, wrapped in
$.
-
quantity¶ Value of the datum (
astropy.units.Quantity,str,bool,None).
-
unit¶ Read-only
astropy.units.Unitof thequantity.
-
unit_str¶ Read-only
astropy.units.Unit-compatiblestrindicating units ofquantity.
Methods Documentation
-
classmethod
from_json(json_data)[source]¶ Construct a Datum from a JSON dataset.
Parameters: json_data :
dictDatum JSON object.
Returns: datum :
DatumDatum from JSON.
-
jsonify_dict(d)¶ Recursively build JSON-renderable objects on all values in a dict.
Parameters: d :
dictDictionary ito 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, })
-