DataCoordinate¶
- 
class lsst.daf.butler.DataCoordinate¶
- Bases: - lsst.daf.butler.NamedKeyMapping- An immutable data ID dictionary that guarantees that its key-value pairs identify at least all required dimensions in a - DimensionGraph.- DataCoordinateSetitself is an ABC, but provides- staticmethodfactory functions for private concrete implementations that should be sufficient for most purposes.- standardizeis the most flexible and safe of these; the others (- makeEmpty,- fromRequiredValues, and- fromFullValues) are more specialized and perform little or no checking of inputs.- Notes - Like any data ID class, - DataCoordinatebehaves like a dictionary, but with some subtleties:- Both Dimensioninstances andstrnames thereof may be used as keys in lookup operations, but iteration (andkeys) will yieldDimensioninstances. Thenamesproperty can be used to obtain the correspondingstrnames.
- Lookups for implied dimensions (those in self.graph.implied) are supported if and only ifhasFullreturnsTrue, and are never included in iteration orkeys. Thefullproperty may be used to obtain a mapping whose keys do include implied dimensions.
- Equality comparison with other mappings is supported, but it always
considers only required dimensions (as well as requiring both operands
to identify the same dimensions).  This is not quite consistent with the
way mappings usually work - normally differing keys imply unequal
mappings - but it makes sense in this context because data IDs with the
same values for required dimensions but different values for implied
dimensions represent a serious problem with the data that
DataCoordinatecannot generally recognize on its own, and a data ID that knows implied dimension values should still be able to compare as equal to one that does not. This is of course not the way comparisons between simpledictdata IDs work, and hence using aDataCoordinateinstance for at least one operand in any data ID comparison is strongly recommended.
 - Attributes Summary - full- A mapping that includes key-value pairs for all dimensions in - self.graph, including implied (- NamedKeyMapping).- graph- The dimensions identified by this data ID ( - DimensionGraph).- names- The names of the required dimensions identified by this data ID, in the same order as - keys(- collections.abc.Set[- str]).- records- A mapping that contains - DimensionRecordobjects for all elements identified by this data ID (- NamedKeyMapping).- region- The spatial region associated with this data ID ( - lsst.sphgeom.Regionor- None).- timespan- The temporal interval associated with this data ID ( - Timespanor- None).- universe- The universe that defines all known dimensions compatible with this coordinate ( - DimensionUniverse).- Methods Summary - byName()- Return a - Mappingwith names as keys and the same values as- self.- expanded(records, …)- Return a - DataCoordinatethat holds the given records and guarantees that- hasRecordsreturns- True.- fromFullValues(graph, values, int, None], …])- Construct a - DataCoordinatefrom a tuple of dimension values that identify all dimensions.- fromRequiredValues(graph, values, int, …)- Construct a - DataCoordinatefrom a tuple of dimension values that identify only required dimensions.- get(k[,d])- hasFull()- Whether this data ID contains values for implied as well as required dimensions. - hasRecords()- Whether this data ID contains records for all of the dimension elements it identifies. - items()- keys()- makeEmpty(universe)- Return an empty - DataCoordinatethat identifies the null set of dimensions.- pack(name, *, returnMaxBits)- Pack this data ID into an integer. - standardize(mapping, DataIdValue]] = None, …)- Adapt an arbitrary mapping and/or additional arguments into a true - DataCoordinate, or augment an existing one.- subset(graph)- Return a - DataCoordinatewhose graph is a subset of- self.graph.- values()- Attributes Documentation - 
full¶
- A mapping that includes key-value pairs for all dimensions in - self.graph, including implied (- NamedKeyMapping).- Accessing this attribute if - hasFullreturns- Falseis a logic error that may raise an exception of unspecified type either immediately or when implied keys are accessed via the returned mapping, depending on the implementation and whether assertions are enabled.
 - 
graph¶
- The dimensions identified by this data ID ( - DimensionGraph).- Note that values are only required to be present for dimensions in - self.graph.required; all others may be retrieved (from a- Registry) given these.
 - 
names¶
- The names of the required dimensions identified by this data ID, in the same order as - keys(- collections.abc.Set[- str]).
 - 
