Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tickets/dm 3373 #2

Merged
merged 2 commits into from
Mar 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ doc/*.tag
doc/html
doc/xml
doc/doxygen.conf
bin/*
bin
ups/*.cfgc
python/lsst/pipe/drivers/version.py
3 changes: 3 additions & 0 deletions bin.src/constructBias.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
from lsst.pipe.drivers.constructCalibs import BiasTask
BiasTask.parseAndSubmit()
3 changes: 3 additions & 0 deletions bin.src/constructDark.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
from lsst.pipe.drivers.constructCalibs import DarkTask
DarkTask.parseAndSubmit()
3 changes: 3 additions & 0 deletions bin.src/constructFlat.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
from lsst.pipe.drivers.constructCalibs import FlatTask
FlatTask.parseAndSubmit()
3 changes: 3 additions & 0 deletions bin.src/constructFringe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env python
from lsst.pipe.drivers.constructCalibs import FringeTask
FringeTask.parseAndSubmit()
58 changes: 58 additions & 0 deletions python/lsst/pipe/drivers/checksum.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@

import hashlib
import zlib
import cPickle as pickle

import lsst.afw.image as afwImage

__all__ = ["checksum",]

# Image types to support
exposureTypes = (afwImage.ExposureF, afwImage.ExposureD,)
maskedImageTypes = (afwImage.MaskedImageF, afwImage.MaskedImageD,)
decoratedImageTypes = (afwImage.DecoratedImageF, afwImage.DecoratedImageD,)
imageTypes = (afwImage.ImageF, afwImage.ImageD, afwImage.ImageI,)

PROTOCOL = 2 # Pickling protocol

# Functions for creating the checksum
sumFunctions = {
"CRC32" : lambda obj: zlib.crc32(pickle.dumps(obj, PROTOCOL)),
"MD5" : lambda obj: hashlib.md5(pickle.dumps(obj, PROTOCOL)).hexdigest(),
}

def 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
"""
assert sumType in sumFunctions, "Unknown sumType: %s" % (sumType,)
func = sumFunctions[sumType]

results = {}

if isinstance(obj, exposureTypes):
obj = obj.getMaskedImage()
if isinstance(obj, decoratedImageTypes):
obj = obj.getImage()

if isinstance(obj, maskedImageTypes):
results[sumType + "_IMAGE"] = func(obj.getImage())
results[sumType + "_MASK"] = func(obj.getMask())
results[sumType + "_VARIANCE"] = func(obj.getVariance())
elif isinstance(obj, imageTypes):
results[sumType + "_IMAGE"] = func(obj)
else:
results[sumType] = func(obj)

if header is not None:
for k, v in results.iteritems():
header.add(k, v)

return results