Exemple #1
0
    def testMockDiaPipelineTask(self):
        config = MockDiaPipelineTask.ConfigClass()
        config.apdb.db_url = "testing_only"
        task = MockDiaPipelineTask(config=config)
        pipelineTests.assertValidInitOutput(task)
        result = task.run(pandas.DataFrame(), pandas.DataFrame(),
                          afwImage.ExposureF(), afwImage.ExposureF(),
                          afwImage.ExposureF(), 42, 'k')
        pipelineTests.assertValidOutput(task, result)

        self.butler.put(pandas.DataFrame(), "deepDiff_diaSrcTable",
                        self.visitId)
        self.butler.put(pandas.DataFrame(), "visitSsObjects", self.visitId)
        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,
                "diffIm": self.visitId,
                "exposure": self.visitId,
                "template": self.visitId,
                "apdbMarker": self.visitId,
                "associatedDiaSources": self.visitId,
            })
        pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)
Exemple #2
0
    def testMockDetectAndMeasureTask(self):
        task = MockDetectAndMeasureTask()
        pipelineTests.assertValidInitOutput(task)
        result = task.run(
            science=afwImage.ExposureF(),
            matchedTemplate=afwImage.ExposureF(),
            difference=afwImage.ExposureF(),
            selectSources=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_differenceTempExp",
                        self.visitId)
        self.butler.put(afwTable.SourceCatalog(), "src", self.visitId)
        quantum = pipelineTests.makeQuantum(
            task, self.butler, self.visitId, {
                "science": self.visitId,
                "matchedTemplate": self.visitId,
                "difference": self.visitId,
                "selectSources": self.visitId,
                "diaSources": self.visitId,
                "subtractedMeasuredExposure": self.visitId,
            })
        pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)
Exemple #3
0
    def testMockGetTemplateTask(self):
        task = MockGetTemplateTask()
        pipelineTests.assertValidInitOutput(task)
        result = task.run(
            coaddExposures=[afwImage.ExposureF()],
            bbox=lsst.geom.Box2I(),
            wcs=None,  # Should not be allowed, but too hard to fake a SkyWcs
            dataIds=[],
        )
        pipelineTests.assertValidOutput(task, result)

        self.butler.put(afwImage.ExposureF(), "calexp", self.visitId)
        skymap = lsst.skymap.DiscreteSkyMap(lsst.skymap.DiscreteSkyMapConfig())
        self.butler.put(skymap,
                        lsst.skymap.BaseSkyMap.SKYMAP_DATASET_TYPE_NAME,
                        self.skymapId)
        self.butler.put(afwImage.ExposureF(), "goodSeeingCoadd", self.patchId)
        quantum = pipelineTests.makeQuantum(
            task, self.butler, self.skymapVisitId, {
                "bbox": self.visitId,
                "wcs": self.visitId,
                "skyMap": self.skymapId,
                "coaddExposures": [self.patchId],
                "template": self.visitId,
            })
        pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)
Exemple #4
0
    def testMockCalibrateTask(self):
        task = MockCalibrateTask()
        pipelineTests.assertValidInitOutput(task)
        # Even the real CalibrateTask won't pass assertValidOutput, because for
        # some reason the outputs are injected in runQuantum rather than run.

        self.butler.put(afwImage.ExposureF(), "icExp", self.visitId)
        self.butler.put(afwMath.BackgroundList(), "icExpBackground",
                        self.visitId)
        self.butler.put(afwTable.SourceCatalog(), "icSrc", self.visitId)
        self.butler.put(afwTable.SimpleCatalog(), "gaia_dr2_20200414",
                        self.htmId)
        self.butler.put(afwTable.SimpleCatalog(), "ps1_pv3_3pi_20170110",
                        self.htmId)
        quantum = pipelineTests.makeQuantum(
            task, self.butler, self.visitId, {
                "exposure": self.visitId,
                "background": self.visitId,
                "icSourceCat": self.visitId,
                "astromRefCat": [self.htmId],
                "photoRefCat": [self.htmId],
                "outputExposure": self.visitId,
                "outputCat": self.visitId,
                "outputBackground": self.visitId,
                "matches": self.visitId,
                "matchesDenormalized": self.visitId,
            })
        pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)
