read_ds9

regions.read_ds9(filename, errors='strict')[source]

Read a DS9 region file in as a list of Region objects.

Parameters:
filename : str

The file path

errors : warn, ignore, strict, optional

The error handling scheme to use for handling parsing errors. The default is ‘strict’, which will raise a DS9RegionParserError. warn will raise a DS9RegionParserWarning, and ignore will do nothing (i.e., be silent).

Returns:
regions : list

Python list of Region objects.

Examples

>>> from regions import read_ds9
>>> from astropy.utils.data import get_pkg_data_filename
>>> file = get_pkg_data_filename('data/physical_reference.reg', package='regions.io.ds9.tests')
>>> regs = read_ds9(file, errors='warn')
>>> print(regs[0])
Region: CirclePixelRegion
center: PixCoord(x=330.0, y=1090.0)
radius: 40.0