DimensionRecord¶
-
class
lsst.daf.butler.DimensionRecord(**kwargs)¶ Bases:
objectBase class for the Python representation of database records for a
DimensionElement.Parameters: - **kwargs
Field values for this record. Unrecognized keys are ignored. If this is the record for a
Dimension, its primary key value may be provided with the actual name of the field (e.g. “id” or “name”), the name of theDimension, or both. If this record class has a “timespan” attribute, “datetime_begin” and “datetime_end” keyword arguments may be provided instead of a single “timespan” keyword argument (but are ignored if a “timespan” argument is provided).
Notes
DimensionRecordsubclasses are created dynamically for eachDimensionElementin aDimensionUniverse, and are accessible via theDimensionElement.RecordClassattribute. TheDimensionRecordbase class itself is pure abstract, but does not use theabcmodule to indicate this because it does not have overridable methods.Record classes have attributes that correspond exactly to the
standardfields in the related database table, plus “region” and “timespan” attributes for spatial and/or temporal elements (respectively).Instances are usually obtained from a
Registry, but can be constructed directly from Python as well.DimensionRecordinstances are immutable.Attributes Summary
dataIdA dict-like identifier for this record’s primary keys ( DataCoordinate).Methods Summary
from_json(json_str, universe, registry)Convert a JSON string created by to_jsonand return something of the supplied class.from_simple(simple, Any], universe, registry)Construct a new object from the data returned from the to_simplemethod.toDict(splitTimespan)Return a vanilla dictrepresentation of this record.to_json(minimal)Convert this class to JSON form. to_simple(minimal)Convert this class to a simple python type suitable for serialization. Attributes Documentation
-
dataId¶ A dict-like identifier for this record’s primary keys (
DataCoordinate).
Methods Documentation
-
classmethod
from_json(json_str: str, universe: Optional[DimensionUniverse] = None, registry: Optional[Registry] = None) → SupportsSimple¶ Convert a JSON string created by
to_jsonand return something of the supplied class.Parameters: - json_str :
str Representation of the dimensions in JSON format as created by
to_json().- universe :
DimensionUniverse, optional The special graph of all known dimensions. Passed directly to
from_simple().- registry :
lsst.daf.butler.Registry, optional Registry to use to convert simple name of a DatasetType to a full
DatasetType. Passed directly tofrom_simple().
Returns: - constructed : Any
Newly-constructed object.
- json_str :
-
classmethod
from_simple(simple: Dict[str, Any], universe: Optional[DimensionUniverse] = None, registry: Optional[Registry] = None) → DimensionRecord¶ Construct a new object from the data returned from the
to_simplemethod.Parameters: - simple :
dictofstr Value return from
to_simple.- universe :
DimensionUniverse The special graph of all known dimensions of which this graph will be a subset. Can be
NoneifRegistryis provided.- registry :
lsst.daf.butler.Registry, optional Registry from which a universe can be extracted. Can be
Noneif universe is provided explicitly.
Returns: - graph :
DimensionGraph Newly-constructed object.
- simple :
-
toDict(splitTimespan: bool = False) → Dict[str, Any]¶ Return a vanilla
dictrepresentation of this record.Parameters:
-
to_json(minimal: bool = False) → str¶ Convert this class to JSON form.
The class type is not recorded in the JSON so the JSON decoder must know which class is represented.
Parameters: - minimal :
bool, optional Use minimal serialization. Requires Registry to convert back to a full type.
Returns: - json :
str The class in JSON string format.
- minimal :