LSST Applications g034a557a3c+dd8dd8f11d,g0afe43252f+b86e4b8053,g11f7dcd041+017865fdd3,g1cd03abf6b+8446defddb,g1ce3e0751c+f991eae79d,g28da252d5a+ca8a1a9fb3,g2bbee38e9b+b6588ad223,g2bc492864f+b6588ad223,g2cdde0e794+8523d0dbb4,g347aa1857d+b6588ad223,g35bb328faa+b86e4b8053,g3a166c0a6a+b6588ad223,g461a3dce89+b86e4b8053,g52b1c1532d+b86e4b8053,g7f3b0d46df+ad13c1b82d,g80478fca09+f29c5d6c70,g858d7b2824+293f439f82,g8cd86fa7b1+af721d2595,g965a9036f2+293f439f82,g979bb04a14+51ed57f74c,g9ddcbc5298+f24b38b85a,gae0086650b+b86e4b8053,gbb886bcc26+b97e247655,gc28159a63d+b6588ad223,gc30aee3386+a2f0f6cab9,gcaf7e4fdec+293f439f82,gcd45df26be+293f439f82,gcdd4ae20e8+70b5def7e6,gce08ada175+da9c58a417,gcf0d15dbbd+70b5def7e6,gdaeeff99f8+006e14e809,gdbce86181e+6a170ce272,ge3d4d395c2+224150c836,ge5f7162a3a+bb2241c923,ge6cb8fbbf7+d119aed356,ge79ae78c31+b6588ad223,gf048a9a2f4+40ffced2b8,gf0baf85859+b4cca3d10f,w.2024.30
LSST Data Management Base Package
Loading...
Searching...
No Matches
Public Member Functions | Static Public Attributes | Protected Member Functions | Static Protected Attributes | List of all members
lsst.pipe.tasks.skyCorrection.SkyCorrectionTask Class Reference
Inheritance diagram for lsst.pipe.tasks.skyCorrection.SkyCorrectionTask:

Public Member Functions

 __init__ (self, *args, **kwargs)
 
 runQuantum (self, butlerQC, inputRefs, outputRefs)
 
 run (self, calExps, calBkgs, skyFrames, camera)
 

Static Public Attributes

 ConfigClass = SkyCorrectionConfig
 

Protected Member Functions

 _restoreBackgroundRefineMask (self, calExps, calBkgs)
 
 _subtractVisitBackground (self, calExps, calBkgs, camera, config)
 
 _subtractDetectorBackground (self, calExp, bgModel)
 
 _subtractSkyFrame (self, calExps, skyFrames, calBkgs)
 
 _binAndMosaic (self, exposures, camera, binning, ids=None, refExps=None)
 

Static Protected Attributes

str _DefaultName = "skyCorr"
 

Detailed Description

Perform a full focal plane sky correction.

Definition at line 214 of file skyCorrection.py.

Constructor & Destructor Documentation

◆ __init__()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask.__init__ ( self,
* args,
** kwargs )

Definition at line 220 of file skyCorrection.py.

220 def __init__(self, *args, **kwargs):
221 super().__init__(**kwargs)
222 self.makeSubtask("sky")
223 self.makeSubtask("maskObjects")
224

Member Function Documentation

◆ _binAndMosaic()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask._binAndMosaic ( self,
exposures,
camera,
binning,
ids = None,
refExps = None )
protected
Bin input exposures and mosaic across the entire focal plane.

Input exposures are binned and then mosaicked at the position of
the detector in the focal plane of the camera.

Parameters
----------
exposures : `list`
    Detector level list of either calexp `ExposureF` types or
    calexpBackground `BackgroundList` types.
camera : `lsst.afw.cameraGeom.Camera`
    Camera matching the input data to process.
binning : `int`
    Binning size to be applied to input images.
ids : `list` [`int`], optional
    List of detector ids to iterate over.
refExps : `list` [`lsst.afw.image.exposure.ExposureF`], optional
    If supplied, mask planes from these reference images will be used.
Returns
-------
mosaicImage : `lsst.afw.image.exposure.ExposureF`
    Mosaicked full focal plane image.

