Skip to content

Commit

Permalink
Update code for new SubtractBackgroundTask
Browse files Browse the repository at this point in the history
lsst.meas.algorithms.SubtractBackgroundTask replaces getBackground
and SubtractBackgroundTask replaces BackgroundConfig
  • Loading branch information
r-owen committed May 4, 2016
1 parent 248d50c commit 26a0fd0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 6 additions & 2 deletions python/lsst/ip/diffim/imagePsfMatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import lsst.afw.geom as afwGeom
import lsst.afw.table as afwTable
import lsst.pipe.base as pipeBase
from lsst.meas.algorithms import SourceDetectionTask, getBackground
from lsst.meas.algorithms import SourceDetectionTask, SubtractBackgroundTask
from lsst.meas.base import SingleFrameMeasurementTask
from .makeKernelBasisList import makeKernelBasisList
from .psfMatch import PsfMatchTask, PsfMatchConfigDF, PsfMatchConfigAL
Expand Down Expand Up @@ -281,6 +281,10 @@ def __init__(self, *args, **kwargs):
PsfMatchTask.__init__(self, *args, **kwargs)
self.kConfig = self.config.kernel.active
self._warper = afwMath.Warper.fromConfig(self.kConfig.warpingConfig)
# the background subtraction task uses a config from an unusual location,
# so cannot easily be constructed with makeSubtask
self.background = SubtractBackgroundTask(config=self.kConfig.afwBackgroundConfig, name="background",
parentTask=self)
self.selectSchema = afwTable.SourceTable.makeMinimalSchema()
self.selectAlgMetadata = dafBase.PropertyList()
self.makeSubtask("selectDetection", schema=self.selectSchema)
Expand Down Expand Up @@ -635,7 +639,7 @@ def getSelectSources(self, exposure, sigma=None, doSmooth=True, idFactory=None):
maskArr = mi.getMask().getArray()
miArr = np.ma.masked_array(imArr, mask=maskArr)
try:
bkgd = getBackground(mi, self.kConfig.afwBackgroundConfig).getImageF()
bkgd = self.background.fitBackground(mi).getImageF()
except Exception:
self.log.warn("Failed to get background model. Falling back to median background estimation")
bkgd = np.ma.extras.median(miArr)
Expand Down
4 changes: 2 additions & 2 deletions python/lsst/ip/diffim/psfMatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
import lsst.afw.math as afwMath
import lsst.afw.display.ds9 as ds9
import lsst.pipe.base as pipeBase
from lsst.meas.algorithms.detection import BackgroundConfig
from lsst.meas.algorithms import SubtractBackgroundConfig
from . import utils as diUtils
from . import diffimLib

Expand Down Expand Up @@ -122,7 +122,7 @@ class PsfMatchConfig(pexConfig.Config):
detectionConfig = pexConfig.ConfigField("Controlling the detection of sources for kernel building",
DetectionConfig)
afwBackgroundConfig = pexConfig.ConfigField("Controlling the Afw background fitting",
BackgroundConfig)
SubtractBackgroundConfig)

useAfwBackground = pexConfig.Field(
dtype = bool,
Expand Down

0 comments on commit 26a0fd0

Please sign in to comment.