make_region

gammapy.utils.regions.make_region(region)[source]

Make region object (regions.Region).

See also:

Parameters
regionregions.Region or str

Region object or DS9 string representation

Examples

If a region object in DS9 string format is given, the corresponding region object is created. Note that in the DS9 format “image” or “physical” coordinates start at 1, whereas regions.PixCoord starts at 0 (as does Python, Numpy, Astropy, Gammapy, …).

>>> from gammapy.utils.regions import make_region
>>> make_region("image;circle(10,20,3)")
<CirclePixelRegion(PixCoord(x=9.0, y=19.0), radius=3.0)>
>>> make_region("galactic;circle(10,20,3)")
<CircleSkyRegion(<SkyCoord (Galactic): (l, b) in deg
    (10., 20.)>, radius=3.0 deg)>

If a region object is passed in, it is returned unchanged:

>>> region = make_region("image;circle(10,20,3)")
>>> region2 = make_region(region)
>>> region is region2
True