DimensionDataAttacher

class lsst.daf.butler.DimensionDataAttacher(*, records: Iterable[DimensionRecordSet] = (), deserializers: Iterable[DimensionRecordSetDeserializer] = (), cache: DimensionRecordCache | None = None, dimensions: DimensionGroup | None = None)

Bases: object

A helper class for attaching dimension records to data IDs.

Parameters:
recordsdict [str, DimensionRecordSet], optional

Regular dimension record sets, keyed by dimension element name. Not copied, and may be modified in-place.

deserializersdict [str, DimensionRecordSetDeserializer], optional

Partially-deserialized dimension records, keyed by dimension element name. Records will be fully deserialized on demand and then cached.

cacheDimensionRecordCache, optional

A cache of dimension records from a butler instance. If present, this is assumed to have records for elements that are not in records and deserializers.

dimensionsDimensionGroup, optional

Dimensions for which empty record sets should be added when no other source of records is given. This allows data IDs with these dimensions to have records attached by fetching them via the query argument to the attach method, or by computing regions on the skypix dimensions.

Methods Summary

attach(dimensions, data_ids[, query])

Attach dimension records to data IDs.

serialized(*[, ignore, ignore_cached, ...])

Serialize all dimension data in this attacher, with deduplication across fully- and partially-deserialized records.

Methods Documentation

attach(dimensions: DimensionGroup, data_ids: Iterable[DataCoordinate], query: Query | None = None) list[DataCoordinate]

Attach dimension records to data IDs.

Parameters:
dimensionsDimensionGroup

Dimensions of all given data IDs. All dimension elements must have been referenced in at least one of the constructor arguments.

data_idsIterable [ DataCoordinate ]

Data IDs to attach dimension records to (not in place; data coordinates are immutable).

queryqueries.Query, optional

A butler query that can be used to look up missing dimension records. Records fetched via query are cached in the records attribute.

Returns:
expandedlist [ DataCoordinate ]

Data IDs with dimension records attached, in the same order as the original iterable.

serialized(*, ignore: Iterable[str] = (), ignore_cached: bool = False, include_skypix: bool = False) SerializableDimensionData

Serialize all dimension data in this attacher, with deduplication across fully- and partially-deserialized records.

Parameters:
ignoreIterable [ str ], optional

Names of dimension elements that should not be serialized.

ignore_cachedbool, optional

If True, ignore all dimension elements for which DimensionElement.is_cached is True.

include_skypixbool, optional

If True, include skypix dimensions. These are ignored by default because they can always be recomputed from their IDs on-the-fly.

Returns:
serializedSerializedDimensionData

Serialized dimension records.