DatasetRef¶
- 
class lsst.daf.butler.DatasetRef¶
- Bases: - object- Reference to a Dataset in a - Registry.- A - DatasetRefmay point to a Dataset that currently does not yet exist (e.g., because it is a predicted input for provenance).- Parameters: - datasetType : DatasetType
- The - DatasetTypefor this Dataset.
- dataId : DataCoordinate
- A mapping of dimensions that labels the Dataset within a Collection. 
- id : int, optional
- The unique integer identifier assigned when the dataset is created. 
- run : str, optional
- The name of the run this dataset was associated with when it was created. Must be provided if - idis.
- hash : bytes, optional
- A hash of the dataset type and data ID. Should only be provided if copying from another - DatasetRefwith the same dataset type and data ID.
- conform : bool, optional
- If - True(default), call- DataCoordinate.standardizeto ensure that the data ID’s dimensions are consistent with the dataset type’s.- DatasetRefinstances for which those dimensions are not equal should not be created in new code, but are still supported for backwards compatibility. New code should only pass- Falseif it can guarantee that the dimensions are already consistent.
- hasParentId : bool, optional
- If - Truethis- DatasetRefis a component that has the- idof the composite parent.
 - Raises: - ValueError
- Raised if - runis provided but- idis not, or if- idis provided but- runis not.
 - Attributes Summary - dataId- A mapping of - Dimensionprimary key values that labels the dataset within a Collection (- DataCoordinate).- datasetType- The definition of this dataset ( - DatasetType).- dimensions- The dimensions associated with the underlying - DatasetType- hasParentId- hash- Secure hash of the - DatasetTypename and data ID (- bytes).- id- Primary key of the dataset ( - intor- None).- run- The name of the run that produced the dataset. - Methods Summary - expanded(dataId)- Return a new - DatasetRefwith the given expanded data ID.- getCheckedId()- Return - self.id, or raise if it is- None.- groupByType(refs)- Group an iterable of - DatasetRefby- DatasetType.- isComponent()- Boolean indicating whether this - DatasetRefrefers to a component of a composite.- isComposite()- Boolean indicating whether this - DatasetRefis a composite type.- makeComponentRef(name)- Create a - DatasetRefthat corresponds to a component of this dataset.- resolved(id, run)- Return a new - DatasetRefwith the same data ID and dataset type and the given ID and run.- unresolved()- Return a new - DatasetRefwith the same data ID and dataset type, but no ID or run.- Attributes Documentation - 
dataId¶
- A mapping of - Dimensionprimary key values that labels the dataset within a Collection (- DataCoordinate).- Cannot be changed after a - DatasetRefis constructed.
 - 
datasetType¶
- The definition of this dataset ( - DatasetType).- Cannot be changed after a - DatasetRefis constructed.
 - 
dimensions¶
- The dimensions associated with the underlying - DatasetType
 - 
hasParentId¶
 - 
hash¶
- Secure hash of the - DatasetTypename and data ID (- bytes).
 - 
id¶
- Primary key of the dataset ( - intor- None).- Cannot be changed after a - DatasetRefis constructed; use- resolvedor- unresolvedto add or remove this information when creating a new- DatasetRef.
 - 
run¶
- The name of the run that produced the dataset. - Cannot be changed after a - DatasetRefis constructed; use- resolvedor- unresolvedto add or remove this information when creating a new- DatasetRef.
 - Methods Documentation - 
expanded(dataId: lsst.daf.butler.core.dimensions.coordinate.ExpandedDataCoordinate) → lsst.daf.butler.core.datasets.ref.DatasetRef¶
- Return a new - DatasetRefwith the given expanded data ID.- Parameters: - dataId : ExpandedDataCoordinate
- Data ID for the new - DatasetRef. Must compare equal to the original data ID.
 - Returns: - ref : DatasetRef
- A new - DatasetRefwith the given data ID.
 
- dataId : 
 - 
getCheckedId() → int¶
- Return - self.id, or raise if it is- None.- This trivial method exists to allow operations that would otherwise be natural list comprehensions to check that the ID is not - Noneas well.- Returns: - Raises: - AmbiguousDatasetError
- Raised if - ref.idis- None.
 
 - 
static groupByType(refs: Iterable[lsst.daf.butler.core.datasets.ref.DatasetRef]) → lsst.daf.butler.core.named.NamedKeyDict[lsst.daf.butler.core.datasets.type.DatasetType, typing.List[lsst.daf.butler.core.datasets.ref.DatasetRef]][lsst.daf.butler.core.datasets.type.DatasetType, List[lsst.daf.butler.core.datasets.ref.DatasetRef]]¶
- Group an iterable of - DatasetRefby- DatasetType.- Parameters: - refs : Iterable[DatasetRef]
- DatasetRefinstances to group.
 - Returns: - grouped : NamedKeyDict[DatasetType,list[DatasetRef] ]
- Grouped - DatasetRefinstances.
 
- refs : 
 - 
isComponent() → bool¶
- Boolean indicating whether this - DatasetRefrefers to a component of a composite.- Returns: - isComponent : bool
- Trueif this- DatasetRefis a component,- Falseotherwise.
 
- isComponent : 
 - 
isComposite() → bool¶
- Boolean indicating whether this - DatasetRefis a composite type.- Returns: - isComposite : bool
- Trueif this- DatasetRefis a composite type,- Falseotherwise.
 
- isComposite : 
 - 
makeComponentRef(name: str) → lsst.daf.butler.core.datasets.ref.DatasetRef¶
- Create a - DatasetRefthat corresponds to a component of this dataset.- Parameters: - name : str
- Name of the component. 
 - Returns: - ref : DatasetRef
- A - DatasetRefwith a dataset type that corresponds to the given component, with- hasParentId=True, and the same ID and run (which may be- None, if they are- Nonein- self).
 
- name : 
 - 
resolved(id: int, run: str) → lsst.daf.butler.core.datasets.ref.DatasetRef¶
- Return a new - DatasetRefwith the same data ID and dataset type and the given ID and run.- Parameters: - Returns: - ref : DatasetRef
- A new - DatasetRef.
 
- ref : 
 - 
unresolved() → lsst.daf.butler.core.datasets.ref.DatasetRef¶
- Return a new - DatasetRefwith the same data ID and dataset type, but no ID or run.- Returns: - ref : DatasetRef
- A new - DatasetRef.
 - Notes - This can be used to compare only the data ID and dataset type of a pair of - DatasetRefinstances, regardless of whether either is resolved:- if ref1.unresolved() == ref2.unresolved(): ... 
- ref : 
 
- datasetType :