# PixelRegion¶

class regions.PixelRegion[source]

Bases: regions.Region

Base class for all regions defined in pixel coordinates

Attributes Summary

 bounding_box The minimal bounding box (in integer pixel coordinates) that contains the region.

Methods Summary

 as_artist([origin]) Convert to mpl patch contains(pixcoord) Checks whether a position or positions fall inside the region. intersection(other) Returns a region representing the intersection of this region with other. mpl_properties_default([shape]) This sets the default values of the visual attributes as specified under DS9 convention. plot([origin, ax]) Calls as_artist method forwarding all kwargs and adds patch to given axis. symmetric_difference(other) Returns the union of the two regions minus any areas contained in the intersection of the two regions. to_mask([mode, subpixels]) Returns a mask for the aperture. to_sky(wcs) Returns a region defined in sky coordinates. union(other) Returns a region representing the union of this region with other.

Attributes Documentation

bounding_box

The minimal bounding box (in integer pixel coordinates) that contains the region.

Methods Documentation

as_artist(origin=(0, 0), **kwargs)[source]

Convert to mpl patch

Parameters: origin : array_like, optional The (x, y) pixel position of the origin of the displayed image. Default is (0, 0). kwargs : dict keywords that a Patch accepts patch : Patch Matplotlib patch
contains(pixcoord)[source]

Checks whether a position or positions fall inside the region.

Parameters: pixcoord : PixCoord The position or positions to check.
intersection(other)[source]

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

mpl_properties_default(shape='patch')[source]

This sets the default values of the visual attributes as specified under DS9 convention.

plot(origin=(0, 0), ax=None, **kwargs)[source]

Calls as_artist method forwarding all kwargs and adds patch to given axis.

Parameters: origin : array_like, optional The (x, y) pixel position of the origin of the displayed image. Default is (0, 0). ax : Axes, optional Axis kwargs : dict keywords that a Patch accepts ax : Axes Axes on which the patch is added.
symmetric_difference(other)[source]

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

to_mask(mode='center', subpixels=5)[source]

Returns a mask for the aperture.

Parameters: mode : { ‘center’ | ‘exact’ | ‘subpixels’}, optional The following modes are available: 'center': returns 1 for pixels where the center is in the region, and 0 otherwise. 'exact': returns a value between 0 and 1 giving the fractional level of overlap of the pixel with the region. 'subpixels': A pixel is divided into subpixels and the center of each subpixel is tested (a subpixel is either completely in or out of the region). Returns a value between 0 and 1 giving the fractional level of overlap of the subpixels with the region. With subpixels set to 1, this method is equivalent to 'center'. subpixels : int, optional For the 'subpixel' mode, resample pixels by this factor in each dimension. That is, each pixel is divided into subpixels ** 2 subpixels. mask : Mask A region mask object.
to_sky(wcs)[source]

Returns a region defined in sky coordinates.

Parameters: wcs : WCS instance The world coordinate system transformation to assume sky_region : SkyRegion object.
union(other)[source]

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