1 from __future__
import absolute_import, division, print_function
16 """Make and write an image of an entire focal plane 20 camera : `lsst.afw.cameraGeom.Camera` 22 exposures : `dict` mapping detector ID to `lsst.afw.image.Exposure` 23 CCD exposures, binned by `binning`. 25 Binning size that has been applied to images. 27 class ImageSource(object):
28 """Source of images for makeImageFromCamera""" 29 def __init__(self, exposures):
34 exposures : `dict` mapping detector ID to `lsst.afw.image.Exposure` 35 CCD exposures, already binned. 38 self.exposures = exposures
39 self.background = np.nan
41 def getCcdImage(self, detector, imageFactory, binSize):
42 """Provide image of CCD to makeImageFromCamera""" 43 detId = detector.getId()
44 if detId
not in self.exposures:
45 dims = detector.getBBox().getDimensions()/binSize
46 image = imageFactory(*[int(xx)
for xx
in dims])
47 image.set(self.background)
49 image = self.exposures[detector.getId()]
50 if hasattr(image,
"getMaskedImage"):
51 image = image.getMaskedImage()
52 if hasattr(image,
"getMask"):
53 mask = image.getMask()
54 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
56 image.getImage().getArray()[isBad] = self.background
57 if hasattr(image,
"getImage"):
58 image = image.getImage()
59 return image, detector
61 image = makeImageFromCamera(
63 imageSource=ImageSource(exposures),
64 imageFactory=afwImage.ImageF,
71 binning = Field(dtype=int, default=8, doc=
"Binning factor to apply")
75 ConfigClass = VisualizeVisitConfig
76 _DefaultName =
"visualizeVisit" 79 BatchPoolTask.__init__(self, *args, **kwargs)
83 def _makeArgumentParser(cls, *args, **kwargs):
84 kwargs.pop(
"doBatch",
False)
85 parser = ArgumentParser(name=
"visualizeVisit", *args, **kwargs)
86 parser.add_id_argument(
"--id", datasetType=
"calexp", level=
"visit",
87 help=
"data ID, e.g. --id visit=12345")
92 """Return walltime request for batch job 94 Subclasses should override if the walltime should be calculated 95 differently (e.g., addition of some serial time). 100 Requested time per iteration. 101 parsedCmd : `argparse.Namespace` 102 Results of argument parsing. 106 numTargets = len(cls.RunnerClass.getTargetList(parsedCmd))
107 return time*numTargets
110 """Generate an image of the entire visit 112 Only the master node executes this method; it controls the slave nodes, 113 which do the data retrieval. 117 expRef : `lsst.daf.persistence.ButlerDataRef` 118 Data reference for exposure. 123 pool.storeSet(butler=expRef.getButler())
125 with self.
logOperation(
"processing %s" % (expRef.dataId,)):
126 camera = expRef.get(
"camera")
127 dataIdList = [ccdRef.dataId
for ccdRef
in expRef.subItems(
"ccd")
if 128 ccdRef.datasetExists(
"calexp")]
130 exposures = pool.map(self.
readImage, dataIdList)
131 exposures = dict(keyValue
for keyValue
in exposures
if keyValue
is not None)
133 expRef.put(image,
"calexp_camera")
136 """Collect original image for visualisation 138 This method runs on the slave nodes. 142 cache : `lsst.pipe.base.Struct` 151 image : `lsst.afw.image.MaskedImage` 154 exposure = cache.butler.get(
"calexp", dataId)
155 return (exposure.getDetector().getId(),
156 afwMath.binImage(exposure.getMaskedImage(), self.config.binning))
158 def _getConfigName(self):
159 """It's not worth preserving the configuration""" 162 def _getMetadataName(self):
163 """There's no metadata to write out"""
def readImage(self, cache, dataId)
def batchWallTime(cls, time, parsedCmd, numCores)
def logOperation(self, operation, catch=False, trace=True)
def __init__(self, args, kwargs)
def runDataRef(self, expRef)
def makeCameraImage(camera, exposures, binning)