34 from .coaddBase
import CoaddBaseTask, makeSkyInfo
35 from .warpAndPsfMatch
import WarpAndPsfMatchTask
36 from .coaddHelpers
import groupPatchExposures, getGroupDataRef
38 __all__ = [
"MakeCoaddTempExpTask",
"MakeWarpTask",
"MakeWarpConfig"]
42 """Raised when data cannot be retrieved for an exposure.
43 When processing patches, sometimes one exposure is missing; this lets us
44 distinguish bewteen that case, and other errors.
50 """Config for MakeCoaddTempExpTask
52 warpAndPsfMatch = pexConfig.ConfigurableField(
53 target=WarpAndPsfMatchTask,
54 doc=
"Task to warp and PSF-match calexp",
56 doWrite = pexConfig.Field(
57 doc=
"persist <coaddName>Coadd_<warpType>Warp",
61 bgSubtracted = pexConfig.Field(
62 doc=
"Work with a background subtracted calexp?",
66 coaddPsf = pexConfig.ConfigField(
67 doc=
"Configuration for CoaddPsf",
70 makeDirect = pexConfig.Field(
71 doc=
"Make direct Warp/Coadds",
75 makePsfMatched = pexConfig.Field(
76 doc=
"Make Psf-Matched Warp/Coadd?",
81 doWriteEmptyWarps = pexConfig.Field(
84 doc=
"Write out warps even if they are empty"
87 hasFakes = pexConfig.Field(
88 doc=
"Should be set to True if fake sources have been inserted into the input data.",
92 doApplySkyCorr = pexConfig.Field(dtype=bool, default=
False, doc=
"Apply sky correction?")
95 CoaddBaseTask.ConfigClass.validate(self)
97 raise RuntimeError(
"At least one of config.makePsfMatched and config.makeDirect must be True")
100 log.warn(
"Config doPsfMatch deprecated. Setting makePsfMatched=True and makeDirect=False")
105 CoaddBaseTask.ConfigClass.setDefaults(self)
106 self.
warpAndPsfMatch.psfMatch.kernel.active.kernelSize = self.matchingKernelSize
117 r"""!Warp and optionally PSF-Match calexps onto an a common projection.
119 @anchor MakeCoaddTempExpTask_
121 @section pipe_tasks_makeCoaddTempExp_Contents Contents
123 - @ref pipe_tasks_makeCoaddTempExp_Purpose
124 - @ref pipe_tasks_makeCoaddTempExp_Initialize
125 - @ref pipe_tasks_makeCoaddTempExp_IO
126 - @ref pipe_tasks_makeCoaddTempExp_Config
127 - @ref pipe_tasks_makeCoaddTempExp_Debug
128 - @ref pipe_tasks_makeCoaddTempExp_Example
130 @section pipe_tasks_makeCoaddTempExp_Purpose Description
132 Warp and optionally PSF-Match calexps onto a common projection, by
133 performing the following operations:
134 - Group calexps by visit/run
135 - For each visit, generate a Warp by calling method @ref makeTempExp.
136 makeTempExp loops over the visit's calexps calling @ref WarpAndPsfMatch
139 The result is a `directWarp` (and/or optionally a `psfMatchedWarp`).
141 @section pipe_tasks_makeCoaddTempExp_Initialize Task Initialization
143 @copydoc \_\_init\_\_
145 This task has one special keyword argument: passing reuse=True will cause
146 the task to skip the creation of warps that are already present in the
149 @section pipe_tasks_makeCoaddTempExp_IO Invoking the Task
151 This task is primarily designed to be run from the command line.
153 The main method is `runDataRef`, which takes a single butler data reference for the patch(es)
158 WarpType identifies the types of convolutions applied to Warps (previously CoaddTempExps).
159 Only two types are available: direct (for regular Warps/Coadds) and psfMatched
160 (for Warps/Coadds with homogenized PSFs). We expect to add a third type, likelihood,
161 for generating likelihood Coadds with Warps that have been correlated with their own PSF.
163 @section pipe_tasks_makeCoaddTempExp_Config Configuration parameters
165 See @ref MakeCoaddTempExpConfig and parameters inherited from
166 @link lsst.pipe.tasks.coaddBase.CoaddBaseConfig CoaddBaseConfig @endlink
168 @subsection pipe_tasks_MakeCoaddTempExp_psfMatching Guide to PSF-Matching Configs
170 To make `psfMatchedWarps`, select `config.makePsfMatched=True`. The subtask
171 @link lsst.ip.diffim.modelPsfMatch.ModelPsfMatchTask ModelPsfMatchTask @endlink
172 is responsible for the PSF-Matching, and its config is accessed via `config.warpAndPsfMatch.psfMatch`.
173 The optimal configuration depends on aspects of dataset: the pixel scale, average PSF FWHM and
174 dimensions of the PSF kernel. These configs include the requested model PSF, the matching kernel size,
175 padding of the science PSF thumbnail and spatial sampling frequency of the PSF.
177 *Config Guidelines*: The user must specify the size of the model PSF to which to match by setting
178 `config.modelPsf.defaultFwhm` in units of pixels. The appropriate values depends on science case.
179 In general, for a set of input images, this config should equal the FWHM of the visit
180 with the worst seeing. The smallest it should be set to is the median FWHM. The defaults
181 of the other config options offer a reasonable starting point.
182 The following list presents the most common problems that arise from a misconfigured
183 @link lsst.ip.diffim.modelPsfMatch.ModelPsfMatchTask ModelPsfMatchTask @endlink
184 and corresponding solutions. All assume the default Alard-Lupton kernel, with configs accessed via
185 ```config.warpAndPsfMatch.psfMatch.kernel['AL']```. Each item in the list is formatted as:
186 Problem: Explanation. *Solution*
188 *Troublshooting PSF-Matching Configuration:*
189 - Matched PSFs look boxy: The matching kernel is too small. _Increase the matching kernel size.
192 config.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSize=27 # default 21
194 Note that increasing the kernel size also increases runtime.
195 - Matched PSFs look ugly (dipoles, quadropoles, donuts): unable to find good solution
196 for matching kernel. _Provide the matcher with more data by either increasing
197 the spatial sampling by decreasing the spatial cell size,_
199 config.warpAndPsfMatch.psfMatch.kernel['AL'].sizeCellX = 64 # default 128
200 config.warpAndPsfMatch.psfMatch.kernel['AL'].sizeCellY = 64 # default 128
202 _or increasing the padding around the Science PSF, for example:_
204 config.warpAndPsfMatch.psfMatch.autoPadPsfTo=1.6 # default 1.4
206 Increasing `autoPadPsfTo` increases the minimum ratio of input PSF dimensions to the
207 matching kernel dimensions, thus increasing the number of pixels available to fit
208 after convolving the PSF with the matching kernel.
209 Optionally, for debugging the effects of padding, the level of padding may be manually
210 controlled by setting turning off the automatic padding and setting the number
211 of pixels by which to pad the PSF:
213 config.warpAndPsfMatch.psfMatch.doAutoPadPsf = False # default True
214 config.warpAndPsfMatch.psfMatch.padPsfBy = 6 # pixels. default 0
216 - Deconvolution: Matching a large PSF to a smaller PSF produces
217 a telltale noise pattern which looks like ripples or a brain.
218 _Increase the size of the requested model PSF. For example:_
220 config.modelPsf.defaultFwhm = 11 # Gaussian sigma in units of pixels.
222 - High frequency (sometimes checkered) noise: The matching basis functions are too small.
223 _Increase the width of the Gaussian basis functions. For example:_
225 config.warpAndPsfMatch.psfMatch.kernel['AL'].alardSigGauss=[1.5, 3.0, 6.0]
226 # from default [0.7, 1.5, 3.0]
229 @section pipe_tasks_makeCoaddTempExp_Debug Debug variables
231 MakeCoaddTempExpTask has no debug output, but its subtasks do.
233 @section pipe_tasks_makeCoaddTempExp_Example A complete example of using MakeCoaddTempExpTask
235 This example uses the package ci_hsc to show how MakeCoaddTempExp fits
236 into the larger Data Release Processing.
241 # if not built already:
242 python $(which scons) # this will take a while
244 The following assumes that `processCcd.py` and `makeSkyMap.py` have previously been run
245 (e.g. by building `ci_hsc` above) to generate a repository of calexps and an
246 output respository with the desired SkyMap. The command,
248 makeCoaddTempExp.py $CI_HSC_DIR/DATA --rerun ci_hsc \
249 --id patch=5,4 tract=0 filter=HSC-I \
250 --selectId visit=903988 ccd=16 --selectId visit=903988 ccd=17 \
251 --selectId visit=903988 ccd=23 --selectId visit=903988 ccd=24 \
252 --config doApplyExternalPhotoCalib=False doApplyExternalSkyWcs=False \
253 makePsfMatched=True modelPsf.defaultFwhm=11
255 writes a direct and PSF-Matched Warp to
256 - `$CI_HSC_DIR/DATA/rerun/ci_hsc/deepCoadd/HSC-I/0/5,4/warp-HSC-I-0-5,4-903988.fits` and
257 - `$CI_HSC_DIR/DATA/rerun/ci_hsc/deepCoadd/HSC-I/0/5,4/psfMatchedWarp-HSC-I-0-5,4-903988.fits`
260 @note PSF-Matching in this particular dataset would benefit from adding
261 `--configfile ./matchingConfig.py` to
262 the command line arguments where `matchingConfig.py` is defined by:
265 config.warpAndPsfMatch.psfMatch.kernel['AL'].kernelSize=27
266 config.warpAndPsfMatch.psfMatch.kernel['AL'].alardSigGauss=[1.5, 3.0, 6.0]" > matchingConfig.py
269 Add the option `--help` to see more options.
271 ConfigClass = MakeCoaddTempExpConfig
272 _DefaultName =
"makeCoaddTempExp"
275 CoaddBaseTask.__init__(self, **kwargs)
277 self.makeSubtask(
"warpAndPsfMatch")
278 if self.config.hasFakes:
285 """!Produce <coaddName>Coadd_<warpType>Warp images by warping and optionally PSF-matching.
287 @param[in] patchRef: data reference for sky map patch. Must include keys "tract", "patch",
288 plus the camera-specific filter key (e.g. "filter" or "band")
289 @return: dataRefList: a list of data references for the new <coaddName>Coadd_directWarps
290 if direct or both warp types are requested and <coaddName>Coadd_psfMatchedWarps if only psfMatched
293 @warning: this task assumes that all exposures in a warp (coaddTempExp) have the same filter.
295 @warning: this task sets the PhotoCalib of the coaddTempExp to the PhotoCalib of the first calexp
296 with any good pixels in the patch. For a mosaic camera the resulting PhotoCalib should be ignored
297 (assembleCoadd should determine zeropoint scaling without referring to it).
302 if self.config.makePsfMatched
and not self.config.makeDirect:
307 calExpRefList = self.
selectExposures(patchRef, skyInfo, selectDataList=selectDataList)
309 if len(calExpRefList) == 0:
310 self.log.warn(
"No exposures to coadd for patch %s", patchRef.dataId)
312 self.log.info(
"Selected %d calexps for patch %s", len(calExpRefList), patchRef.dataId)
313 calExpRefList = [calExpRef
for calExpRef
in calExpRefList
if calExpRef.datasetExists(self.
calexpType)]
314 self.log.info(
"Processing %d existing calexps for patch %s", len(calExpRefList), patchRef.dataId)
318 self.log.info(
"Processing %d warp exposures for patch %s", len(groupData.groups), patchRef.dataId)
321 for i, (tempExpTuple, calexpRefList)
in enumerate(groupData.groups.items()):
323 tempExpTuple, groupData.keys)
324 if self.
reuse and tempExpRef.datasetExists(datasetType=primaryWarpDataset, write=
True):
325 self.log.info(
"Skipping makeCoaddTempExp for %s; output already exists.", tempExpRef.dataId)
326 dataRefList.append(tempExpRef)
328 self.log.info(
"Processing Warp %d/%d: id=%s", i, len(groupData.groups), tempExpRef.dataId)
334 visitId = int(tempExpRef.dataId[
"visit"])
335 except (KeyError, ValueError):
342 for calExpInd, calExpRef
in enumerate(calexpRefList):
343 self.log.info(
"Reading calexp %s of %s for Warp id=%s", calExpInd+1, len(calexpRefList),
346 ccdId = calExpRef.get(
"ccdExposureId", immediate=
True)
353 calExpRef = calExpRef.butlerSubset.butler.dataRef(self.
calexpType,
354 dataId=calExpRef.dataId,
355 tract=skyInfo.tractInfo.getId())
357 except Exception
as e:
358 self.log.warn(
"Calexp %s not found; skipping it: %s", calExpRef.dataId, e)
361 if self.config.doApplySkyCorr:
364 calExpList.append(calExp)
365 ccdIdList.append(ccdId)
366 dataIdList.append(calExpRef.dataId)
368 exps = self.
run(calExpList, ccdIdList, skyInfo, visitId, dataIdList).exposures
370 if any(exps.values()):
371 dataRefList.append(tempExpRef)
373 self.log.warn(
"Warp %s could not be created", tempExpRef.dataId)
375 if self.config.doWrite:
376 for (warpType, exposure)
in exps.items():
377 if exposure
is not None:
384 def run(self, calExpList, ccdIdList, skyInfo, visitId=0, dataIdList=None):
385 """Create a Warp from inputs
387 We iterate over the multiple calexps in a single exposure to construct
388 the warp (previously called a coaddTempExp) of that exposure to the
389 supplied tract/patch.
391 Pixels that receive no pixels are set to NAN; this is not correct
392 (violates LSST algorithms group policy), but will be fixed up by
393 interpolating after the coaddition.
395 @param calexpRefList: List of data references for calexps that (may)
396 overlap the patch of interest
397 @param skyInfo: Struct from CoaddBaseTask.getSkyInfo() with geometric
398 information about the patch
399 @param visitId: integer identifier for visit, for the table that will
401 @return a pipeBase Struct containing:
402 - exposures: a dictionary containing the warps requested:
403 "direct": direct warp if config.makeDirect
404 "psfMatched": PSF-matched warp if config.makePsfMatched
408 totGoodPix = {warpType: 0
for warpType
in warpTypeList}
409 didSetMetadata = {warpType:
False for warpType
in warpTypeList}
411 inputRecorder = {warpType: self.inputRecorder.makeCoaddTempExpRecorder(visitId, len(calExpList))
412 for warpType
in warpTypeList}
414 modelPsf = self.config.modelPsf.apply()
if self.config.makePsfMatched
else None
415 if dataIdList
is None:
416 dataIdList = ccdIdList
418 for calExpInd, (calExp, ccdId, dataId)
in enumerate(zip(calExpList, ccdIdList, dataIdList)):
419 self.log.info(
"Processing calexp %d of %d for this Warp: id=%s",
420 calExpInd+1, len(calExpList), dataId)
423 warpedAndMatched = self.warpAndPsfMatch.
run(calExp, modelPsf=modelPsf,
424 wcs=skyInfo.wcs, maxBBox=skyInfo.bbox,
425 makeDirect=self.config.makeDirect,
426 makePsfMatched=self.config.makePsfMatched)
427 except Exception
as e:
428 self.log.warn(
"WarpAndPsfMatch failed for calexp %s; skipping it: %s", dataId, e)
431 numGoodPix = {warpType: 0
for warpType
in warpTypeList}
432 for warpType
in warpTypeList:
433 exposure = warpedAndMatched.getDict()[warpType]
436 coaddTempExp = coaddTempExps[warpType]
437 if didSetMetadata[warpType]:
438 mimg = exposure.getMaskedImage()
439 mimg *= (coaddTempExp.getPhotoCalib().getInstFluxAtZeroMagnitude()
440 / exposure.getPhotoCalib().getInstFluxAtZeroMagnitude())
442 numGoodPix[warpType] = coaddUtils.copyGoodPixels(
443 coaddTempExp.getMaskedImage(), exposure.getMaskedImage(), self.
getBadPixelMask())
444 totGoodPix[warpType] += numGoodPix[warpType]
445 self.log.debug(
"Calexp %s has %d good pixels in this patch (%.1f%%) for %s",
446 dataId, numGoodPix[warpType],
447 100.0*numGoodPix[warpType]/skyInfo.bbox.getArea(), warpType)
448 if numGoodPix[warpType] > 0
and not didSetMetadata[warpType]:
449 coaddTempExp.setPhotoCalib(exposure.getPhotoCalib())
450 coaddTempExp.setFilter(exposure.getFilter())
451 coaddTempExp.getInfo().setVisitInfo(exposure.getInfo().getVisitInfo())
453 coaddTempExp.setPsf(exposure.getPsf())
454 didSetMetadata[warpType] =
True
457 inputRecorder[warpType].addCalExp(calExp, ccdId, numGoodPix[warpType])
459 except Exception
as e:
460 self.log.warn(
"Error processing calexp %s; skipping it: %s", dataId, e)
463 for warpType
in warpTypeList:
464 self.log.info(
"%sWarp has %d good pixels (%.1f%%)",
465 warpType, totGoodPix[warpType], 100.0*totGoodPix[warpType]/skyInfo.bbox.getArea())
467 if totGoodPix[warpType] > 0
and didSetMetadata[warpType]:
468 inputRecorder[warpType].finish(coaddTempExps[warpType], totGoodPix[warpType])
469 if warpType ==
"direct":
470 coaddTempExps[warpType].setPsf(
471 CoaddPsf(inputRecorder[warpType].coaddInputs.ccds, skyInfo.wcs,
472 self.config.coaddPsf.makeControl()))
474 if not self.config.doWriteEmptyWarps:
476 coaddTempExps[warpType] =
None
478 result = pipeBase.Struct(exposures=coaddTempExps)
482 """Return one calibrated Exposure, possibly with an updated SkyWcs.
484 @param[in] dataRef a sensor-level data reference
485 @param[in] bgSubtracted return calexp with background subtracted? If False get the
486 calexp's background background model and add it to the calexp.
487 @return calibrated exposure
489 @raises MissingExposureError If data for the exposure is not available.
491 If config.doApplyExternalPhotoCalib is `True`, the photometric calibration
492 (`photoCalib`) is taken from `config.externalPhotoCalibName` via the
493 `name_photoCalib` dataset. Otherwise, the photometric calibration is
494 retrieved from the processed exposure. When
495 `config.doApplyExternalSkyWcs` is `True`, the astrometric calibration
496 is taken from `config.externalSkyWcsName` with the `name_wcs` dataset.
497 Otherwise, the astrometric calibration is taken from the processed
501 exposure = dataRef.get(self.
calexpType, immediate=
True)
502 except dafPersist.NoResults
as e:
506 background = dataRef.get(
"calexpBackground", immediate=
True)
507 mi = exposure.getMaskedImage()
508 mi += background.getImage()
511 if self.config.doApplyExternalPhotoCalib:
512 source = f
"{self.config.externalPhotoCalibName}_photoCalib"
513 self.log.debug(
"Applying external photoCalib to %s from %s", dataRef.dataId, source)
514 photoCalib = dataRef.get(source)
515 exposure.setPhotoCalib(photoCalib)
517 photoCalib = exposure.getPhotoCalib()
519 if self.config.doApplyExternalSkyWcs:
520 source = f
"{self.config.externalSkyWcsName}_wcs"
521 self.log.debug(
"Applying external skyWcs to %s from %s", dataRef.dataId, source)
522 skyWcs = dataRef.get(source)
523 exposure.setWcs(skyWcs)
525 exposure.maskedImage = photoCalib.calibrateImage(exposure.maskedImage,
526 includeScaleUncertainty=self.config.includeCalibVar)
527 exposure.maskedImage /= photoCalib.getCalibrationMean()
533 def _prepareEmptyExposure(skyInfo):
534 """Produce an empty exposure for a given patch"""
535 exp = afwImage.ExposureF(skyInfo.bbox, skyInfo.wcs)
536 exp.getMaskedImage().set(numpy.nan, afwImage.Mask
537 .getPlaneBitMask(
"NO_DATA"), numpy.inf)
541 """Return list of requested warp types per the config.
544 if self.config.makeDirect:
545 warpTypeList.append(
"direct")
546 if self.config.makePsfMatched:
547 warpTypeList.append(
"psfMatched")
551 """Apply correction to the sky background level
553 Sky corrections can be generated with the 'skyCorrection.py'
554 executable in pipe_drivers. Because the sky model used by that
555 code extends over the entire focal plane, this can produce
556 better sky subtraction.
558 The calexp is updated in-place.
562 dataRef : `lsst.daf.persistence.ButlerDataRef`
563 Data reference for calexp.
564 calexp : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
567 bg = dataRef.get(
"skyCorr")
568 self.log.debug(
"Applying sky correction to %s", dataRef.dataId)
569 if isinstance(calexp, afwImage.Exposure):
570 calexp = calexp.getMaskedImage()
571 calexp -= bg.getImage()
575 dimensions=(
"tract",
"patch",
"skymap",
"instrument",
"visit"),
576 defaultTemplates={
"coaddName":
"deep"}):
577 calExpList = cT.Input(
578 doc=
"Input exposures to be resampled and optionally PSF-matched onto a SkyMap projection/patch",
580 storageClass=
"ExposureF",
581 dimensions=(
"instrument",
"visit",
"detector"),
584 backgroundList = cT.Input(
585 doc=
"Input backgrounds to be added back into the calexp if bgSubtracted=False",
586 name=
"calexpBackground",
587 storageClass=
"Background",
588 dimensions=(
"instrument",
"visit",
"detector"),
591 skyCorrList = cT.Input(
592 doc=
"Input Sky Correction to be subtracted from the calexp if doApplySkyCorr=True",
594 storageClass=
"Background",
595 dimensions=(
"instrument",
"visit",
"detector"),
599 doc=
"Input definition of geometry/bbox and projection/wcs for warped exposures",
600 name=BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
601 storageClass=
"SkyMap",
602 dimensions=(
"skymap",),
605 doc=(
"Output direct warped exposure (previously called CoaddTempExp), produced by resampling ",
606 "calexps onto the skyMap patch geometry."),
607 name=
"{coaddName}Coadd_directWarp",
608 storageClass=
"ExposureF",
609 dimensions=(
"tract",
"patch",
"skymap",
"visit",
"instrument"),
611 psfMatched = cT.Output(
612 doc=(
"Output PSF-Matched warped exposure (previously called CoaddTempExp), produced by resampling ",
613 "calexps onto the skyMap patch geometry and PSF-matching to a model PSF."),
614 name=
"{coaddName}Coadd_psfMatchedWarp",
615 storageClass=
"ExposureF",
616 dimensions=(
"tract",
"patch",
"skymap",
"visit",
"instrument"),
619 def __init__(self, *, config=None):
620 super().__init__(config=config)
621 if config.bgSubtracted:
622 self.inputs.remove(
"backgroundList")
623 if not config.doApplySkyCorr:
624 self.inputs.remove(
"skyCorrList")
625 if not config.makeDirect:
626 self.outputs.remove(
"direct")
627 if not config.makePsfMatched:
628 self.outputs.remove(
"psfMatched")
632 pipelineConnections=MakeWarpConnections):
637 if self.doApplyExternalPhotoCalib:
638 raise RuntimeError(
"Gen3 MakeWarpTask cannot apply external PhotoCalib results. "
639 "Please set doApplyExternalPhotoCalib=False.")
640 if self.doApplyExternalSkyWcs:
641 raise RuntimeError(
"Gen3 MakeWarpTask cannot apply external SkyWcs results. "
642 "Please set doApplyExternalSkyWcs=False.")
646 """Warp and optionally PSF-Match calexps onto an a common projection
648 First Draft of a Gen3 compatible MakeWarpTask which
649 currently does not handle doApplyExternalPhotoCalib=True or
650 doApplyExternalSkyWcs=True.
652 ConfigClass = MakeWarpConfig
653 _DefaultName =
"makeWarp"
655 @utils.inheritDoc(pipeBase.PipelineTask)
656 def runQuantum(self, butlerQC, inputRefs, outputRefs):
660 Construct warps for requested warp type for single epoch
662 PipelineTask (Gen3) entry point to warp and optionally PSF-match
663 calexps. This method is analogous to `runDataRef`.
666 inputs = butlerQC.get(inputRefs)
670 skyMap = inputs.pop(
"skyMap")
671 quantumDataId = butlerQC.quantum.dataId
672 skyInfo =
makeSkyInfo(skyMap, tractId=quantumDataId[
'tract'], patchId=quantumDataId[
'patch'])
675 dataIdList = [ref.dataId
for ref
in inputRefs.calExpList]
678 ccdIdList = [dataId.pack(
"visit_detector")
for dataId
in dataIdList]
681 visits = [dataId[
'visit']
for dataId
in dataIdList]
682 assert(all(visits[0] == visit
for visit
in visits))
685 self.prepareCalibratedExposures(**inputs)
686 results = self.run(**inputs, visitId=visitId, ccdIdList=ccdIdList, dataIdList=dataIdList,
688 if self.config.makeDirect:
689 butlerQC.put(results.exposures[
"direct"], outputRefs.direct)
690 if self.config.makePsfMatched:
691 butlerQC.put(results.exposures[
"psfMatched"], outputRefs.psfMatched)
693 def prepareCalibratedExposures(self, calExpList, backgroundList=None, skyCorrList=None):
694 """Calibrate and add backgrounds to input calExpList in place
696 TODO DM-17062: apply jointcal/meas_mosaic here
700 calExpList : `list` of `lsst.afw.image.Exposure`
701 Sequence of calexps to be modified in place
702 backgroundList : `list` of `lsst.afw.math.backgroundList`
703 Sequence of backgrounds to be added back in if bgSubtracted=False
704 skyCorrList : `list` of `lsst.afw.math.backgroundList`
705 Sequence of background corrections to be subtracted if doApplySkyCorr=True
707 backgroundList = len(calExpList)*[
None]
if backgroundList
is None else backgroundList
708 skyCorrList = len(calExpList)*[
None]
if skyCorrList
is None else skyCorrList
709 for calexp, background, skyCorr
in zip(calExpList, backgroundList, skyCorrList):
710 mi = calexp.maskedImage
711 if not self.config.bgSubtracted:
712 mi += background.getImage()
713 if self.config.doApplySkyCorr:
714 mi -= skyCorr.getImage()