Hide keyboard shortcuts

Hot-keys on this page

r m x p   toggle line displays

j k   next/prev highlighted chunk

0   (zero) top of page

1   (one) first highlighted chunk

1# This file is part of obs_base. 

2# 

3# Developed for the LSST Data Management System. 

4# This product includes software developed by the LSST Project 

5# (https://www.lsst.org). 

6# See the COPYRIGHT file at the top-level directory of this distribution 

7# for details of code ownership. 

8# 

9# This program is free software: you can redistribute it and/or modify 

10# it under the terms of the GNU General Public License as published by 

11# the Free Software Foundation, either version 3 of the License, or 

12# (at your option) any later version. 

13# 

14# This program is distributed in the hope that it will be useful, 

15# but WITHOUT ANY WARRANTY; without even the implied warranty of 

16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

17# GNU General Public License for more details. 

18# 

19# You should have received a copy of the GNU General Public License 

20# along with this program. If not, see <https://www.gnu.org/licenses/>. 

21 

22__all__ = ["ExposureIdInfo"] 

23 

24 

25class ExposureIdInfo(object): 

26 """Exposure ID and number of bits used. 

27 

28 Attributes include: 

29 

30 expId 

31 exposure ID as an int 

32 expBits 

33 maximum number of bits allowed for exposure IDs 

34 maxBits 

35 maximum number of bits available for values that combine exposure ID 

36 with other information, such as source ID 

37 unusedBits 

38 maximum number of bits available for non-exposure info 

39 (maxBits - expBits) 

40 

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`: 

43 

44 .. code-block:: python 

45 

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) 

53 

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). 

56 """ 

57 

58 def __init__(self, expId=0, expBits=1, maxBits=64): 

59 """Construct an ExposureIdInfo 

60 

61 See the class doc string for an explanation of the arguments. 

62 """ 

63 expId = int(expId) 

64 expBits = int(expBits) 

65 maxBits = int(maxBits) 

66 

67 if expId.bit_length() > expBits: 

68 raise RuntimeError("expId=%s uses %s bits > expBits=%s" % (expId, expId.bit_length(), expBits)) 

69 if maxBits < expBits: 

70 raise RuntimeError("expBits=%s > maxBits=%s" % (expBits, maxBits)) 

71 

72 self.expId = expId 

73 self.expBits = expBits 

74 self.maxBits = maxBits 

75 

76 @property 

77 def unusedBits(self): 

78 return self.maxBits - self.expBits