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. 28 """Source of images for makeImageFromCamera""" 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()
62 return image, detector
66 imageSource=ImageSource(exposures),
67 imageFactory=afwImage.ImageF,
74 binning =
Field(dtype=int, default=8, doc=
"Binning factor to apply")
78 ConfigClass = VisualizeVisitConfig
79 _DefaultName =
"visualizeVisit" 82 BatchPoolTask.__init__(self, *args, **kwargs)
86 def _makeArgumentParser(cls, *args, **kwargs):
87 kwargs.pop(
"doBatch",
False)
89 parser.add_id_argument(
"--id", datasetType=
"calexp", level=
"visit",
90 help=
"data ID, e.g. --id visit=12345")
95 """Return walltime request for batch job 97 Subclasses should override if the walltime should be calculated 98 differently (e.g., addition of some serial time). 103 Requested time per iteration. 104 parsedCmd : `argparse.Namespace` 105 Results of argument parsing. 109 numTargets = len(cls.
RunnerClass.getTargetList(parsedCmd))
110 return time*numTargets
113 """Generate an image of the entire visit 115 Only the master node executes this method; it controls the slave nodes, 116 which do the data retrieval. 120 expRef : `lsst.daf.persistence.ButlerDataRef` 121 Data reference for exposure. 126 pool.storeSet(butler=expRef.getButler())
128 with self.
logOperation(
"processing %s" % (expRef.dataId,)):
129 camera = expRef.get(
"camera")
130 dataIdList = [ccdRef.dataId
for ccdRef
in expRef.subItems(
"ccd")
if 131 ccdRef.datasetExists(
"calexp")]
133 exposures = pool.map(self.
readImage, dataIdList)
134 exposures = dict(keyValue
for keyValue
in exposures
if keyValue
is not None)
136 expRef.put(image,
"calexp_camera")
139 """Collect original image for visualisation 141 This method runs on the slave nodes. 145 cache : `lsst.pipe.base.Struct` 154 image : `lsst.afw.image.MaskedImage` 157 exposure = cache.butler.get(
"calexp", dataId)
158 return (exposure.getDetector().getId(),
161 def _getConfigName(self):
162 """It's not worth preserving the configuration""" 165 def _getMetadataName(self):
166 """There's no metadata to write out"""
def readImage(self, cache, dataId)
def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1)
std::shared_ptr< ImageT > rotateImageBy90(ImageT const &image, int nQuarter)
Rotate an image by an integral number of quarter turns.
def __init__(self, minimum, dataRange, Q)
def batchWallTime(cls, time, parsedCmd, numCores)
def logOperation(self, operation, catch=False, trace=True)
Provide a context manager for logging an operation.
def __init__(self, args, kwargs)
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binsize, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
def runDataRef(self, expRef)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects...
def makeCameraImage(camera, exposures, binning)