Region¶
- class regions.Region[source]¶
Bases:
ABC
Base class for all regions.
Methods Summary
copy
(**changes)Make an independent (deep) copy.
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.
- Parameters:
- **changesdict
Changes to make to the region parameters.
- abstract intersection(other)[source]¶
Return a region representing the intersection of this region with
other
.- Parameters:
- other
Region
The other region to use for the intersection.
- 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.
- Parameters:
- other
Region
The other region to use for the symmetric difference.
- other
- abstract union(other)[source]¶
Return a region representing the union of this region with
other
.- Parameters:
- other
Region
The other region to use for the union.
- 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.