DataId¶
-
class
lsst.daf.butler.
DataId
(dataId=None, *, dimensions=None, dimension=None, universe=None, region=None, entries=None, **kwds)¶ Bases:
collections.abc.Mapping
A dict-like identifier for data usable across multiple collections and
DatasetType
s.Parameters: - dataId :
dict
orDataId
A
dict
-like object containingDimension
links. If this is a trueDataId
and the set of dimensions identified does not change, this object will be updated in-place and returned instead of a new instance.- dimensions : iterable of
Dimension
orstr
, optional The set of dimensions the
DataId
will identify, either asDimension
instances or string names thereof.- dimension :
Dimension
orstr
, optional The single dimension this
DataId
will identify (along with all of its required dependencies).- universe :
DimensionGraph
, optional A graph containing all known dimensions and joins. Must be provided if names are passed instead of
Dimension
instances indimensions
ordimension
, or when dimensions are inferred from the provided link keys.- region :
lsst.sphgeom.ConvexPolygon
, optional Spatial region on the sky associated with this combination of dimension entries.
- entries :
dict
, optional A nested dictionary of additional metadata column values associated with these dimensions, with
DimensionElement
instances orstr
names as the outer keys,str
column names as inner keys, and column values as inner dictionary values. If thedimension
argument is provided, may also be a non-nested dict containing metadata column values for just that dimension.- kwds :
dict
, optional Additional key-value pairs to update
dataId
with.
Raises: - ValueError
Raised if incomplete or incompatible arguments are provided.
Notes
The keys of a
DataId
correspond to the “link” columns of one or moreDimension
s, while values identify particular rows in the tables or views for thoseDimension
s. In addition to implementing the (immutable)collections.abc.Mapping
API,DataId
s have additional attributes to hold additional metadata, regions, and definitions for thoseDimension
s. They are also hashable, and hence can be used as keys in dictionaries.The
DataId
class represents a complete ID that has either been obtained from or validated with the set of knownDimension
s. Regulardict
s are typically used to represent conceptual data IDs that have not been validated. TheDataId
constructor serves as a sort of standardization routine; most APIs that conceptually operate onDataId
s should accept either trueDataId
s or regular dicts via a singledataId
argument, and pass this through theDataId
construction (usually with additional keyword arguments forwarded) to guarantee a trueDataId
. When convenient, thatDataId
should also be returned.The set of dimensions a
DataId
identifies can be provided to the constructor four ways:- Multiple dimensions may be passed via the
dimensions
argument. - A single dimension may be passed via the
dimension
argument. - If a true
DataId
is passed, its dimensions will be used if they are not overridden by one of the above. - If none of the above is provided, the dimensions are inferred from the
set of keys provided in
dataId
,extra
, andkwds
; any dimensions inuniverse
whose links are a subset of those keys is included.
Attributes Summary
entries
A nested dictionary of additional values associated with the identified dimension entries ( DimensionKeyDict
).Methods Summary
dimensions
([implied])Return dimensions this DataId
identifies.fields
(element[, region, metadata])Return the entries for a particular DimensionElement
.get
(k[,d])implied
()Return a new DataId
with all implied dimensions ofself
“upgraded” to required.items
()keys
()matches
(other)Compare two data IDs with possibly differing dimensions. updateHash
(message)Add this data ID to a secure hash. values
()Attributes Documentation
-
entries
¶ A nested dictionary of additional values associated with the identified dimension entries (
DimensionKeyDict
).The outer dictionary maps
DimensionElement
objects to dictionaries of field names and values.Entry values are not in general guaranteed to have been validated against any actual
Registry
schema.
Methods Documentation
-
dimensions
(implied=False)¶ Return dimensions this
DataId
identifies.Parameters: Returns: - graph :
DimensionGraph
- graph :
-
fields
(element, region=True, metadata=True)¶ Return the entries for a particular
DimensionElement
.Parameters: - element :
DimensionElement
orstr
The
Dimension
orDimensionJoin
for which fields should be returned.- region :
bool
Whether to include the region in the result. Ignored if this
DataId
has no region or the givenDimension
is not the region holder for it.- metadata :
bool
Whether to include metadata (non-link, non-region columns) in the result. Ignored if this
DataId
has no metadata for the givenDimension
.
Returns: - fields :
dict
A dictionary of column name-value pairs.
- element :
-
get
(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
-
items
() → a set-like object providing a view on D's items¶
-
keys
() → a set-like object providing a view on D's keys¶
-
matches
(other)¶ Compare two data IDs with possibly differing dimensions.
Parameters: Returns:
-
updateHash
(message)¶ Add this data ID to a secure hash.
Parameters:
-
values
() → an object providing a view on D's values¶
- dataId :