records¶
- A mapping that contains - DimensionRecordobjects for all elements identified by this data ID (- NamedKeyMapping).- The values of this mapping may be - Noneif and only if there is no record for that element with these dimensions in the database (which means some foreign key field must have a NULL value).- Accessing this attribute if - hasRecordsreturns- Falseis a logic error that may raise an exception of unspecified type either immediately or when the returned mapping is used, depending on the implementation and whether assertions are enabled.
 - 
region¶
- The spatial region associated with this data ID ( - lsst.sphgeom.Regionor- None).- This is - Noneif and only if- self.graph.spatialis empty.- Accessing this attribute if - hasRecordsreturns- Falseis a logic error that may or may not raise an exception, depending on the implementation and whether assertions are enabled.
 - 
timespan¶
- The temporal interval associated with this data ID ( - Timespanor- None).- This is - Noneif and only if- self.graph.timespanis empty.- Accessing this attribute if - hasRecordsreturns- Falseis a logic error that may or may not raise an exception, depending on the implementation and whether assertions are enabled.
 - 
universe¶
- The universe that defines all known dimensions compatible with this coordinate ( - DimensionUniverse).
 - Methods Documentation - 
byName() → Dict[str, V_co]¶
- Return a - Mappingwith names as keys and the same values as- self.- Returns: 
 - 
expanded(records: Union[lsst.daf.butler.core.named.NamedKeyMapping[lsst.daf.butler.core.dimensions._elements.DimensionElement, typing.Union[lsst.daf.butler.core.dimensions._records.DimensionRecord, NoneType]][lsst.daf.butler.core.dimensions._elements.DimensionElement, Optional[lsst.daf.butler.core.dimensions._records.DimensionRecord]], Mapping[str, Optional[lsst.daf.butler.core.dimensions._records.DimensionRecord]]]) → lsst.daf.butler.core.dimensions._coordinate.DataCoordinate¶
- Return a - DataCoordinatethat holds the given records and guarantees that- hasRecordsreturns- True.- This is a low-level interface with at most assertion-level checking of inputs. Most callers should use - Registry.expandDataIdinstead.- Parameters: - records : Mapping[str,DimensionRecordorNone]
- A - NamedKeyMappingwith- DimensionElementkeys or a regular- Mappingwith- str(- DimensionElementname) keys and- DimensionRecordvalues. Keys must cover all elements in- self.graph.elements. Values may be- None, but only to reflect actual NULL values in the database, not just records that have not been fetched.
 
- records : 
 - 
static fromFullValues(graph: lsst.daf.butler.core.dimensions._graph.DimensionGraph, values: Tuple[Union[str, int, None], ...]) → lsst.daf.butler.core.dimensions._coordinate.DataCoordinate¶
- Construct a - DataCoordinatefrom a tuple of dimension values that identify all dimensions.- This is a low-level interface with at most assertion-level checking of inputs. Most callers should use - standardizeinstead.- Parameters: - graph : DimensionGraph
- Dimensions this data ID will identify. 
- values : tuple[intorstr]
- Tuple of primary key values corresponding to - itertools.chain(graph.required, graph.implied), in that order. Note that this is _not_ the same order as- graph.dimensions, though these contain the same elements.
 - Returns: - dataId : DataCoordinate
- A data ID object that identifies the given dimensions. - dataId.hasFull()will return- Trueif and only if- graph.impliedis empty, and- dataId.hasRecords()will never return- True.
 
- graph : 
 - 
static fromRequiredValues(graph: lsst.daf.butler.core.dimensions._graph.DimensionGraph, values: Tuple[Union[str, int, None], ...]) → lsst.daf.butler.core.dimensions._coordinate.DataCoordinate¶
- Construct a - DataCoordinatefrom a tuple of dimension values that identify only required dimensions.- This is a low-level interface with at most assertion-level checking of inputs. Most callers should use - standardizeinstead.- Parameters: - graph : DimensionGraph
- Dimensions this data ID will identify. 
- values : tuple[intorstr]
- Tuple of primary key values corresponding to - graph.required, in that order.
 - Returns: - dataId : DataCoordinate
- A data ID object that identifies the given dimensions. - dataId.hasFull()will return- Trueif and only if- graph.impliedis empty, and- dataId.hasRecords()will never return- True.
 
- graph : 
 - 
