Пример #1
0
def make_tevcat_exclusion_mask():
    """Create an all-sky exclusion mask containing all TeVCat sources

    Returns
    -------
    mask : `~gammapy.image.SkyImage`
        Exclusion mask
    """
    from gammapy.catalog import load_catalog_tevcat

    tevcat = load_catalog_tevcat()
    all_sky_exclusion = SkyImage.empty(nxpix=3600,
                                       nypix=1800,
                                       binsz=0.1,
                                       fill=1,
                                       dtype='int')
    coords = all_sky_exclusion.coordinates()
    lons = coords.l
    lats = coords.b

    for source in tevcat:
        lon = Longitude(source['coord_gal_lon'], 'deg')
        lat = Latitude(source['coord_gal_lat'], 'deg')
        x = Angle(source['size_x'], 'deg')
        y = Angle(source['size_y'], 'deg')
        if np.isnan(x) and np.isnan(y):
            rad = Angle('0.3 deg')
        else:
            rad = x if x > y else y

        mask = lon_lat_circle_mask(lons, lats, lon, lat, rad)
        all_sky_exclusion.data[mask] = 0
        all_sky_exclusion.meta["EXTNAME"] = "EXCLUSION"

    return all_sky_exclusion
Пример #2
0
def make_tevcat_exclusion_mask():
    """Create an all-sky exclusion mask containing all TeVCat sources

    Returns
    -------
    mask : `~gammapy.image.ExclusionMask`
        Exclusion mask
    """

    # TODO: make this a method ExclusionMask.from_catalog()?
    from gammapy.catalog import load_catalog_tevcat

    tevcat = load_catalog_tevcat()
    all_sky_exclusion = ExclusionMask.empty(nxpix=3600, nypix=1800, binsz=0.1,
                                            fill=1, dtype='int')
    val_lon, val_lat = all_sky_exclusion.coordinates()
    lons = Longitude(val_lon, 'deg')
    lats = Latitude(val_lat, 'deg')

    for source in tevcat:
        lon = Longitude(source['coord_gal_lon'], 'deg')
        lat = Latitude(source['coord_gal_lat'], 'deg')
        x = Angle(source['size_x'], 'deg')
        y = Angle(source['size_y'], 'deg')
        if np.isnan(x) and np.isnan(y):
            rad = Angle('0.3 deg')
        else:
            rad = x if x > y else y

        mask = lon_lat_circle_mask(lons, lats, lon, lat, rad)
        all_sky_exclusion.data[mask] = 0

    return all_sky_exclusion
Пример #3
0
def make_tevcat_exclusion_mask():
    """Create an all-sky exclusion mask containing all TeVCat sources
    
    Returns
    -------
    mask : `~gammapy.image.ExclusionMask`
        Exclusion mask
    """

    from gammapy.catalog import load_catalog_tevcat
    
    tevcat = load_catalog_tevcat()
    all_sky_exclusion = make_empty_image(nxpix=3600, nypix=1800, binsz=0.1)
    val = np.ones(shape=all_sky_exclusion.data.shape)
    all_sky_exclusion.data = val
    val_lon, val_lat = coordinates(all_sky_exclusion)
    lons = Longitude(val_lon, 'deg')
    lats = Latitude(val_lat, 'deg')

    for source in tevcat:
        lon = Longitude(source['coord_gal_lon'], 'deg')
        lat = Latitude(source['coord_gal_lat'], 'deg')
        x = Angle(source['size_x'], 'deg')
        y = Angle(source['size_y'], 'deg')
        if np.isnan(x) and np.isnan(y):
            rad = Angle('0.3 deg')
        else:
            rad = x if x>y else y

        mask = lon_lat_circle_mask(lons, lats, lon, lat, rad)
        all_sky_exclusion.data[mask] = 0

    return ExclusionMask.from_hdu(all_sky_exclusion)