LSST Applications  21.0.0-147-g0e635eb1+1acddb5be5,22.0.0+052faf71bd,22.0.0+1ea9a8b2b2,22.0.0+6312710a6c,22.0.0+729191ecac,22.0.0+7589c3a021,22.0.0+9f079a9461,22.0.1-1-g7d6de66+b8044ec9de,22.0.1-1-g87000a6+536b1ee016,22.0.1-1-g8e32f31+6312710a6c,22.0.1-10-gd060f87+016f7cdc03,22.0.1-12-g9c3108e+df145f6f68,22.0.1-16-g314fa6d+c825727ab8,22.0.1-19-g93a5c75+d23f2fb6d8,22.0.1-19-gb93eaa13+aab3ef7709,22.0.1-2-g8ef0a89+b8044ec9de,22.0.1-2-g92698f7+9f079a9461,22.0.1-2-ga9b0f51+052faf71bd,22.0.1-2-gac51dbf+052faf71bd,22.0.1-2-gb66926d+6312710a6c,22.0.1-2-gcb770ba+09e3807989,22.0.1-20-g32debb5+b8044ec9de,22.0.1-23-gc2439a9a+fb0756638e,22.0.1-3-g496fd5d+09117f784f,22.0.1-3-g59f966b+1e6ba2c031,22.0.1-3-g849a1b8+f8b568069f,22.0.1-3-gaaec9c0+c5c846a8b1,22.0.1-32-g5ddfab5d3+60ce4897b0,22.0.1-4-g037fbe1+64e601228d,22.0.1-4-g8623105+b8044ec9de,22.0.1-5-g096abc9+d18c45d440,22.0.1-5-g15c806e+57f5c03693,22.0.1-7-gba73697+57f5c03693,master-g6e05de7fdc+c1283a92b8,master-g72cdda8301+729191ecac,w.2021.39
LSST Data Management Base Package
Functions | Variables
lsst.pipe.drivers.checksum Namespace Reference

Functions

def checksum (obj, header=None, sumType="MD5")
 Calculate a checksum of an object. More...
 

Variables

tuple exposureTypes = (afwImage.ExposureF, afwImage.ExposureD,)
 
tuple maskedImageTypes = (afwImage.MaskedImageF, afwImage.MaskedImageD,)
 
tuple decoratedImageTypes = (afwImage.DecoratedImageF, afwImage.DecoratedImageD,)
 
tuple imageTypes = (afwImage.ImageF, afwImage.ImageD, afwImage.ImageI,)
 
int PROTOCOL = 2
 
dictionary sumFunctions
 

Function Documentation

◆ checksum()

def lsst.pipe.drivers.checksum.checksum (   obj,
  header = None,
  sumType = "MD5" 
)

Calculate a checksum of an object.

We have special handling for images (e.g., breaking a MaskedImage into
its various components), but the object may be any picklable type.

@param obj  Object for which to calculate the checksum
@param header  FITS header (PropertyList) to update with checksum values, or None
@param sumType  Type of checksum to calculate
@return dict with header keyword,value pairs

Definition at line 24 of file checksum.py.

24 def checksum(obj, header=None, sumType="MD5"):
25  """!Calculate a checksum of an object
26 
27  We have special handling for images (e.g., breaking a MaskedImage into
28  its various components), but the object may be any picklable type.
29 
30  @param obj Object for which to calculate the checksum
31  @param header FITS header (PropertyList) to update with checksum values, or None
32  @param sumType Type of checksum to calculate
33  @return dict with header keyword,value pairs
34  """
35  assert sumType in sumFunctions, "Unknown sumType: %s" % (sumType,)
36  func = sumFunctions[sumType]
37 
38  results = {}
39 
40  if isinstance(obj, exposureTypes):
41  obj = obj.getMaskedImage()
42  if isinstance(obj, decoratedImageTypes):
43  obj = obj.getImage()
44 
45  if isinstance(obj, maskedImageTypes):
46  results[sumType + "_IMAGE"] = func(obj.getImage())
47  results[sumType + "_MASK"] = func(obj.getMask())
48  results[sumType + "_VARIANCE"] = func(obj.getVariance())
49  elif isinstance(obj, imageTypes):
50  results[sumType + "_IMAGE"] = func(obj)
51  else:
52  results[sumType] = func(obj)
53 
54  if header is not None:
55  for k, v in results.items():
56  header.add(k, v)
57 
58  return results
def checksum(obj, header=None, sumType="MD5")
Calculate a checksum of an object.
Definition: checksum.py:24

Variable Documentation

◆ decoratedImageTypes

tuple lsst.pipe.drivers.checksum.decoratedImageTypes = (afwImage.DecoratedImageF, afwImage.DecoratedImageD,)

Definition at line 12 of file checksum.py.

◆ exposureTypes

tuple lsst.pipe.drivers.checksum.exposureTypes = (afwImage.ExposureF, afwImage.ExposureD,)

Definition at line 10 of file checksum.py.

◆ imageTypes

tuple lsst.pipe.drivers.checksum.imageTypes = (afwImage.ImageF, afwImage.ImageD, afwImage.ImageI,)

Definition at line 13 of file checksum.py.

◆ maskedImageTypes

tuple lsst.pipe.drivers.checksum.maskedImageTypes = (afwImage.MaskedImageF, afwImage.MaskedImageD,)

Definition at line 11 of file checksum.py.

◆ PROTOCOL

int lsst.pipe.drivers.checksum.PROTOCOL = 2

Definition at line 15 of file checksum.py.

◆ sumFunctions

dictionary lsst.pipe.drivers.checksum.sumFunctions
Initial value:
1 = {
2  "CRC32": lambda obj: zlib.crc32(pickle.dumps(obj, PROTOCOL)),
3  "MD5": lambda obj: hashlib.md5(pickle.dumps(obj, PROTOCOL)).hexdigest(),
4 }

Definition at line 18 of file checksum.py.