Skip to content

Commit

Permalink
Adding tests to reflect the new spatially sampled metric
Browse files Browse the repository at this point in the history
  • Loading branch information
BrunoSanchez authored and isullivan committed Apr 16, 2024
1 parent 50eb43f commit a9a37a0
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 4 deletions.
37 changes: 35 additions & 2 deletions python/lsst/ap/verify/testPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
DiaPipelineConfig, FilterDiaSourceCatalogConfig)
from lsst.pipe.base import PipelineTask, Struct
from lsst.ip.isr import IsrTaskConfig
from lsst.ip.diffim import GetTemplateConfig, AlardLuptonSubtractConfig, DetectAndMeasureConfig
from lsst.ip.diffim import (GetTemplateConfig, AlardLuptonSubtractConfig,

Check failure on line 41 in python/lsst/ap/verify/testPipeline.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W291

trailing whitespace
DetectAndMeasureConfig, SpatiallySampledMetricsConfig)
from lsst.pipe.tasks.characterizeImage import CharacterizeImageConfig
from lsst.pipe.tasks.calibrate import CalibrateConfig
from lsst.meas.transiNet import RBTransiNetConfig
Expand Down Expand Up @@ -432,7 +433,6 @@ def run(self, science, matchedTemplate, difference,
"""
return Struct(subtractedMeasuredExposure=difference,
diaSources=afwTable.SourceCatalog(),
spatiallySampledMetrics=astropy.table.Table(),
)


Expand Down Expand Up @@ -460,6 +460,39 @@ def run(self, diaSourceCat):
)


class MockSpatiallySampledMetricsTask(PipelineTask):
"""A do-nothing substitute for SpatiallySampledMetricsTask.
"""
ConfigClass = SpatiallySampledMetricsConfig
_DefaultName = "notSpatiallySampledMetricsTask"

def run(self, science, matchedTemplate, template, difference, diaSources):
"""Produce spatially sampled metrics
Parameters
----------
science : `lsst.afw.image.ExposureF`
Science exposure that the template was subtracted from.
matchedTemplate : `lsst.afw.image.ExposureF`
Warped and PSF-matched template that was used produce the
difference image.
template : `lsst.afw.image.ExposureF`
Warped and non PSF-matched template that was used produce

Check failure on line 480 in python/lsst/ap/verify/testPipeline.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W291

trailing whitespace
the difference image.
difference : `lsst.afw.image.ExposureF`
Result of subtracting template from the science image.
diaSources : `lsst.afw.table.SourceCatalog`
The catalog of detected sources.
Returns
-------
results : `lsst.pipe.base.Struct`
Results struct with components.
"""

return Struct(spatiallySampledMetrics=astropy.table.Table())


class MockRBTransiNetTask(PipelineTask):
"""A do-nothing substitute for RBTransiNetTask.
"""
Expand Down
31 changes: 29 additions & 2 deletions tests/test_testPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@
from lsst.ap.verify.testPipeline import MockIsrTask, MockCharacterizeImageTask, \
MockCalibrateTask, MockGetTemplateTask, \
MockAlardLuptonSubtractTask, MockDetectAndMeasureTask, MockTransformDiaSourceCatalogTask, \
MockRBTransiNetTask, MockDiaPipelineTask, MockFilterDiaSourceCatalogTask
MockRBTransiNetTask, MockDiaPipelineTask, MockFilterDiaSourceCatalogTask, \
MockSpatiallySampledMetricsTask


class MockTaskTestSuite(unittest.TestCase):
Expand Down Expand Up @@ -254,7 +255,6 @@ def testMockDetectAndMeasureTask(self):
"difference": self.visitId,
"diaSources": self.visitId,
"subtractedMeasuredExposure": self.visitId,
"spatiallySampledMetrics": self.visitId,
})
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

Expand All @@ -264,6 +264,33 @@ def testMockFilterDiaSourceCatalogTask(self):
result = task.run(afwTable.SourceCatalog())
pipelineTests.assertValidOutput(task, result)

def testMockSpatiallySampledMetricsTask(self):
task = MockSpatiallySampledMetricsTask()
result = task.run(
afwImage.ExposureF(),

Check failure on line 270 in tests/test_testPipeline.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W291

trailing whitespace
afwImage.ExposureF(),

Check failure on line 271 in tests/test_testPipeline.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W291

trailing whitespace
afwImage.ExposureF(),

Check failure on line 272 in tests/test_testPipeline.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W291

trailing whitespace
afwImage.ExposureF(),

Check failure on line 273 in tests/test_testPipeline.py

View workflow job for this annotation

GitHub Actions / call-workflow / lint

W291

trailing whitespace
afwTable.SourceCatalog()
)
pipelineTests.assertValidOutput(task, result)

self.butler.put(afwImage.ExposureF(), "calexp", self.visitId)
self.butler.put(afwImage.ExposureF(), "deepDiff_matchedExp", self.visitId)
self.butler.put(afwImage.ExposureF(), "deepDiff_templateExp", self.visitId)
self.butler.put(afwImage.ExposureF(), "deepDiff_differenceExp", self.visitId)
self.butler.put(afwTable.SourceCatalog(), "deepDiff_candidateDiaSrc", self.visitId)
quantum = pipelineTests.makeQuantum(
task, self.butler, self.visitId,
{"science": self.visitId,
"matchedTemplate": self.visitId,
"template": self.visitId,
"difference": self.visitId,
"diaSources": self.visitId,
"spatiallySampledMetrics": self.visitId,
})
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

def testMockRBTransiNetTask(self):
task = MockRBTransiNetTask()
pipelineTests.assertValidInitOutput(task)
Expand Down

0 comments on commit a9a37a0

Please sign in to comment.