RegionMask¶

class
regions.
RegionMask
(data, bbox)[source]¶ Bases:
object
Class for a region mask.
Parameters:  data : array_like
A 2D array of a region mask representing the fractional overlap of the region on the pixel grid. This should be the fullsized (i.e. not truncated) array that is the direct output of one of the lowlevel “geometry” functions.
 bbox :
regions.BoundingBox
The bounding box for the region.
Examples
Usage examples are provided in the Computing overlap masks section of the docs.
Attributes Summary
shape
The shape of the mask data array. Methods Summary
cutout
(self, data[, fill_value, copy])Create a cutout from the input data over the mask bounding box, taking any edge effects into account. multiply
(self, data[, fill_value])Multiply the region mask with the input data, taking any edge effects into account. to_image
(self, shape)Return an image of the mask in a 2D array of the given shape, taking any edge effects into account. Attributes Documentation

shape
¶ The shape of the mask data array.
Methods Documentation

cutout
(self, data, fill_value=0.0, copy=False)[source]¶ Create a cutout from the input data over the mask bounding box, taking any edge effects into account.
Parameters:  data : array_like
A 2D array on which to apply the region mask.
 fill_value : float, optional
The value used to fill pixels where the region mask does not overlap with the input
data
. The default is 0. copy : bool, optional
If
True
then the returned cutout array will always be hold a copy of the inputdata
. IfFalse
and the mask is fully within the inputdata
, then the returned cutout array will be a view into the inputdata
. In cases where the mask partially overlaps or has no overlap with the inputdata
, the returned cutout array will always hold a copy of the inputdata
(i.e. this keyword has no effect).
Returns:  result :
ndarray
orNone
A 2D array cut out from the input
data
representing the same cutout region as the region mask. If there is a partial overlap of the region mask with the input data, pixels outside of the data will be assigned tofill_value
.None
is returned if there is no overlap of the region with the inputdata
.

multiply
(self, data, fill_value=0.0)[source]¶ Multiply the region mask with the input data, taking any edge effects into account.
The result is a maskweighted cutout from the data.
Parameters:  data : array_like or
Quantity
The 2D array to multiply with the region mask.
 fill_value : float, optional
The value is used to fill pixels where the region mask does not overlap with the input
data
. The default is 0.
Returns:  result :
ndarray
orNone
A 2D maskweighted cutout from the input
data
. If there is a partial overlap of the region mask with the input data, pixels outside of the data will be assigned tofill_value
before being multipled with the mask.None
is returned if there is no overlap of the region with the inputdata
.
 data : array_like or