Пример #1
0
    def testUniqueButler(self):
        dataId = {"instrument": "notACam"}
        self.butler.put(MetricsExample({
            "answer": 42,
            "question": "unknown"
        }), "DataType1", dataId)
        self.assertTrue(self.butler.datasetExists("DataType1", dataId))

        newButler = makeTestCollection(self.creatorButler)
        with self.assertRaises(LookupError):
            newButler.datasetExists("DataType1", dataId)
Пример #2
0
    def _prepareQuantum(self, task):
        inputId = {
            "instrument": self.CAMERA_ID,
            "visit": self.VISIT_ID,
            "detector": self.CHIP_ID,
        }

        butler = butlerTests.makeTestCollection(self.repo)
        # task.config not persistable if it refers to a local class
        # We don't actually use the persisted config, so just make a new one
        info = task.ConfigClass()
        butler.put(info, "apdb_marker", inputId)

        quantum = testUtils.makeQuantum(task, butler, inputId, {
            "dbInfo": [inputId],
            "measurement": inputId
        })

        return (butler, quantum, info)
Пример #3
0
    def setUp(self):
        super().setUp()
        self.butler = butlerTests.makeTestCollection(self.repo)

        self.dataId = {"instrument": "notACam", "visit": 101, "detector": 42}
        # CalibrateTask absolutely requires an ExpandedDataCoordinate
        self.dataId = self.butler.registry.expandDataId(self.dataId)
        self.refcatId = {"htm7": 189584}

        # Tests do no processing, so we don't need real data
        self.exposure = lsst.afw.image.ExposureF(10, 10)
        background = lsst.afw.math.BackgroundMI(self.exposure.getBBox(),
                                                self.exposure.getMaskedImage())
        self.backgroundlist = lsst.afw.math.BackgroundList(
            (background, lsst.afw.math.Interpolate.UNKNOWN,
             lsst.afw.math.UndersampleStyle.THROW_EXCEPTION,
             lsst.afw.math.ApproximateControl.UNKNOWN, 0, 0, 1))
        self.icSrc = lsst.afw.table.SourceCatalog()
        self.refcat = lsst.afw.table.SimpleCatalog()

        self.butler.put(self.exposure, "icExp", self.dataId)
        self.butler.put(self.backgroundlist, "icExpBackground", self.dataId)
        self.butler.put(self.icSrc, "icSrc", self.dataId)
        self.butler.put(self.refcat, "cal_ref_cat", self.refcatId)
Пример #4
0
 def setUp(self):
     self.butler = makeTestCollection(self.creatorButler)
Пример #5
0
 def setUp(self):
     super().setUp()
     self.butler = butlerTests.makeTestCollection(self.repo,
                                                  uniqueId=self.id())
Пример #6
0
 def setUp(self):
     super().setUp()
     self.butler = butlerTests.makeTestCollection(self.repo)
Пример #7
0
    def testRunQuantum(self):
        """Test the run quantum method with a gen3 butler.
        """
        root = tempfile.mkdtemp()
        dimensions = {
            "instrument": ["notACam"],
            "skymap": ["deepCoadd_skyMap"],
            "tract": [0, 42],
            "visit": [1234, 4321],
            "detector": [25, 26]
        }
        testRepo = butlerTests.makeTestRepo(root, dimensions)
        matchTask = MatchApFakesTask()
        connections = matchTask.config.ConnectionsClass(
            config=matchTask.config)

        dataId = {
            "instrument": "notACam",
            "skymap": "deepCoadd_skyMap",
            "tract": 0,
            "visit": 1234,
            "detector": 25
        }
        butlerTests.addDatasetType(testRepo, connections.fakeCat.name,
                                   connections.fakeCat.dimensions,
                                   connections.fakeCat.storageClass)
        butlerTests.addDatasetType(testRepo, connections.diffIm.name,
                                   connections.diffIm.dimensions,
                                   connections.diffIm.storageClass)
        butlerTests.addDatasetType(
            testRepo, connections.associatedDiaSources.name,
            connections.associatedDiaSources.dimensions,
            connections.associatedDiaSources.storageClass)
        butlerTests.addDatasetType(testRepo,
                                   connections.matchedDiaSources.name,
                                   connections.matchedDiaSources.dimensions,
                                   connections.matchedDiaSources.storageClass)
        butler = butlerTests.makeTestCollection(testRepo)

        butler.put(self.fakeCat, connections.fakeCat.name, {
            "tract": dataId["tract"],
            "skymap": dataId["skymap"]
        })
        butler.put(
            self.exposure, connections.diffIm.name, {
                "instrument": dataId["instrument"],
                "visit": dataId["visit"],
                "detector": dataId["detector"]
            })
        butler.put(
            self.sourceCat, connections.associatedDiaSources.name, {
                "instrument": dataId["instrument"],
                "visit": dataId["visit"],
                "detector": dataId["detector"]
            })

        quantum = testUtils.makeQuantum(
            matchTask, butler, dataId, {
                key: dataId
                for key in {
                    "fakeCat", "diffIm", "associatedDiaSources",
                    "matchedDiaSources"
                }
            })
        run = testUtils.runTestQuantum(matchTask, butler, quantum)
        # Actual input dataset omitted for simplicity
        run.assert_called_once()
        shutil.rmtree(root, ignore_errors=True)
Пример #8
0
    def setUp(self):
        self.butler = butlerTests.makeTestCollection(self.creatorButler)

        self.config = DefineVisitsTask.ConfigClass()
        self.config.computeVisitRegions.active.padding = 42  # non-default value
        self.task = DefineVisitsTask(config=self.config, butler=self.butler)
Пример #9
0
    def setUp(self):
        self.butler = butlerTests.makeTestCollection(self.creatorButler)

        self.config = RawIngestTask.ConfigClass()
        self.config.transfer = "copy"  # safe non-default value
        self.task = RawIngestTask(config=self.config, butler=self.butler)
Пример #10
0
 def setUp(self):
     # TestCase.id() is unique for each test method
     self.butler = makeTestCollection(self.creatorButler, uniqueId=self.id())