8 from lsst.pex.config
import Config, Field
14 """Make and write an image of an entire focal plane
18 camera : `lsst.afw.cameraGeom.Camera`
20 exposures : `dict` mapping detector ID to `lsst.afw.image.Exposure`
21 CCD exposures, binned by `binning`.
23 Binning size that has been applied to images.
26 """Source of images for makeImageFromCamera"""
27 def __init__(self, exposures):
32 exposures : `dict` mapping detector ID to `lsst.afw.image.Exposure`
33 CCD exposures, already binned.
36 self.exposures = exposures
37 self.background = np.nan
39 def getCcdImage(self, detector, imageFactory, binSize):
40 """Provide image of CCD to makeImageFromCamera"""
41 detId = detector.getId()
42 if detId
not in self.exposures:
43 dims = detector.getBBox().getDimensions()/binSize
44 image = imageFactory(*[int(xx)
for xx
in dims])
45 image.set(self.background)
47 image = self.exposures[detector.getId()]
48 if hasattr(image,
"getMaskedImage"):
49 image = image.getMaskedImage()
50 if hasattr(image,
"getMask"):
51 mask = image.getMask()
52 isBad = mask.getArray() & mask.getPlaneBitMask(
"NO_DATA") > 0
54 image.getImage().getArray()[isBad] = self.background
55 if hasattr(image,
"getImage"):
56 image = image.getImage()
60 return image, detector
64 imageSource=ImageSource(exposures),
65 imageFactory=afwImage.ImageF,
72 binning = Field(dtype=int, default=8, doc=
"Binning factor to apply")
76 ConfigClass = VisualizeVisitConfig
77 _DefaultName =
"visualizeVisit"
80 BatchPoolTask.__init__(self, *args, **kwargs)
84 def _makeArgumentParser(cls, *args, **kwargs):
85 kwargs.pop(
"doBatch",
False)
87 parser.add_id_argument(
"--id", datasetType=
"calexp", level=
"visit",
88 help=
"data ID, e.g. --id visit=12345")
93 """Return walltime request for batch job
95 Subclasses should override if the walltime should be calculated
96 differently (e.g., addition of some serial time).
101 Requested time per iteration.
102 parsedCmd : `argparse.Namespace`
103 Results of argument parsing.
107 numTargets = len(cls.
RunnerClass.getTargetList(parsedCmd))
108 return time*numTargets
111 """Generate an image of the entire visit
113 Only the master node executes this method; it controls the slave nodes,
114 which do the data retrieval.
118 expRef : `lsst.daf.persistence.ButlerDataRef`
119 Data reference for exposure.
124 pool.storeSet(butler=expRef.getButler())
126 with self.
logOperation(
"processing %s" % (expRef.dataId,)):
127 camera = expRef.get(
"camera")
128 dataIdList = [ccdRef.dataId
for ccdRef
in expRef.subItems(
"ccd")
if
129 ccdRef.datasetExists(
"calexp")]
131 exposures = pool.map(self.
readImage, dataIdList)
132 exposures = dict(keyValue
for keyValue
in exposures
if keyValue
is not None)
134 expRef.put(image,
"calexp_camera")
137 """Collect original image for visualisation
139 This method runs on the slave nodes.
143 cache : `lsst.pipe.base.Struct`
152 image : `lsst.afw.image.MaskedImage`
155 exposure = cache.butler.get(
"calexp", dataId)
156 return (exposure.getDetector().getId(),
159 def _getConfigName(self):
160 """It's not worth preserving the configuration"""
163 def _getMetadataName(self):
164 """There's no metadata to write out"""