CompoundPixelRegion

class regions.CompoundPixelRegion(region1, region2, operator, meta=None, visual=None)[source]

Bases: regions.PixelRegion

Represents the logical combination of two regions in pixel coordinates.

Parameters:
region1 : PixelRegion object

The inner Pixel region.

region2 : PixelRegion object

The outer Pixel region.

operator : function

A callable binary operator.

meta : RegionMeta object, optional

A dictionary which stores the meta attributes of this region.

visual : RegionVisual object, optional

A dictionary which stores the visual meta attributes of this region.

Attributes Summary

area
operator
region1 Descriptor class for CompoundPixelRegion which takes a PixelRegion object.
region2 Descriptor class for CompoundPixelRegion which takes a PixelRegion object.

Methods Summary

as_artist(self[, origin]) Matplotlib patch object for annulus region (matplotlib.patches.PathPatch).
bounding_box(self, \*\*kwargs) The minimal bounding box (in integer pixel coordinates) that contains the region.
contains(self, pixcoord) Checks whether a position or positions fall inside the region.
rotate(self, center, angle) Make a rotated region.
to_mask(self[, mode, subpixels]) Returns a mask for the aperture.
to_sky(self, wcs) Returns a region defined in sky coordinates.

Attributes Documentation

area
operator
region1

Descriptor class for CompoundPixelRegion which takes a PixelRegion object.

region2

Descriptor class for CompoundPixelRegion which takes a PixelRegion object.

Methods Documentation

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

Matplotlib patch object for annulus region (matplotlib.patches.PathPatch).

Parameters:
origin : array_like, optional

The (x, y) pixel position of the origin of the displayed image. Default is (0, 0).

kwargs : dict

All keywords that a PathPatch object accepts

Returns:
patch : PathPatch

Matplotlib patch object

bounding_box(self, **kwargs)[source]

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

contains(self, pixcoord)[source]

Checks whether a position or positions fall inside the region.

Parameters:
pixcoord : PixCoord

The position or positions to check.

rotate(self, center, angle)[source]

Make a rotated region.

Rotates counter-clockwise for positive angle.

Parameters:
center : PixCoord

Rotation center point

angle : Angle

Rotation angle

Returns:
region : CompoundPixelRegion

Rotated region (an independent copy)

to_mask(self, mode='center', subpixels=1)[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.

Returns:
mask : Mask

A region mask object.

to_sky(self, wcs)[source]

Returns a region defined in sky coordinates.

Parameters:
wcs : WCS instance

The world coordinate system transformation to assume

Returns:
sky_region : SkyRegion object.