Skip to content

Commit

Permalink
makeCoaddTempExp: add code to apply sky correction
Browse files Browse the repository at this point in the history
Sky corrections can be generating with the 'skyCorrection.py'
executable in pipe_drivers. Because the sky model used by that code
extends over the entire focal plane, this can produce better sky
subtraction.
  • Loading branch information
PaulPrice committed Nov 6, 2017
1 parent ffd72dd commit 40f2edc
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions python/lsst/pipe/tasks/makeCoaddTempExp.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ class MakeCoaddTempExpConfig(CoaddBaseTask.ConfigClass):
dtype=bool,
default=False,
)
doApplySkyCorr = pexConfig.Field(dtype=bool, default=False, doc="Apply sky correction?")

def validate(self):
CoaddBaseTask.ConfigClass.validate(self)
Expand Down Expand Up @@ -368,6 +369,10 @@ def createTempExp(self, calexpRefList, skyInfo, visitId=0):
except Exception as e:
self.log.warn("Calexp %s not found; skipping it: %s", calExpRef.dataId, e)
continue

if self.config.doApplySkyCorr:
self.applySkyCorr(calExpRef, calExp)

try:
warpedAndMatched = self.warpAndPsfMatch.run(calExp, modelPsf=modelPsf,
wcs=skyInfo.wcs, maxBBox=skyInfo.bbox,
Expand Down Expand Up @@ -441,3 +446,25 @@ def getWarpTypeList(self):
if self.config.makePsfMatched:
warpTypeList.append("psfMatched")
return warpTypeList

def applySkyCorr(self, dataRef, calexp):
"""Apply correction to the sky background level
Sky corrections can be generated with the 'skyCorrection.py'
executable in pipe_drivers. Because the sky model used by that
code extends over the entire focal plane, this can produce
better sky subtraction.
The calexp is updated in-place.
Parameters
----------
dataRef : `lsst.daf.persistence.ButlerDataRef`
Data reference for calexp.
calexp : `lsst.afw.image.Exposure` or `lsst.afw.image.MaskedImage`
Calibrated exposure.
"""
bg = dataRef.get("skyCorr")
if isinstance(calexp, afwImage.Exposure):
calexp = calexp.getMaskedImage()
calexp -= bg.getImage()

0 comments on commit 40f2edc

Please sign in to comment.