14 """Make and write an image of an entire focal plane
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):
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)
86 parser = ArgumentParser(name=
"visualizeVisit", *args, **kwargs)
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.
119 Data reference for exposure.
124 pool.storeSet(butler=expRef.getButler())
126 with self.
logOperationlogOperation(
"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.
readImagereadImage, 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`
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"""
An immutable representation of a camera.
A class to contain the data, WCS, and other information needed to describe an image of the sky.
A class to manipulate images, masks, and variance as a single object.
def logOperation(self, operation, catch=False, trace=True)
Provide a context manager for logging an operation.
def batchWallTime(cls, time, parsedCmd, numCores)
def runDataRef(self, expRef)
def __init__(self, *args, **kwargs)
def readImage(self, cache, dataId)
def makeImageFromCamera(camera, detectorNameList=None, background=numpy.nan, bufferSize=10, imageSource=FakeImageDataSource(), imageFactory=afwImage.ImageU, binSize=1)
Backwards-compatibility support for depersisting the old Calib (FluxMag0/FluxMag0Err) objects.
std::shared_ptr< ImageT > rotateImageBy90(ImageT const &image, int nQuarter)
Rotate an image by an integral number of quarter turns.
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
def makeCameraImage(camera, exposures, binning)