DimensionPacker

class lsst.daf.butler.DimensionPacker(fixed: lsst.daf.butler.core.dimensions.coordinate.ExpandedDataCoordinate, dimensions: lsst.daf.butler.core.dimensions.graph.DimensionGraph)

Bases: object

An abstract base class for bidirectional mappings between a DataCoordinate and a packed integer ID.

Parameters
fixedExpandedDataCoordinate

Expanded data ID for the dimensions whose values must remain fixed (to these values) in all calls to pack, and are used in the results of calls to unpack.

dimensionsDimensionGraph

The dimensions of data IDs packed by this instance.

Attributes Summary

maxBits

The maximum number of nonzero bits in the packed ID returned by pack (int).

universe

A graph containing all known dimensions (DimensionUniverse).

Methods Summary

pack(dataId, *[, returnMaxBits])

Pack the given data ID into a single integer.

unpack(packedId)

Unpack an ID produced by pack into a full DataCoordinate.

Attributes Documentation

maxBits

The maximum number of nonzero bits in the packed ID returned by pack (int).

Must be implemented by all concrete derived classes. May return None to indicate that there is no maximum.

universe

A graph containing all known dimensions (DimensionUniverse).

Methods Documentation

pack(dataId: Union[lsst.daf.butler.core.dimensions.coordinate.DataCoordinate, Mapping[str, Any]], *, returnMaxBits: bool = False, **kwds) → int

Pack the given data ID into a single integer.

Parameters
dataIdDataId

Data ID to pack. Values for any keys also present in the “fixed” data ID passed at construction must be the same as the values passed at construction.

returnMaxBitsbool

If True, return a tuple of (packed, self.maxBits).

kwds

Additional keyword arguments forwarded to DataCoordinate.standardize.

Returns
packedint

Packed integer ID.

maxBitsint, optional

Maximum number of nonzero bits in packed. Not returned unless returnMaxBits is True.

Notes

Should not be overridden by derived class (_pack should be overridden instead).

abstract unpack(packedId: int) → lsst.daf.butler.core.dimensions.coordinate.DataCoordinate

Unpack an ID produced by pack into a full DataCoordinate.

Must be implemented by all concrete derived classes.

Parameters
packedIdint

The result of a call to pack on either self or an identically-constructed packer instance.

Returns
dataIdDataCoordinate

Dictionary-like ID that uniquely identifies all covered dimensions.