Skip to content

Commit

Permalink
Merge pull request #667 from lsst/tickets/DM-34452
Browse files Browse the repository at this point in the history
DM-34452: Deprecate calibrate.doInsertFakes and remove gen2-only tests.
  • Loading branch information
erykoff committed Apr 16, 2022
2 parents 1f2df39 + 4394a2d commit 9a336e4
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 333 deletions.
49 changes: 6 additions & 43 deletions python/lsst/pipe/tasks/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -286,12 +286,16 @@ class CalibrateConfig(pipeBase.PipelineTaskConfig, pipelineConnections=Calibrate
doInsertFakes = pexConfig.Field(
dtype=bool,
default=False,
doc="Run fake sources injection task"
doc="Run fake sources injection task",
deprecated=("doInsertFakes is no longer supported. This config will be removed after v24. "
"Please use ProcessCcdWithFakesTask instead.")
)
insertFakes = pexConfig.ConfigurableField(
target=BaseFakeSourcesTask,
doc="Injection of fake sources for testing purposes (must be "
"retargeted)"
"retargeted)",
deprecated=("insertFakes is no longer supported. This config will be removed after v24. "
"Please use ProcessCcdWithFakesTask instead.")
)
doComputeSummaryStats = pexConfig.Field(
dtype=bool,
Expand Down Expand Up @@ -511,12 +515,6 @@ def __init__(self, butler=None, astromRefObjLoader=None,

self.algMetadata = dafBase.PropertyList()

# Only create a subtask for fakes if configuration option is set
# N.B. the config for fake object task must be retargeted to a child
# of BaseFakeSourcesTask
if self.config.doInsertFakes:
self.makeSubtask("insertFakes")

if self.config.doDeblend:
self.makeSubtask("deblend", schema=self.schema)
if self.config.doSkySources:
Expand Down Expand Up @@ -776,41 +774,6 @@ def run(self, exposure, exposureIdInfo=None, background=None,
exposureId=exposureIdInfo.expId
)

if self.config.doInsertFakes:
self.insertFakes.run(exposure, background=background)

table = SourceTable.make(self.schema, sourceIdFactory)
table.setMetadata(self.algMetadata)

detRes = self.detection.run(table=table, exposure=exposure,
doSmooth=True)
sourceCat = detRes.sources
if detRes.fpSets.background:
for bg in detRes.fpSets.background:
background.append(bg)
if self.config.doDeblend:
self.deblend.run(exposure=exposure, sources=sourceCat)
self.measurement.run(
measCat=sourceCat,
exposure=exposure,
exposureId=exposureIdInfo.expId
)
self.postCalibrationMeasurement.run(
measCat=sourceCat,
exposure=exposure,
exposureId=exposureIdInfo.expId
)
if self.config.doApCorr:
self.applyApCorr.run(
catalog=sourceCat,
apCorrMap=exposure.getInfo().getApCorrMap()
)
self.catalogCalculation.run(sourceCat)

if icSourceCat is not None and len(self.config.icSourceFieldsToCopy) > 0:
self.copyIcSourceFields(icSourceCat=icSourceCat,
sourceCat=sourceCat)

if self.config.doComputeSummaryStats:
summary = self.computeSummaryStats.run(exposure=exposure,
sources=sourceCat,
Expand Down
6 changes: 6 additions & 0 deletions python/lsst/pipe/tasks/fakes.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
#
import abc

from deprecated.sphinx import deprecated

import lsst.pex.config
import lsst.pipe.base
import lsst.afw.image
Expand All @@ -33,6 +35,10 @@ class BaseFakeSourcesConfig(lsst.pex.config.Config):
)


@deprecated(reason=("The fakes code has been deprecated in favor of ProcessCcdWithFakes. "
"This will be removed after v24."),
category=FutureWarning,
version="24.0")
class BaseFakeSourcesTask(lsst.pipe.base.Task, metaclass=abc.ABCMeta):
"""An abstract base class for subtasks that inject fake sources into images to test completeness and
other aspects of the processing.
Expand Down
14 changes: 7 additions & 7 deletions python/lsst/pipe/tasks/multiBand.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,18 @@ class DetectCoaddSourcesConfig(PipelineTaskConfig, pipelineConnections=DetectCoa
detection = ConfigurableField(target=DynamicDetectionTask, doc="Source detection")
coaddName = Field(dtype=str, default="deep", doc="Name of coadd")
doInsertFakes = Field(dtype=bool, default=False,
doc="Run fake sources injection task")
doc="Run fake sources injection task",
deprecated=("doInsertFakes is no longer supported. This config will be removed "
"after v24."))
insertFakes = ConfigurableField(target=BaseFakeSourcesTask,
doc="Injection of fake sources for testing "
"purposes (must be retargeted)")
"purposes (must be retargeted)",
deprecated=("insertFakes is no longer supported. This config will "
"be removed after v24."))
hasFakes = Field(
dtype=bool,
default=False,
doc="Should be set to True if fake sources have been inserted into the input data."
doc="Should be set to True if fake sources have been inserted into the input data.",
)

def setDefaults(self):
Expand Down Expand Up @@ -262,8 +266,6 @@ def __init__(self, schema=None, **kwargs):
super().__init__(**kwargs)
if schema is None:
schema = afwTable.SourceTable.makeMinimalSchema()
if self.config.doInsertFakes:
self.makeSubtask("insertFakes")
self.schema = schema
self.makeSubtask("detection", schema=self.schema)
if self.config.doScaleVariance:
Expand Down Expand Up @@ -318,8 +320,6 @@ def run(self, exposure, idFactory, expId):
varScale = self.scaleVariance.run(exposure.maskedImage)
exposure.getMetadata().add("VARIANCE_SCALE", varScale)
backgrounds = afwMath.BackgroundList()
if self.config.doInsertFakes:
self.insertFakes.run(exposure, background=backgrounds)
table = afwTable.SourceTable.make(self.schema, idFactory)
detections = self.detection.run(table, exposure, expId=expId)
sources = detections.sources
Expand Down
2 changes: 0 additions & 2 deletions tests/test_calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@
# along with this program. If not, see <https://www.gnu.org/licenses/>.

"""Test ProcessCcdTask and its immediate subtasks.
Run the task on one obs_test image and perform various checks on the results
"""
import shutil
import tempfile
Expand Down
191 changes: 0 additions & 191 deletions tests/test_fakeProcessing.py

This file was deleted.

0 comments on commit 9a336e4

Please sign in to comment.