Definition at line 535 of file skyCorrection.py.

535 def _binAndMosaic(self, exposures, camera, binning, ids=None, refExps=None):
536 """Bin input exposures and mosaic across the entire focal plane.
537
538 Input exposures are binned and then mosaicked at the position of
539 the detector in the focal plane of the camera.
540
541 Parameters
542 ----------
543 exposures : `list`
544 Detector level list of either calexp `ExposureF` types or
545 calexpBackground `BackgroundList` types.
546 camera : `lsst.afw.cameraGeom.Camera`
547 Camera matching the input data to process.
548 binning : `int`
549 Binning size to be applied to input images.
550 ids : `list` [`int`], optional
551 List of detector ids to iterate over.
552 refExps : `list` [`lsst.afw.image.exposure.ExposureF`], optional
553 If supplied, mask planes from these reference images will be used.
554 Returns
555 -------
556 mosaicImage : `lsst.afw.image.exposure.ExposureF`
557 Mosaicked full focal plane image.
558 """
559 refExps = np.resize(refExps, len(exposures)) # type: ignore
560 binnedImages = []
561 for exp, refExp in zip(exposures, refExps):
562 try:
563 nativeImage = exp.getMaskedImage()
564 except AttributeError:
565 nativeImage = afwImage.makeMaskedImage(exp.getImage())
566 if refExp:
567 nativeImage.setMask(refExp.getMask())
568 binnedImage = afwMath.binImage(nativeImage, binning)
569 binnedImages.append(binnedImage)
570 mosConfig = VisualizeMosaicExpConfig()
571 mosConfig.binning = binning
572 mosTask = VisualizeMosaicExpTask(config=mosConfig)
573 imageStruct = mosTask.run(binnedImages, camera, inputIds=ids)
574 mosaicImage = imageStruct.outputData
575 return mosaicImage
MaskedImage< ImagePixelT, MaskPixelT, VariancePixelT > * makeMaskedImage(typename std::shared_ptr< Image< ImagePixelT > > image, typename std::shared_ptr< Mask< MaskPixelT > > mask=Mask< MaskPixelT >(), typename std::shared_ptr< Image< VariancePixelT > > variance=Image< VariancePixelT >())
A function to return a MaskedImage of the correct type (cf.
std::shared_ptr< ImageT > binImage(ImageT const &inImage, int const binX, int const binY, lsst::afw::math::Property const flags=lsst::afw::math::MEAN)
Definition binImage.cc:44

◆ _restoreBackgroundRefineMask()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask._restoreBackgroundRefineMask ( self,
calExps,
calBkgs )
protected
Restore original background to each calexp and invert the related
background model; optionally refine the mask plane.

The original visit-level background is restored to each calibrated
exposure and the existing background model is inverted in-place. If
doMaskObjects is True, the mask map associated with the exposure will
be iteratively updated (over nIter loops) by re-estimating the
background each iteration and redetecting footprints.

The background model modified in-place in this method will comprise the
first N elements of the skyCorr dataset type, i.e., these N elements
are the inverse of the calexpBackground model. All subsequent elements
appended to skyCorr will be additive such that, when skyCorr is
subtracted from a calexp, the net result will be to undo the initial
per-detector background solution and then apply the skyCorr model
thereafter. Adding skyCorr to a calexpBackground will effectively
negate the calexpBackground, returning only the additive background
components of the skyCorr background model.

Parameters
----------
calExps : `lsst.afw.image.exposure.ExposureF`
    Detector level calexp images to process.
calBkgs : `lsst.afw.math._backgroundList.BackgroundList`
    Detector level background lists associated with the calexps.

Returns
-------
calExps : `lsst.afw.image.exposure.ExposureF`
    The calexps with the initially subtracted background restored.
skyCorrBases : `lsst.afw.math._backgroundList.BackgroundList`
    The inverted initial background models; the genesis for skyCorrs.

Definition at line 331 of file skyCorrection.py.

331 def _restoreBackgroundRefineMask(self, calExps, calBkgs):
332 """Restore original background to each calexp and invert the related
333 background model; optionally refine the mask plane.
334
335 The original visit-level background is restored to each calibrated
336 exposure and the existing background model is inverted in-place. If
337 doMaskObjects is True, the mask map associated with the exposure will
338 be iteratively updated (over nIter loops) by re-estimating the
339 background each iteration and redetecting footprints.
340
341 The background model modified in-place in this method will comprise the
342 first N elements of the skyCorr dataset type, i.e., these N elements
343 are the inverse of the calexpBackground model. All subsequent elements
344 appended to skyCorr will be additive such that, when skyCorr is
345 subtracted from a calexp, the net result will be to undo the initial
346 per-detector background solution and then apply the skyCorr model
347 thereafter. Adding skyCorr to a calexpBackground will effectively
348 negate the calexpBackground, returning only the additive background
349 components of the skyCorr background model.
350
351 Parameters
352 ----------
353 calExps : `lsst.afw.image.exposure.ExposureF`
354 Detector level calexp images to process.
355 calBkgs : `lsst.afw.math._backgroundList.BackgroundList`
356 Detector level background lists associated with the calexps.
357
358 Returns
359 -------
360 calExps : `lsst.afw.image.exposure.ExposureF`
361 The calexps with the initially subtracted background restored.
362 skyCorrBases : `lsst.afw.math._backgroundList.BackgroundList`
363 The inverted initial background models; the genesis for skyCorrs.
364 """
365 skyCorrBases = []
366 for calExp, calBkg in zip(calExps, calBkgs):
367 image = calExp.getMaskedImage()
368
369 # Invert all elements of the existing bg model; restore in calexp
370 for calBkgElement in calBkg:
371 statsImage = calBkgElement[0].getStatsImage()
372 statsImage *= -1
373 skyCorrBase = calBkg.getImage()
374 image -= skyCorrBase
375
376 # Iteratively subtract bg, re-detect sources, and add bg back on
377 if self.config.doMaskObjects:
378 self.maskObjects.findObjects(calExp)
379
380 stats = np.nanpercentile(skyCorrBase.array, [50, 75, 25])
381 self.log.info(
382 "Detector %d: Initial background restored; BG median = %.1f counts, BG IQR = %.1f counts",
383 calExp.getDetector().getId(),
384 -stats[0],
385 np.subtract(*stats[1:]),
386 )
387 skyCorrBases.append(skyCorrBase)
388 return calExps, skyCorrBases
389

◆ _subtractDetectorBackground()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask._subtractDetectorBackground ( self,
calExp,
bgModel )
protected
Generate CCD background model and subtract from image.

Translate the full focal plane background into CCD coordinates and
subtract from the original science exposure image.

Parameters
----------
calExp : `lsst.afw.image.exposure.ExposureF`
    Exposure to subtract the background model from.
bgModel : `lsst.pipe.tasks.background.FocalPlaneBackground`
    Full focal plane camera-level background model.

Returns
-------
calExp : `lsst.afw.image.exposure.ExposureF`
    Background subtracted input exposure.
calBkgElement : `lsst.afw.math._backgroundList.BackgroundList`
    Detector level realization of the full focal plane bg model.

Definition at line 473 of file skyCorrection.py.

473 def _subtractDetectorBackground(self, calExp, bgModel):
474 """Generate CCD background model and subtract from image.
475
476 Translate the full focal plane background into CCD coordinates and
477 subtract from the original science exposure image.
478
479 Parameters
480 ----------
481 calExp : `lsst.afw.image.exposure.ExposureF`
482 Exposure to subtract the background model from.
483 bgModel : `lsst.pipe.tasks.background.FocalPlaneBackground`
484 Full focal plane camera-level background model.
485
486 Returns
487 -------
488 calExp : `lsst.afw.image.exposure.ExposureF`
489 Background subtracted input exposure.
490 calBkgElement : `lsst.afw.math._backgroundList.BackgroundList`
491 Detector level realization of the full focal plane bg model.
492 """
493 image = calExp.getMaskedImage()
494 with warnings.catch_warnings():
495 warnings.filterwarnings("ignore", r"invalid value encountered")
496 calBkgElement = bgModel.toCcdBackground(calExp.getDetector(), image.getBBox())
497 image -= calBkgElement.getImage()
498 return calExp, calBkgElement
499

◆ _subtractSkyFrame()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask._subtractSkyFrame ( self,
calExps,
skyFrames,
calBkgs )
protected
Determine the full focal plane sky frame scale factor relative to
an input list of calibrated exposures and subtract.

This method measures the sky frame scale on all inputs, resulting in
values equal to the background method solveScales(). The sky frame is
then subtracted as in subtractSkyFrame() using the appropriate scale.

Input calExps and calBkgs are updated in-place, returning sky frame
subtracted calExps and sky frame updated calBkgs, respectively.

Parameters
----------
calExps : `list` [`lsst.afw.image.exposure.ExposureF`]
    Calibrated exposures to be background subtracted.
skyFrames : `list` [`lsst.afw.image.exposure.ExposureF`]
    Sky frame calibration data for the input detectors.
calBkgs : `list` [`lsst.afw.math._backgroundList.BackgroundList`]
    Background lists associated with the input calibrated exposures.

Definition at line 500 of file skyCorrection.py.

500 def _subtractSkyFrame(self, calExps, skyFrames, calBkgs):
501 """Determine the full focal plane sky frame scale factor relative to
502 an input list of calibrated exposures and subtract.
503
504 This method measures the sky frame scale on all inputs, resulting in
505 values equal to the background method solveScales(). The sky frame is
506 then subtracted as in subtractSkyFrame() using the appropriate scale.
507
508 Input calExps and calBkgs are updated in-place, returning sky frame
509 subtracted calExps and sky frame updated calBkgs, respectively.
510
511 Parameters
512 ----------
513 calExps : `list` [`lsst.afw.image.exposure.ExposureF`]
514 Calibrated exposures to be background subtracted.
515 skyFrames : `list` [`lsst.afw.image.exposure.ExposureF`]
516 Sky frame calibration data for the input detectors.
517 calBkgs : `list` [`lsst.afw.math._backgroundList.BackgroundList`]
518 Background lists associated with the input calibrated exposures.
519 """
520 skyFrameBgModels = []
521 scales = []
522 for calExp, skyFrame in zip(calExps, skyFrames):
523 skyFrameBgModel = self.sky.exposureToBackground(skyFrame)
524 skyFrameBgModels.append(skyFrameBgModel)
525 # return a tuple of gridded image and sky frame clipped means
526 samples = self.sky.measureScale(calExp.getMaskedImage(), skyFrameBgModel)
527 scales.append(samples)
528 scale = self.sky.solveScales(scales)
529 for calExp, skyFrameBgModel, calBkg in zip(calExps, skyFrameBgModels, calBkgs):
530 # subtract the scaled sky frame model from each calExp in-place,
531 # also updating the calBkg list in-place
532 self.sky.subtractSkyFrame(calExp.getMaskedImage(), skyFrameBgModel, scale, calBkg)
533 self.log.info("Sky frame subtracted with a scale factor of %.5f", scale)
534

◆ _subtractVisitBackground()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask._subtractVisitBackground ( self,
calExps,
calBkgs,
camera,
config )
protected
Perform a full focal-plane background subtraction for a visit.

Generate a full focal plane background model, binning all masked
detectors into bins of [bgModelN.xSize, bgModelN.ySize]. After,
subtract the resultant background model (translated back into CCD
coordinates) from the original detector exposure.

Return a list of background subtracted images and a list of full focal
plane background parameters.

Parameters
----------
calExps : `list` [`lsst.afw.image.exposure.ExposureF`]
    Calibrated exposures to be background subtracted.
calBkgs : `list` [`lsst.afw.math._backgroundList.BackgroundList`]
    Background lists associated with the input calibrated exposures.
camera : `lsst.afw.cameraGeom.Camera`
    Camera description.
config : `lsst.pipe.tasks.background.FocalPlaneBackgroundConfig`
    Configuration to use for background subtraction.

Returns
-------
calExps : `list` [`lsst.afw.image.maskedImage.MaskedImageF`]
    Background subtracted exposures for creating a focal plane image.
calBkgs : `list` [`lsst.afw.math._backgroundList.BackgroundList`]
    Updated background lists with a visit-level model appended.

Definition at line 390 of file skyCorrection.py.

390 def _subtractVisitBackground(self, calExps, calBkgs, camera, config):
391 """Perform a full focal-plane background subtraction for a visit.
392
393 Generate a full focal plane background model, binning all masked
394 detectors into bins of [bgModelN.xSize, bgModelN.ySize]. After,
395 subtract the resultant background model (translated back into CCD
396 coordinates) from the original detector exposure.
397
398 Return a list of background subtracted images and a list of full focal
399 plane background parameters.
400
401 Parameters
402 ----------
403 calExps : `list` [`lsst.afw.image.exposure.ExposureF`]
404 Calibrated exposures to be background subtracted.
405 calBkgs : `list` [`lsst.afw.math._backgroundList.BackgroundList`]
406 Background lists associated with the input calibrated exposures.
407 camera : `lsst.afw.cameraGeom.Camera`
408 Camera description.
409 config : `lsst.pipe.tasks.background.FocalPlaneBackgroundConfig`
410 Configuration to use for background subtraction.
411
412 Returns
413 -------
414 calExps : `list` [`lsst.afw.image.maskedImage.MaskedImageF`]
415 Background subtracted exposures for creating a focal plane image.
416 calBkgs : `list` [`lsst.afw.math._backgroundList.BackgroundList`]
417 Updated background lists with a visit-level model appended.
418 """
419 # Set up empty full focal plane background model object
420 bgModelBase = FocalPlaneBackground.fromCamera(config, camera)
421
422 # Loop over each detector, bin into [xSize, ySize] bins, and update
423 # summed flux (_values) and number of contributing pixels (_numbers)
424 # in focal plane coordinates. Append outputs to bgModels.
425 bgModels = []
426 for calExp in calExps:
427 bgModel = bgModelBase.clone()
428 bgModel.addCcd(calExp)
429 bgModels.append(bgModel)
430
431 # Merge detector models to make a single full focal plane bg model
432 for bgModel, calExp in zip(bgModels, calExps):
433 msg = (
434 "Detector %d: Merging %d unmasked pixels (%.1f%s of detector area) into focal plane "
435 "background model"
436 )
437 self.log.debug(
438 msg,
439 calExp.getDetector().getId(),
440 bgModel._numbers.getArray().sum(),
441 100 * bgModel._numbers.getArray().sum() / calExp.getBBox().getArea(),
442 "%",
443 )
444 bgModelBase.merge(bgModel)
445
446 # Map full focal plane bg solution to detector; subtract from exposure
447 calBkgElements = []
448 for calExp in calExps:
449 _, calBkgElement = self._subtractDetectorBackground(calExp, bgModelBase)
450 calBkgElements.append(calBkgElement)
451
452 msg = (
453 "Focal plane background model constructed using %.2f x %.2f mm (%d x %d pixel) superpixels; "
454 "FP BG median = %.1f counts, FP BG IQR = %.1f counts"
455 )
456 with warnings.catch_warnings():
457 warnings.filterwarnings("ignore", r"invalid value encountered")
458 stats = np.nanpercentile(bgModelBase.getStatsImage().array, [50, 75, 25])
459 self.log.info(
460 msg,
461 config.xSize,
462 config.ySize,
463 int(config.xSize / config.pixelSize),
464 int(config.ySize / config.pixelSize),
465 stats[0],
466 np.subtract(*stats[1:]),
467 )
468
469 for calBkg, calBkgElement in zip(calBkgs, calBkgElements):
470 calBkg.append(calBkgElement[0])
471 return calExps, calBkgs
472

◆ run()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask.run ( self,
calExps,
calBkgs,
skyFrames,
camera )
Perform sky correction on a visit.

The original visit-level background is first restored to the calibrated
exposure and the existing background model is inverted in-place. If
doMaskObjects is True, the mask map associated with this exposure will
be iteratively updated (over nIter loops) by re-estimating the
background each iteration and redetecting footprints.

An initial full focal plane sky subtraction (bgModel1) will take place
prior to scaling and subtracting the sky frame.

If doSky is True, the sky frame will be scaled to the flux in the input
visit.

If doBgModel2 is True, a final full focal plane sky subtraction will
take place after the sky frame has been subtracted.

The first N elements of the returned skyCorr will consist of inverted
elements of the calexpBackground model (i.e., subtractive). All
subsequent elements appended to skyCorr thereafter will be additive
such that, when skyCorr is subtracted from a calexp, the net result
will be to undo the initial per-detector background solution and then
apply the skyCorr model thereafter. Adding skyCorr to a
calexpBackground will effectively negate the calexpBackground,
returning only the additive background components of the skyCorr
background model.

Parameters
----------
calExps : `list` [`lsst.afw.image.exposure.ExposureF`]
    Detector calibrated exposure images for the visit.
calBkgs : `list` [`lsst.afw.math.BackgroundList`]
    Detector background lists matching the calibrated exposures.
skyFrames : `list` [`lsst.afw.image.exposure.ExposureF`]
    Sky frame calibration data for the input detectors.
camera : `lsst.afw.cameraGeom.Camera`
    Camera matching the input data to process.

Returns
-------
results : `Struct` containing:
    skyCorr : `list` [`lsst.afw.math.BackgroundList`]
        Detector-level sky correction background lists.
    calExpMosaic : `lsst.afw.image.exposure.ExposureF`
        Visit-level mosaic of the sky corrected data, binned.
        Analogous to `calexp - skyCorr`.
    calBkgMosaic : `lsst.afw.image.exposure.ExposureF`
        Visit-level mosaic of the sky correction background, binned.
        Analogous to `calexpBackground + skyCorr`.

Definition at line 251 of file skyCorrection.py.

251 def run(self, calExps, calBkgs, skyFrames, camera):
252 """Perform sky correction on a visit.
253
254 The original visit-level background is first restored to the calibrated
255 exposure and the existing background model is inverted in-place. If
256 doMaskObjects is True, the mask map associated with this exposure will
257 be iteratively updated (over nIter loops) by re-estimating the
258 background each iteration and redetecting footprints.
259
260 An initial full focal plane sky subtraction (bgModel1) will take place
261 prior to scaling and subtracting the sky frame.
262
263 If doSky is True, the sky frame will be scaled to the flux in the input
264 visit.
265
266 If doBgModel2 is True, a final full focal plane sky subtraction will
267 take place after the sky frame has been subtracted.
268
269 The first N elements of the returned skyCorr will consist of inverted
270 elements of the calexpBackground model (i.e., subtractive). All
271 subsequent elements appended to skyCorr thereafter will be additive
272 such that, when skyCorr is subtracted from a calexp, the net result
273 will be to undo the initial per-detector background solution and then
274 apply the skyCorr model thereafter. Adding skyCorr to a
275 calexpBackground will effectively negate the calexpBackground,
276 returning only the additive background components of the skyCorr
277 background model.
278
279 Parameters
280 ----------
281 calExps : `list` [`lsst.afw.image.exposure.ExposureF`]
282 Detector calibrated exposure images for the visit.
283 calBkgs : `list` [`lsst.afw.math.BackgroundList`]
284 Detector background lists matching the calibrated exposures.
285 skyFrames : `list` [`lsst.afw.image.exposure.ExposureF`]
286 Sky frame calibration data for the input detectors.
287 camera : `lsst.afw.cameraGeom.Camera`
288 Camera matching the input data to process.
289
290 Returns
291 -------
292 results : `Struct` containing:
293 skyCorr : `list` [`lsst.afw.math.BackgroundList`]
294 Detector-level sky correction background lists.
295 calExpMosaic : `lsst.afw.image.exposure.ExposureF`
296 Visit-level mosaic of the sky corrected data, binned.
297 Analogous to `calexp - skyCorr`.
298 calBkgMosaic : `lsst.afw.image.exposure.ExposureF`
299 Visit-level mosaic of the sky correction background, binned.
300 Analogous to `calexpBackground + skyCorr`.
301 """
302 # Restore original backgrounds in-place; optionally refine mask maps
303 numOrigBkgElements = [len(calBkg) for calBkg in calBkgs]
304 _ = self._restoreBackgroundRefineMask(calExps, calBkgs)
305
306 # Bin exposures, generate full-fp bg, map to CCDs and subtract in-place
307 _ = self._subtractVisitBackground(calExps, calBkgs, camera, self.config.bgModel1)
308
309 # Subtract a scaled sky frame from all input exposures
310 if self.config.doSky:
311 self._subtractSkyFrame(calExps, skyFrames, calBkgs)
312
313 # Bin exposures, generate full-fp bg, map to CCDs and subtract in-place
314 if self.config.doBgModel2:
315 _ = self._subtractVisitBackground(calExps, calBkgs, camera, self.config.bgModel2)
316
317 # Make camera-level images of bg subtracted calexps and subtracted bgs
318 calExpIds = [exp.getDetector().getId() for exp in calExps]
319 skyCorrExtras = []
320 for calBkg, num in zip(calBkgs, numOrigBkgElements):
321 skyCorrExtra = calBkg.clone()
322 skyCorrExtra._backgrounds = skyCorrExtra._backgrounds[num:]
323 skyCorrExtras.append(skyCorrExtra)
324 calExpMosaic = self._binAndMosaic(calExps, camera, self.config.binning, ids=calExpIds, refExps=None)
325 calBkgMosaic = self._binAndMosaic(
326 skyCorrExtras, camera, self.config.binning, ids=calExpIds, refExps=calExps
327 )
328
329 return Struct(skyCorr=calBkgs, calExpMosaic=calExpMosaic, calBkgMosaic=calBkgMosaic)
330

◆ runQuantum()

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask.runQuantum ( self,
butlerQC,
inputRefs,
outputRefs )

Definition at line 225 of file skyCorrection.py.

225 def runQuantum(self, butlerQC, inputRefs, outputRefs):
226 # Sort the calExps, calBkgs and skyFrames inputRefs and the
227 # skyCorr outputRef by detector ID to ensure reproducibility.
228 detectorOrder = [ref.dataId["detector"] for ref in inputRefs.calExps]
229 detectorOrder.sort()
230 inputRefs.calExps = _reorderAndPadList(
231 inputRefs.calExps, [ref.dataId["detector"] for ref in inputRefs.calExps], detectorOrder
232 )
233 inputRefs.calBkgs = _reorderAndPadList(
234 inputRefs.calBkgs, [ref.dataId["detector"] for ref in inputRefs.calBkgs], detectorOrder
235 )
236 # Only attempt to fetch sky frames if they are going to be applied.
237 if self.config.doSky:
238 inputRefs.skyFrames = _reorderAndPadList(
239 inputRefs.skyFrames, [ref.dataId["detector"] for ref in inputRefs.skyFrames], detectorOrder
240 )
241 else:
242 inputRefs.skyFrames = []
243 outputRefs.skyCorr = _reorderAndPadList(
244 outputRefs.skyCorr, [ref.dataId["detector"] for ref in outputRefs.skyCorr], detectorOrder
245 )
246 inputs = butlerQC.get(inputRefs)
247 inputs.pop("rawLinker", None)
248 outputs = self.run(**inputs)
249 butlerQC.put(outputs, outputRefs)
250

Member Data Documentation

◆ _DefaultName

str lsst.pipe.tasks.skyCorrection.SkyCorrectionTask._DefaultName = "skyCorr"
staticprotected

Definition at line 218 of file skyCorrection.py.

◆ ConfigClass

lsst.pipe.tasks.skyCorrection.SkyCorrectionTask.ConfigClass = SkyCorrectionConfig
static

Definition at line 217 of file skyCorrection.py.


The documentation for this class was generated from the following file: