Exemple #1
0
    def testRunRegularToo(self):
        """
        Test that a binned slicer and a regular slicer can run together
        """
        bundleList = []
        metric = metrics.AccumulateM5Metric(bins=[0.5, 1.5, 2.5])
        slicer = slicers.HealpixSlicer(nside=16)
        sql = ''
        bundleList.append(metricBundle.MetricBundle(metric, slicer, sql))
        metric = metrics.Coaddm5Metric()
        slicer = slicers.HealpixSlicer(nside=16)
        bundleList.append(metricBundle.MetricBundle(metric, slicer, sql))
        bd = metricBundle.makeBundlesDictFromList(bundleList)
        mbg = metricBundle.MetricBundleGroup(bd, None, saveEarly=False)
        mbg.setCurrent('')
        mbg.runCurrent('', simData=self.simData)

        assert (np.array_equal(bundleList[0].metricValues[:, 1].compressed(),
                               bundleList[1].metricValues.compressed()))
    def testAccumulateM5Metric(self):
        metric = metrics.AccumulateM5Metric(bins=[0.5, 1.5, 2.5])
        slicer = slicers.HealpixSlicer(nside=16)
        sql = ''
        mb = metricBundle.MetricBundle(metric, slicer, sql)
        mbg = metricBundle.MetricBundleGroup({0: mb}, None, saveEarly=False)
        mbg.setCurrent('')
        mbg.runCurrent('', simData=self.simData)
        good = np.where(mb.metricValues.mask[:, -1] == False)[0]

        checkMetric = metrics.Coaddm5Metric()
        tempSlice = np.zeros(self.n1, dtype=zip(['fiveSigmaDepth'], [float]))
        tempSlice['fiveSigmaDepth'] += self.m5_1
        val1 = checkMetric.run(tempSlice)
        tempSlice = np.zeros(self.n2, dtype=zip(['fiveSigmaDepth'], [float]))
        tempSlice['fiveSigmaDepth'] += self.m5_2
        val2 = checkMetric.run(tempSlice)

        expected = np.array([[val1, val1], [-666., val2]])
        assert (np.array_equal(mb.metricValues.data[good, :], expected))