示例#1
0
    def run(dataset, correlation_radius, sigma, negative):
        estimator_excess = ExcessMapEstimator(
            correlation_radius=correlation_radius,
            n_sigma=1, 
            n_sigma_ul=3,
            selection_optional=None,
            energy_edges=energy_edges, 
        )
        result = estimator_excess.run(dataset)
        
        sources = find_peaks(
            result["sqrt_ts"],
            threshold=sigma,
            min_distance=correlation_radius,
        )
        if negative is True:
            result["sqrt_ts"].data = -result["sqrt_ts"].data
            sources.vstack(
                find_peaks(
                        result["sqrt_ts"],
                        threshold=sigma,
                        min_distance=correlation_radius,
                )
            )

        regions = []
        for source in sources:
            skydir = SkyCoord(source["ra"], source["dec"], unit="deg", frame="icrs")
            if dataset.counts.geom.to_image().contains(skydir):
                regions.append(CircleSkyRegion(skydir, 0.2 * u.deg))
        return dataset.counts.geom.to_image().region_mask(regions=regions, inside=False), result
示例#2
0
    def test_simple(self):
        """Test a simple example"""
        image = Map.create(npix=(10, 5), unit="s")
        image.data[3, 3] = 11
        image.data[3, 4] = 10
        image.data[3, 5] = 12
        image.data[3, 6] = np.nan
        image.data[0, 9] = 1e20

        table = find_peaks(image, threshold=3)

        assert len(table) == 3
        assert table["value"].unit == "s"
        assert table["ra"].unit == "deg"
        assert table["dec"].unit == "deg"

        row = table[0]
        assert tuple((row["x"], row["y"])) == (9, 0)
        assert_allclose(row["value"], 1e20)
        assert_allclose(row["ra"], 359.55)
        assert_allclose(row["dec"], -0.2)

        row = table[1]
        assert tuple((row["x"], row["y"])) == (5, 3)
        assert_allclose(row["value"], 12)
示例#3
0
    def test_flat_map(self):
        """Test a simple example"""
        axis1 = MapAxis.from_edges([1, 2], name="axis1")
        axis2 = MapAxis.from_edges([9, 10], name="axis2")
        image = Map.create(npix=(10, 5), unit="s", axes=[axis1, axis2])
        image.data[..., 3, 3] = 11
        image.data[..., 3, 4] = 10
        image.data[..., 3, 5] = 12
        image.data[..., 3, 6] = np.nan
        image.data[..., 0, 9] = 1e20

        table = find_peaks(image, threshold=3)
        row = table[0]

        assert len(table) == 3
        assert_allclose(row["value"], 1e20)
        assert_allclose(row["ra"], 359.55)
        assert_allclose(row["dec"], -0.2)
示例#4
0
    def test_constant(self):
        image = Map.create(npix=(10, 5))

        table = find_peaks(image, threshold=3)
        assert len(table) == 0
示例#5
0
    def test_no_peak(self):
        image = Map.create(npix=(10, 5))
        image.data[3, 5] = 12

        table = find_peaks(image, threshold=12.1)
        assert len(table) == 0