22 __all__ = [
"ExposureIdInfo"]
26 """Exposure ID and number of bits used.
33 maximum number of bits allowed for exposure IDs
35 maximum number of bits available for values that combine exposure ID
36 with other information, such as source ID
38 maximum number of bits available for non-exposure info
41 One common use is creating an ID factory for making a source table.
42 For example, given a data butler `butler` and a data ID `dataId`:
44 .. code-block:: python
46 from lsst.afw.table import IdFactory, SourceTable
47 exposureIdInfo = butler.get("expIdInfo", dataId)
48 sourceIdFactory = IdFactory.makeSource(exposureIdInfo.expId,
49 exposureIdInfo.unusedBits)
50 schema = SourceTable.makeMinimalSchema()
51 #...add fields to schema as desired, then...
52 sourceTable = SourceTable.make(self.schema, sourceIdFactory)
54 At least one bit must be reserved, even if there is no exposure ID, for
55 reasons that are not entirely clear (this is DM-6664).
58 def __init__(self, expId=0, expBits=1, maxBits=64):
59 """Construct an ExposureIdInfo
61 See the class doc string for an explanation of the arguments.
64 expBits = int(expBits)
65 maxBits = int(maxBits)
67 if expId.bit_length() > expBits:
68 raise RuntimeError(
"expId=%s uses %s bits > expBits=%s" % (expId, expId.bit_length(), expBits))
70 raise RuntimeError(
"expBits=%s > maxBits=%s" % (expBits, maxBits))