get(k[, d]) → D[k] if k in D, else d. d defaults to None.¶
 - 
hasFull() → bool¶
- Whether this data ID contains values for implied as well as required dimensions. - Returns: - state : bool
- If - True,- __getitem__,- get, and- __contains__(but not- keys!) will act as though the mapping includes key-value pairs for implied dimensions, and the- fullproperty may be used. If- False, these operations only include key-value pairs for required dimensions, and accessing- fullis an error. Always- Trueif there are no implied dimensions.
 
- state : 
 - 
hasRecords() → bool¶
- Whether this data ID contains records for all of the dimension elements it identifies. - Returns: 
 - 
items() → a set-like object providing a view on D's items¶
 - 
keys() → a set-like object providing a view on D's keys¶
 - 
static makeEmpty(universe: DimensionUniverse) → DataCoordinate¶
- Return an empty - DataCoordinatethat identifies the null set of dimensions.- Parameters: - universe : DimensionUniverse
- Universe to which this null dimension set belongs. 
 - Returns: - dataId : DataCoordinate
- A data ID object that identifies no dimensions. - hasFulland- hasRecordsare guaranteed to return- True, because both- fulland- recordsare just empty mappings.
 
- universe : 
 - 
pack(name: str, *, returnMaxBits: bool = False) → Union[Tuple[int, int], int]¶
- Pack this data ID into an integer. - Parameters: - name : str
- Name of the - DimensionPackeralgorithm (as defined in the dimension configuration).
- returnMaxBits : bool, optional
- If - True(- Falseis default), return the maximum number of nonzero bits in the returned integer across all data IDs.
 - Returns: - Notes - Accessing this attribute if - hasRecordsreturns- Falseis a logic error that may or may not raise an exception, depending on the implementation and whether assertions are enabled.
- name : 
 - 
static standardize(mapping: Optional[NameLookupMapping[Dimension, DataIdValue]] = None, *, graph: Optional[DimensionGraph] = None, universe: Optional[DimensionUniverse] = None, **kwargs) → DataCoordinate¶
- Adapt an arbitrary mapping and/or additional arguments into a true - DataCoordinate, or augment an existing one.- Parameters: - mapping : Mapping, optional
- An informal data ID that maps dimensions or dimension names to their primary key values (may also be a true - DataCoordinate).
- graph : DimensionGraph
- The dimensions to be identified by the new - DataCoordinate. If not provided, will be inferred from the keys of- mapping, and- universemust be provided unless- mappingis already a- DataCoordinate.
- universe : DimensionUniverse
- All known dimensions and their relationships; used to expand and validate dependencies when - graphis not provided.
- **kwargs
- Additional keyword arguments are treated like additional key-value pairs in - mapping.
 - Returns: - coordinate : DataCoordinate
- A validated - DataCoordinateinstance.
 - Raises: - TypeError
- Raised if the set of optional arguments provided is not supported. 
- KeyError
- Raised if a key-value pair for a required dimension is missing. 
 
- mapping : 
 - 
subset(graph: lsst.daf.butler.core.dimensions._graph.DimensionGraph) → lsst.daf.butler.core.dimensions._coordinate.DataCoordinate¶
- Return a - DataCoordinatewhose graph is a subset of- self.graph.- Parameters: - graph : DimensionGraph
- The dimensions identified by the returned - DataCoordinate.
 - Returns: - coordinate : DataCoordinate
- A - DataCoordinateinstance that identifies only the given dimensions. May be- selfif- graph == self.graph.
 - Raises: - KeyError
- Raised if the primary key value for one or more required dimensions is unknown. This may happen if - graph.issubset(self.graph)is- False, or even if- graph.issubset(self.graph)is- True, if- self.hasFull()is- Falseand- graph.required.issubset(self.graph.required)is- False. As an example of the latter case, consider trying to go from a data ID with dimensions {instrument, physical_filter, band} to just {instrument, band}; band is implied by physical_filter and hence would have no value in the original data ID if- self.hasFull()is- False.
 - Notes - If - hasFulland- hasRecordsreturn- Trueon- self, they will return- True(respectively) on the returned- DataCoordinateas well. The converse does not hold.
- graph : 
 - 
values() → an object providing a view on D's values¶
 
- Both