to_ds9_region

gammapy.catalog.to_ds9_region(catalog, radius=None, color='green', glon='GLON', unc_glon=None, glat='GLAT', unc_glat=None, label=None, label_position='top', label_additional_info=None, label_distance=1.2, marker='diamond', dashed=False, width=3)[source]

Write ds9 region file from catalog.

Currently works only for galactic coordinates.

Parameters:

catalog : Table

Catalog with position and size information.

glon : str (‘GLON’)

Catalog column containing galactic longitude position.

glat : str (‘GLAT’)

Catalog column containing galactic latitude position.

unc_glon : str (None)

Catalog column containing galactic longitude position uncertainty.

unc_glat : str (None)

Catalog column containing galactic latitude position uncertainty.

radius : str (None)

Catalog column containing extension information.

color : str (‘green’)

Valid ds9 color.

label : str (None)

Catalog column to use for the label.

label_position: str (‘top’)

Position of the region label. Either ‘top’ or ‘bottom’.

label_distance: float (1.2)

Distance of the label from the regions center. Given in multiple of the region’s radius.

label_additional_info: dict

Additional info to be shown in the region label.

dashed : bool (False)

Dashed region line.

width : int

Width of the region line.

Returns:

region : str

DS9 region string.

Examples

This example reads Greens catalog from gammapy.datasets and writes it to a ds9 region file.

>>> from gammapy.catalog import load_catalog_green
>>> green = load_catalog_green()
>>> green['MeanDiam'] /= 120.
>>> green_str = to_ds9_region(green, radius='MeanDiam',
>>>                           label='Source_Name', color='red')
>>> with open("region_green.reg", "w") as region_file:
>>>     region_file.write(green_str)