Skip to content

Commit

Permalink
Added logic for MPSkyEphemerisQueryTask
Browse files Browse the repository at this point in the history
  • Loading branch information
Gerenjie committed Jul 26, 2024
1 parent c43806f commit 9ae80ca
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 5 deletions.
16 changes: 16 additions & 0 deletions doc/lsst.ap.verify/request.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
.. py:currentmodule:: lsst.ap.verify
.. program:: ap_verify.py

.. _ap-verify-request:

########################################
mpSkyEphemerisQueryTask external request
########################################

mpSkyEphemerisQueryTask
=======================
``ap_verify`` now runs mpSkyEphemerisQuery, which includes a request to mpSky.
mpSky is not expected to host ephemerides for all test datasets, so it will
often (or always) fail. When requests fail, mpSkyEphemerisQuery should return
an empty DataFrame, and no detections will be associated.
13 changes: 12 additions & 1 deletion python/lsst/ap/verify/testPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@
import lsst.afw.math as afwMath
import lsst.afw.table as afwTable
from lsst.ap.association import (TransformDiaSourceCatalogConfig,
DiaPipelineConfig, FilterDiaSourceCatalogConfig)
DiaPipelineConfig, FilterDiaSourceCatalogConfig,
MPSkyEphemerisQueryConfig)
from lsst.pipe.base import PipelineTask, Struct
from lsst.ip.isr import IsrTaskConfig
from lsst.ip.diffim import (GetTemplateConfig, AlardLuptonSubtractConfig,
Expand Down Expand Up @@ -517,6 +518,16 @@ def run(self, template, science, difference, diaSources, pretrainedModel=None):
return Struct(classifications=afwTable.BaseCatalog(afwTable.Schema()))


class MockMPSkyEphemerisQueryTask(PipelineTask):
"""A do-nothing substitute for MPSkyEphemerisQueryTask.
"""
_DefaultName = "notMPSkyEphemerisQuery"
ConfigClass = MPSkyEphemerisQueryConfig

def run(self, predictedRegionTime):
return Struct(ssObjects=pandas.DataFrame())


class MockTransformDiaSourceCatalogTask(PipelineTask):
"""A do-nothing substitute for TransformDiaSourceCatalogTask.
"""
Expand Down
36 changes: 32 additions & 4 deletions tests/test_testPipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,10 @@
MockCalibrateTask, MockGetTemplateTask, \
MockAlardLuptonSubtractTask, MockDetectAndMeasureTask, MockTransformDiaSourceCatalogTask, \
MockRBTransiNetTask, MockDiaPipelineTask, MockFilterDiaSourceCatalogTask, \
MockSpatiallySampledMetricsTask
MockSpatiallySampledMetricsTask, MockMPSkyEphemerisQueryTask
from lsst.daf.butler import Timespan
from lsst.sphgeom import Circle
from lsst.pipe.base.utils import RegionTimeInfo


class MockTaskTestSuite(unittest.TestCase):
Expand All @@ -53,7 +56,6 @@ class MockTaskTestSuite(unittest.TestCase):
@classmethod
def setUpClass(cls):
super().setUpClass()

repoDir = tempfile.mkdtemp()
cls.addClassCleanup(shutil.rmtree, repoDir, ignore_errors=True)
cls.repo = butlerTests.makeTestRepo(repoDir)
Expand All @@ -73,11 +75,17 @@ def setUpClass(cls):
name=INSTRUMENT, visit_max=256, exposure_max=256, detector_max=128,
class_name="lsst.obs.base.instrument_tests.DummyCam",
)
# groupRecord = cls.repo.dimensions["group"].RecordClass(
# name=VISIT, instrument=INSTRUMENT,
# class_name="lsst.obs.base.instrument_tests.DummyCam",
# )

