Region

class regions.Region[source]

Bases: abc.ABC

Base class for all regions.

Methods Summary

copy(**changes)

Make an independent (deep) copy.

get_formats()

Get the registered I/O formats as a Table.

intersection(other)

Return a region representing the intersection of this region with other.

serialize([format])

Serialize the region to a region string or table.

symmetric_difference(other)

Return the union of the two regions minus any areas contained in the intersection of the two regions.

union(other)

Return a region representing the union of this region with other.

write(filename[, format, overwrite])

Write the region to a region file in the specified format.

Methods Documentation

copy(**changes)[source]

Make an independent (deep) copy.

classmethod get_formats()[source]

Get the registered I/O formats as a Table.

abstract intersection(other)[source]

Return a region representing the intersection of this region with other.

serialize(format=None, **kwargs)[source]

Serialize the region to a region string or table.

This method allows serializing regions in many supported data formats, e.g.,:

>>> reg1_str = reg.serialize(format='ds9')
>>> reg2_str = reg.serialize(format='crtf')
>>> reg3_tbl = reg.serialize(format='fits')

A list of the available formats for Region is available using:

>>> from regions import Region
>>> Region.get_formats()
Parameters
formatstr, optional

The file format specifier.

**kwargsdict, optional

Keyword arguments passed to the data serializer.

abstract symmetric_difference(other)[source]

Return the union of the two regions minus any areas contained in the intersection of the two regions.

abstract union(other)[source]

Return a region representing the union of this region with other.

write(filename, format=None, overwrite=False, **kwargs)[source]

Write the region to a region file in the specified format.

This method allows writing a file in many supported data formats, e.g.,:

>>> reg.write('new_regions.reg', format='ds9')
>>> reg.write('new_regions.crtf', format='crtf')
>>> reg.write('new_regions.fits', format='fits')

A list of the available formats for Region is available using:

>>> from regions import Region
>>> Region.get_formats()
Parameters
filenamestr

The filename or URL of the file to write.

formatstr, optional

The file format specifier.

overwritebool, optional

If True, overwrite the output file if it exists. Raises an OSError if False and the output file exists. Default is False.

**kwargsdict, optional

Keyword arguments passed to the data writer.