lsst.pipe.tasks g2c8cee2ce7+cc5eabfb3a
Loading...
Searching...
No Matches
lsst.pipe.tasks.matchBackgrounds Namespace Reference

Classes

class  ChooseReferenceVisitConfig
class  ChooseReferenceVisitTask
class  MatchBackgroundsConnections

Typedefs

type visits[`int`, `TractBackground`] = np.unique([i.dataId["visit"] for i in warps])

Functions

 matchBackgrounds (self, warps, skyMap, refVisitId)
tuple[BackgroundMI, BackgroundControlfitBackground (MaskedImageF warp, statsCtrl, statsFlag, undersampleStyle)

Variables

 config : `MatchBackgroundsConfig`
 statsCtrl : `~lsst.afw.math.StatisticsControl`
 warps : `list`[`~lsst.afw.image.Exposure`]
 skyMap : `lsst.skyMap.SkyMap`
 result : `~lsst.afw.math.BackgroundList`, `~lsst.afw.image.Exposure`
 visitTractDifferenceBackgrounds
 visitWarpDDFs
 refWarpDDFs
 refPatches
 bgModelBase
 bgModels
 msg
 workingWarp
 patchId
 idx
 refWarp
 array
 bgModel
 bgModelImage
 bkgd
 _
 bkgdImage
 resids
 rms
 mse

Typedef Documentation

◆ visits

type lsst.pipe.tasks.matchBackgrounds.visits[`int`, `TractBackground`] = np.unique([i.dataId["visit"] for i in warps])

Definition at line 475 of file matchBackgrounds.py.

Function Documentation

◆ fitBackground()

tuple[BackgroundMI, BackgroundControl] fitBackground ( MaskedImageF warp,
statsCtrl,
statsFlag,
undersampleStyle )
Generate a simple binned background masked image for warped or other
data

Parameters
----------
warp: `~lsst.afw.image.MaskedImageF`
    Warped exposure for which to estimate background.
statsCtrl : `~lsst.afw.math.StatisticsControl`
    Statistics control object.
statsFlag : `~lsst.afw.math.Property`
    Statistics control type.
undersampleStyle : `str`
    Behavior if there are too few points in the grid for requested
    interpolation style.

Returns
-------
bkgd: `~lsst.afw.math.BackgroundMI`
    Background model of masked warp.
bgCtrl: `~lsst.afw.math.BackgroundControl`
    Background control object.

Definition at line 655 of file matchBackgrounds.py.

◆ matchBackgrounds()

matchBackgrounds ( self,
warps,
skyMap,
refVisitId )
Match science visit's background level to that of reference visit

Process creates binned images of the full focal plane (in tract
coordinates) for all visit IDs, subtracts each from a similarly
binned FFP reference image, then generates TractBackground
objects.

The TractBackground objects representing the difference image
backgrounds are then used to generate 'offset' images for each warp
comprising the full science exposure visit, which are then added to
each warp to match the background to that of the reference visit at the
warp's location within the tract.

Best practice uses `psf_matched_warp` images without the
detections mask plane set.  When using `direct_warp`, sources may bias
the difference image background estimation.  Mask planes are set in
TractBackgroundConfig.

Fit diagnostics are also calculated and returned.

Parameters
----------
warps : `list`[`~lsst.daf.butler.DeferredDatasetHandle`]
    List of warped exposures (of type `~lsst.afw.image.ExposureF`).
    This is ordered by patch ID, then by visit ID
skyMap : `lsst.skyMap.SkyMap`
   SkyMap for deriving the patch/tract dimensions.
refVisitId : `int`
    Chosen reference visit ID to match to.

Returns
-------
backgroundInfoList : `list`[`TractBackground`]
    List of all difference image backgrounds used to match to reference
    visit warps, in nanojanskies.
matchedImageList : `list`[`~lsst.afw.image.ExposureF`]
    List of all background-matched warps, in nanojanskies.

Definition at line 579 of file matchBackgrounds.py.

Variable Documentation

◆ _

lsst.pipe.tasks.matchBackgrounds._
protected

Definition at line 550 of file matchBackgrounds.py.

◆ array

lsst.pipe.tasks.matchBackgrounds.array

Definition at line 523 of file matchBackgrounds.py.

◆ bgModel

lsst.pipe.tasks.matchBackgrounds.bgModel

Definition at line 525 of file matchBackgrounds.py.

◆ bgModelBase

lsst.pipe.tasks.matchBackgrounds.bgModelBase

Definition at line 499 of file matchBackgrounds.py.

◆ bgModelImage

lsst.pipe.tasks.matchBackgrounds.bgModelImage

Definition at line 547 of file matchBackgrounds.py.

◆ bgModels

lsst.pipe.tasks.matchBackgrounds.bgModels

Definition at line 503 of file matchBackgrounds.py.

◆ bkgd

lsst.pipe.tasks.matchBackgrounds.bkgd

Definition at line 550 of file matchBackgrounds.py.

◆ bkgdImage

lsst.pipe.tasks.matchBackgrounds.bkgdImage

Definition at line 554 of file matchBackgrounds.py.

◆ config

lsst.pipe.tasks.matchBackgrounds.config : `MatchBackgroundsConfig`

Definition at line 398 of file matchBackgrounds.py.

◆ idx

lsst.pipe.tasks.matchBackgrounds.idx

Definition at line 518 of file matchBackgrounds.py.

◆ mse

lsst.pipe.tasks.matchBackgrounds.mse

Definition at line 561 of file matchBackgrounds.py.

◆ msg

lsst.pipe.tasks.matchBackgrounds.msg

Definition at line 505 of file matchBackgrounds.py.

◆ patchId

lsst.pipe.tasks.matchBackgrounds.patchId

Definition at line 514 of file matchBackgrounds.py.

◆ refPatches

lsst.pipe.tasks.matchBackgrounds.refPatches

Definition at line 497 of file matchBackgrounds.py.

◆ refWarp

lsst.pipe.tasks.matchBackgrounds.refWarp

Definition at line 519 of file matchBackgrounds.py.

◆ refWarpDDFs

lsst.pipe.tasks.matchBackgrounds.refWarpDDFs

Definition at line 496 of file matchBackgrounds.py.

◆ resids

lsst.pipe.tasks.matchBackgrounds.resids

Definition at line 559 of file matchBackgrounds.py.

◆ result

lsst.pipe.tasks.matchBackgrounds.result : `~lsst.afw.math.BackgroundList`, `~lsst.afw.image.Exposure`

Definition at line 443 of file matchBackgrounds.py.

◆ rms

lsst.pipe.tasks.matchBackgrounds.rms

Definition at line 560 of file matchBackgrounds.py.

◆ skyMap

lsst.pipe.tasks.matchBackgrounds.skyMap : `lsst.skyMap.SkyMap`

Definition at line 438 of file matchBackgrounds.py.

◆ statsCtrl

lsst.pipe.tasks.matchBackgrounds.statsCtrl : `~lsst.afw.math.StatisticsControl`

Definition at line 400 of file matchBackgrounds.py.

◆ visitTractDifferenceBackgrounds

lsst.pipe.tasks.matchBackgrounds.visitTractDifferenceBackgrounds

Definition at line 493 of file matchBackgrounds.py.

◆ visitWarpDDFs

lsst.pipe.tasks.matchBackgrounds.visitWarpDDFs

Definition at line 495 of file matchBackgrounds.py.

◆ warps

lsst.pipe.tasks.matchBackgrounds.warps : `list`[`~lsst.afw.image.Exposure`]
ConfigClass = MatchBackgroundsConfig
config: MatchBackgroundsConfig
_DefaultName = "matchBackgrounds"

def __init__(self, *args, **kwargs):
    super().__init__(**kwargs)
    # Fits on binned images only; masking controlled in tractBackground.py
    self.statsFlag = stringToStatisticsProperty(self.config.gridStatistic)
    self.statsCtrl = StatisticsControl()
    self.statsCtrl.setNanSafe(True)
    self.statsCtrl.setNumSigmaClip(self.config.numSigmaClip)
    self.statsCtrl.setNumIter(self.config.numIter)
    self.stringToInterpStyle = stringToInterpStyle(self.config.interpStyle)
    self.undersampleStyle = stringToUndersampleStyle(self.config.undersampleStyle)

    self.makeSubtask("reference")

@timeMethod
def run(self, warps, skyMap):
# TODO: include warped backgroundToPhotometricRatio correction
if (numExp := len(warps)) < 1:
    self.log.warning("No exposures found!  Returning empty lists.")
    return Struct(backgroundInfoList=[], matchedImageList=[])

if self.config.refWarpVisit is None:
    # Build FFP BG models of each visit
    visitTractBgs = self.reference._makeTractBackgrounds(warps, skyMap)
    # Choose a reference visit using those
    refVisId = self.reference._defineWarps(visitTractBgs)
else:
    self.log.info("Using user-supplied reference visit %d", self.config.refWarpVisit)
    refVisId = self.config.refWarpVisit

self.log.info("Matching %d Exposures", numExp)

backgroundInfoList, matchedImageList = self.matchBackgrounds(warps, skyMap, refVisId)

return Struct(backgroundInfoList=backgroundInfoList, matchedImageList=matchedImageList)

@timeMethod
def _makeTractDifferenceBackgrounds(self, warps, skyMap, refVisitId):

Definition at line 436 of file matchBackgrounds.py.

◆ workingWarp

lsst.pipe.tasks.matchBackgrounds.workingWarp

Definition at line 512 of file matchBackgrounds.py.