PixelRegion¶
- class regions.PixelRegion[source]¶
Bases:
Region
Base class for all regions defined in pixel coordinates.
Attributes Summary
The exact analytical area of the region shape.
The minimal bounding box (in integer pixel coordinates) that contains the region.
Methods Summary
as_artist
([origin])Convert to matplotlib patch object for this region.
contains
(pixcoord)Check whether a position or positions fall inside the region.
intersection
(other)Return a region representing the intersection of this region with
other
.plot
([origin, ax])Plot the region on a matplotlib
Axes
instance.symmetric_difference
(other)Return the union of the two regions minus any areas contained in the intersection of the two regions.
to_mask
([mode, subpixels])Return a mask for the region.
to_sky
(wcs)Return a region defined in sky coordinates.
union
(other)Return a region representing the union of this region with
other
.Attributes Documentation
- area¶
The exact analytical area of the region shape.
- bounding_box¶
The minimal bounding box (in integer pixel coordinates) that contains the region.
- meta = {}¶
- visual = {}¶
Methods Documentation
- abstract as_artist(origin=(0, 0), **kwargs)[source]¶
Convert to matplotlib patch object for this region.
- abstract contains(pixcoord)[source]¶
Check whether a position or positions fall inside the region.
- Parameters:
- pixcoord
PixCoord
The position or positions to check.
- pixcoord
- 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
- plot(origin=(0, 0), ax=None, **kwargs)[source]¶
Plot the region on a matplotlib
Axes
instance.- Parameters:
- Returns:
- artist
matplotlib.artist.Artist
The matplotlib artist (typically a
Patch
object) for the plotted region. The artist can be used, for example, when adding a plot legend.
- artist
- 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 to_mask(mode='center', subpixels=5)[source]¶
Return a mask for the region.
- Parameters:
- mode{‘center’, ‘exact’, ‘subpixels’}, optional
The method used to determine the overlap of the region on the pixel grid. Not all options are available for all region types. Note that the more precise methods are generally slower. The following methods are available:
'center'
: A pixel is considered to be entirely in or out of the region depending on whether its center is in or out of the region. The returned mask will contain values only of 0 (out) and 1 (in).'exact'
(default): The exact fractional overlap of the region and each pixel is calculated. The returned mask will contain values between 0 and 1.'subpixel'
: A pixel is divided into subpixels (see thesubpixels
keyword), each of which are considered to be entirely in or out of the region depending on whether its center is in or out of the region. Ifsubpixels=1
, this method is equivalent to'center'
. The returned mask will contain values between 0 and 1.
- subpixelsint, optional
For the
'subpixel'
mode, resample pixels by this factor in each dimension. That is, each pixel is divided intosubpixels ** 2
subpixels.
- Returns:
- mask
RegionMask
A mask for the region.
- mask