Datum¶
- class lsst.verify.Datum(quantity=None, unit=None, label=None, description=None)¶
- Bases: - QuantityAttributeMixin,- JsonSerializationMixin- A 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 be- None.- Parameters:
- quantityastropy.units.Quantity,int,floator iterable.
- Value of the - Datum.
- unitstr
- Units of - quantityas a- strif- quantityis not supplied as an- astropy.units.Quantity. See http://docs.astropy.org/en/stable/units/. Units are not used by- str,- bool,- intor- Nonetypes.
- labelstr, optional
- Label suitable for plot axes (without units). 
- descriptionstr, optional
- Extended description of the - Datum.
 
- quantity
 - Attributes Summary - Extended description. - Label for plotting (without units). - Units as a LaTeX string, wrapped in - $.- Value of the datum ( - astropy.units.Quantity,- str,- bool,- None).- Read-only - astropy.units.Unitof the- quantity.- Read-only - astropy.units.Unit-compatible- strindicating units of- quantity.- Methods Summary - deserialize([label, description, value, unit])- Deserialize fields from a Datum JSON object into a - Datuminstance.- 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 the- quantity.
 - unit_str¶
- Read-only - astropy.units.Unit-compatible- strindicating units of- quantity.
 - Methods Documentation - classmethod deserialize(label=None, description=None, value=None, unit=None)¶
- Deserialize fields from a Datum JSON object into a - Datuminstance.- Parameters:
- valuefloat,int,bool,str, orlist
- Values, which may be scalars or lists of scalars. 
- unitstrorNone
- An - astropy.units-compatible string with units of- value, or- Noneif the value does not have physical units.
- labelstr, optional
- Label suitable for plot axes (without units). 
- descriptionstr, optional
- Extended description of the - Datum.
 
- value
- Returns:
- datumDatum
- Datum instantiated from provided JSON fields. 
 
- datum
 - Examples - With this class method, a - Datummay be round-tripped from its JSON serialized form.- >>> datum = Datum(50. * u.mmag, label='sigma', ... description="Photometric uncertainty.") >>> print(datum) sigma = 50.0 mmag Photometric uncertainty. >>> json_data = datum.json >>> new_datum = datum.deserialize(**json_data) >>> print(new_datum) sigma = 50.0 mmag Photometric uncertainty. 
 - static jsonify_dict(d)¶
- Recursively build JSON-renderable objects on all values in a dict. - Parameters:
- ddict
- Dictionary to convert into a JSON-serializable object. Values are recursively JSON-ified. 
 
- d
- Returns:
- json_dictdict
- Dictionary that can be serialized to JSON. 
 
- json_dict
 - 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, })