DataIdPacker¶
-
class
lsst.daf.butler.DataIdPacker¶ Bases:
objectAn abstract base class for a bidirectional mappings between a
DataIdand a packed integer orbytesblob.Derived class constructors must accept at least the positional argments required by the base class contructor, but may accept additional keyword subclass-specific arguments as well (see
configure).Parameters: - dimensions :
DataIdPackerDimensions Struct containing dimensions related to this
DataIdPacker.- kwds
Additional subclass-specific keyword arguments. Values for these arguments are obtained from the
Registrydatabase according to the how the packer is configured in theRegistry.
Notes
DataIdPackersubclass instances should generally be obtained from aRegistry. This involves the following steps:One or more packers are configured in the
dataIdPackerssection of theRegistryconfiguration. In YAML form, that looks something like this:dataIdPackers: visit_detector_id: given: [instrument] required: [visit, detector] cls: lsst.daf.butler.instrument.ObservationDataIdPacker parameters: instrument: instrument.instrument obsMax: instrument.visit_max detectorMax: instrument.detector_max
See
DataIdPackerDimensionsfor a description of thegivenandrequiredoptions. Theparameterssection maps keyword argument names for theDataIdPackersubclass constructor to dimension metadata fields in theRegistrydatabase that provide the values for these arguments.A
DataIdthat identifies at least the “given” dimensions of theDataIdPackersubclass must be expanded to include those metadata fields, by callingRegistry.expandDataId.Registry.makeDataIdPackeris called with the name of the packer and the expandedDataId. If theDataIdalso identifies all “required” dimensions for the packer,Registry.packDataIdcan be called instead for convenience (though this does not provide a way to callunpack).
Attributes Summary
dimensionsThe dimensions associated with the DataIdPacker(DataIdPackerDimensions).maxBitsThe maximum number of nonzero bits in the packed ID returned by pack(int).Methods Summary
pack(dataId, *[, returnMaxBits])Pack the given data ID into a single integer. unpack(packedId)Unpack an ID produced by packinto a fullDataId.Attributes Documentation
-
dimensions¶ The dimensions associated with the
DataIdPacker(DataIdPackerDimensions).
-
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
Noneto indicate that there is no maximum.
Methods Documentation
-
pack(dataId, *, returnMaxBits=False, **kwds)¶ Pack the given data ID into a single integer.
Parameters: - dataId :
dictorDataId Dictionary-like object identifying (at least) all required dimensions associated with this packer. Subclasses should in general accept an arbitrary mapping and call the
DataIdconstructor internally to standardize. Values for any keys also present in the data ID passed at construction must be the same as the values in the data ID passed at construction.- returnMaxBits :
bool If
True, return a tuple of(packed, self.maxBits).- kwds
Additional keyword arguments forwarded to the
DataIdconstructor.
Returns: Notes
Should not be overridden by derived class (
_packshould be overridden instead).- dataId :
- dimensions :