# CompoundPixelRegion¶

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

Represents the logical combination of two regions in pixel coordinates.

Parameters
region1PixelRegion object

The inner Pixel region.

region2PixelRegion object

The outer Pixel region.

operatorfunction

A callable binary operator.

metaRegionMeta object, optional

A dictionary which stores the meta attributes of this region.

visualRegionVisual object, optional

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

Attributes Summary

 area Region area (float) bounding_box The minimal bounding box (in integer pixel coordinates) that contains the region. 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([origin]) Matplotlib patch object for annulus region (matplotlib.patches.PathPatch). contains(pixcoord) Checks whether a position or positions fall inside the region. rotate(center, angle) Make a rotated region. to_mask([mode, subpixels]) Returns a mask for the aperture. to_sky(wcs) Returns a region defined in sky coordinates.

Attributes Documentation

area
bounding_box
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(origin=0, 0, **kwargs)[source]

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

Parameters
originarray_like, optional

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

kwargsdict

All keywords that a PathPatch object accepts

Returns
patchPathPatch

Matplotlib patch object

contains(pixcoord)[source]

Checks whether a position or positions fall inside the region.

Parameters
pixcoordPixCoord

The position or positions to check.

rotate(center, angle)[source]

Make a rotated region.

Rotates counter-clockwise for positive angle.

Parameters
centerPixCoord

Rotation center point

angleAngle

Rotation angle

Returns
regionCompoundPixelRegion

Rotated region (an independent copy)

to_mask(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'.

subpixelsint, optional

For the 'subpixel' mode, resample pixels by this factor in each dimension. That is, each pixel is divided into subpixels ** 2 subpixels.

Returns
maskMask

to_sky(wcs)[source]

Returns a region defined in sky coordinates.

Parameters
wcsWCS instance

The world coordinate system transformation to assume

Returns
sky_regionSkyRegion object.