BlobBase¶
-
class
lsst.validate.base.BlobBase[source]¶ Bases:
lsst.validate.base.jsonmixin.JsonSerializationMixin,lsst.validate.base.datummixin.DatumAttributeMixinBase class for blobs: flexible containers of data that are serialized to JSON.
See also
The page Providing datasets to measurements through blobs describes how to create blob classes.
Attributes Summary
datumsdictofDatuminstances contained by the blob instance.identifierUnique UUID4-based identifier for this blob ( str).jsonJob data as a JSON-serializable dict.nameName of this blob (the BlobBasesubclass’s Python namespace).Methods Summary
from_json(json_data)Construct a Blob from a JSON dataset. jsonify_dict(d)Recursively build JSON-renderable objects on all values in a dict. register_datum(name[, quantity, label, ...])Register a new Datumto be contained by, and serialized via, this blob.write_json(filepath)Write JSON to a file. Attributes Documentation
-
datums= None¶ dictofDatuminstances contained by the blob instance.The values of blobs can also be accessed as attributes of the
BlobBasesubclass. Keys indatumsand attributes share the same names.
Methods Documentation
-
classmethod
from_json(json_data)[source]¶ Construct a Blob from a JSON dataset.
Parameters: json_data :
dictBlob JSON object.
Returns: blob :
BlobBase-typeBlob 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, })
-
register_datum(name, quantity=None, label=None, description=None, datum=None)[source]¶ Register a new
Datumto be contained by, and serialized via, this blob.The value of the
Datumcan either be set at registration time (with thequantityordatumarguments) or later by setting the instance attribute namedname.Values of
Datums can always be accessed or updated through instance attributes.The full
Datumobject can be accessed as items of thedatumsdictionary attached to this class. This method is useful for accessing or updating metadata about aDatum, such as:unit,label, ordescription.Parameters: name :
strvalue : obj
Value of the
Datum.label :
str, optionalLabel suitable for plot axes (without units). By default the
nameis used as thelabel. Setting this label argument overrides this default.description :
str, optionalExtended description.
datum :
Datum, optionalIf a
Datumis provided, its value, units and label will be used unless overriden by other arguments toregister_datum.
-