Exemple #5
0
    def testAssertValidInitOutputPass(self):
        task = VisitTask()
        # should not throw
        assertValidInitOutput(task)

        task = PatchTask()
        # should not throw
        assertValidInitOutput(task)
Exemple #6
0
 def testMockIsr(self):
     # Testing MockIsrTask is tricky because the real ISR has an unstable
     # interface with dozens of potential inputs, too many to pass through
     # runTestQuantum. I don't see a good way to test the inputs;
     # fortunately, this is unlikely to matter for the overall goal of
     # testing ap_verify's interaction with the AP pipeline.
     task = MockIsrTask()
     pipelineTests.assertValidInitOutput(task)
     result = task.run(afwImage.ExposureF())
     pipelineTests.assertValidOutput(task, result)
Exemple #7
0
    def testAssertValidInitOutputSingle(self):
        class BadVisitTask(VisitTask):
            def __init__(self, **kwargs):
                PipelineTask.__init__(self,
                                      **kwargs)  # Bypass VisitTask constructor
                self.initOut = butlerTests.MetricsExample(data=[1, 2])

        task = BadVisitTask()

        with self.assertRaises(AssertionError):
            assertValidInitOutput(task)
Exemple #8
0
    def testAssertValidInitOutputMissing(self):
        class BadVisitTask(VisitTask):
            def __init__(self, **kwargs):
                PipelineTask.__init__(self,
                                      **kwargs)  # Bypass VisitTask constructor
                pass  # do not set fields

        task = BadVisitTask()

        with self.assertRaises(AssertionError):
            assertValidInitOutput(task)
Exemple #9
0
    def testAssertValidInitOutputMultiple(self):
        class BadPatchTask(PatchTask):
            def __init__(self, **kwargs):
                PipelineTask.__init__(self,
                                      **kwargs)  # Bypass PatchTask constructor
                self.initOutA = [butlerTests.MetricsExample(data=[1, 2, 4])]
                self.initOutB = butlerTests.MetricsExample(data=[1, 2, 3])

        task = BadPatchTask()

        with self.assertRaises(AssertionError):
            assertValidInitOutput(task)
Exemple #10
0
    def testMockCharacterizeImageTask(self):
        task = MockCharacterizeImageTask()
        pipelineTests.assertValidInitOutput(task)
        result = task.run(afwImage.ExposureF())
        pipelineTests.assertValidOutput(task, result)

        self.butler.put(afwImage.ExposureF(), "postISRCCD", self.exposureId)
        quantum = pipelineTests.makeQuantum(
            task, self.butler, self.visitId, {
                "exposure": self.exposureId,
                "characterized": self.visitId,
                "sourceCat": self.visitId,
                "backgroundModel": self.visitId,
            })
        pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)
Exemple #11
0
    def testMockTransformDiaSourceCatalogTask(self):
        task = MockTransformDiaSourceCatalogTask(
            initInputs=afwTable.SourceCatalog())
        pipelineTests.assertValidInitOutput(task)
        result = task.run(afwTable.SourceCatalog(), afwImage.ExposureF(), 'k',
                          42)
        pipelineTests.assertValidOutput(task, result)

        self.butler.put(afwTable.SourceCatalog(), "deepDiff_diaSrc",
                        self.visitId)
        self.butler.put(afwImage.ExposureF(), "deepDiff_differenceExp",
                        self.visitId)
        quantum = pipelineTests.makeQuantum(
            task, self.butler, self.visitId, {
                "diaSourceCat": self.visitId,
                "diffIm": self.visitId,
                "diaSourceTable": self.visitId,
            })
        pipelineTests.runTestQuantum(task, self.butler, quantum, mockRun=False)
Exemple #12
0
    def testMockAlardLuptonSubtractTask(self):
        task = MockAlardLuptonSubtractTask()
        pipelineTests.assertValidInitOutput(task)
        result = task.run(afwImage.ExposureF(), afwImage.ExposureF(),
                          afwTable.SourceCatalog())
        pipelineTests.assertValidOutput(task, result)

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