cls.repo.registry.syncDimensionData("instrument", instrumentRecord)
butlerTests.addDataIdValue(cls.repo, "physical_filter", PHYSICAL, band=BAND)
butlerTests.addDataIdValue(cls.repo, "subfilter", SUB_FILTER)
butlerTests.addDataIdValue(cls.repo, "exposure", VISIT)
butlerTests.addDataIdValue(cls.repo, "visit", VISIT)
butlerTests.addDataIdValue(cls.repo, "group", VISIT)
butlerTests.addDataIdValue(cls.repo, "detector", CCD)
butlerTests.addDataIdValue(cls.repo, "skymap", SKYMAP)
butlerTests.addDataIdValue(cls.repo, "tract", TRACT)
Expand All @@ -88,6 +96,8 @@ def setUpClass(cls):
{"instrument": INSTRUMENT, "exposure": VISIT, "detector": CCD})
cls.visitId = cls.repo.registry.expandDataId(
{"instrument": INSTRUMENT, "visit": VISIT, "detector": CCD})
cls.groupId = cls.repo.registry.expandDataId(
{"instrument": INSTRUMENT, "group": VISIT, "detector": CCD})
cls.visitOnlyId = cls.repo.registry.expandDataId(
{"instrument": INSTRUMENT, "visit": VISIT})
cls.skymapId = cls.repo.registry.expandDataId({"skymap": SKYMAP})
Expand Down Expand Up @@ -129,6 +139,8 @@ def setUpClass(cls):
butlerTests.addDatasetType(cls.repo, "deepDiff_candidateDiaSrc", cls.visitId.dimensions,
"SourceCatalog")
butlerTests.addDatasetType(cls.repo, "visitSsObjects", cls.visitOnlyId.dimensions, "DataFrame")
butlerTests.addDatasetType(cls.repo, "preloaded_ssObjects", cls.groupId.dimensions, "DataFrame")
butlerTests.addDatasetType(cls.repo, "regionTimeInfo", cls.groupId.dimensions, "RegionTimeInfo")
butlerTests.addDatasetType(cls.repo, "apdb_marker", cls.visitId.dimensions, "Config")
butlerTests.addDatasetType(cls.repo, "deepDiff_assocDiaSrc", cls.visitId.dimensions, "DataFrame")
butlerTests.addDatasetType(cls.repo, "deepDiff_longTrailedSrc", cls.visitId.dimensions,
Expand Down Expand Up @@ -220,6 +232,7 @@ def testMockGetTemplateTask(self):
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

def testMockAlardLuptonSubtractTask(self):

task = MockAlardLuptonSubtractTask()
pipelineTests.assertValidInitOutput(task)
result = task.run(afwImage.ExposureF(), afwImage.ExposureF(), afwTable.SourceCatalog())
Expand Down Expand Up @@ -324,6 +337,21 @@ def testMockRBTransiNetTask(self):
})
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

def testMockMPSkyEphemerisQueryTask(self):
task = MockMPSkyEphemerisQueryTask()
pipelineTests.assertValidInitOutput(task)
dummyRegionTimeInfo = RegionTimeInfo(timespan=Timespan.makeEmpty(), region=Circle())
result = task.run(predictedRegionTime=dummyRegionTimeInfo)
pipelineTests.assertValidOutput(task, result)

self.butler.put(dummyRegionTimeInfo, "regionTimeInfo", self.groupId)
quantum = pipelineTests.makeQuantum(
task, self.butler, self.groupId,
{"predictedRegionTime": self.groupId,
"ssObjects": self.groupId,
})
pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)

def testMockTransformDiaSourceCatalogTask(self):
task = MockTransformDiaSourceCatalogTask(initInputs=afwTable.SourceCatalog())
pipelineTests.assertValidInitOutput(task)
Expand Down Expand Up @@ -351,14 +379,14 @@ def testMockDiaPipelineTask(self):
pipelineTests.assertValidOutput(task, result)

self.butler.put(pandas.DataFrame(), "deepDiff_diaSrcTable", self.visitId)
self.butler.put(pandas.DataFrame(), "visitSsObjects", self.visitId)
self.butler.put(pandas.DataFrame(), "preloaded_ssObjects", self.groupId)
self.butler.put(afwImage.ExposureF(), "deepDiff_differenceExp", self.visitId)
self.butler.put(afwImage.ExposureF(), "calexp", self.visitId)
self.butler.put(afwImage.ExposureF(), "deepDiff_templateExp", self.visitId)
quantum = pipelineTests.makeQuantum(
task, self.butler, self.visitId,
{"diaSourceTable": self.visitId,
"solarSystemObjectTable": self.visitId,
"solarSystemObjectTable": self.visitOnlyId,
"diffIm": self.visitId,
"exposure": self.visitId,
"template": self.visitId,
Expand Down

0 comments on commit 9ae80ca

Please sign in to comment.