From 6de30dde6e111a6b7e72d5de9843a6de9dc72f97 Mon Sep 17 00:00:00 2001 From: Larry Bradley Date: Mon, 24 Oct 2016 13:17:37 -0400 Subject: [PATCH] Add subpixels mode and keyword --- regions/core/core.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/regions/core/core.py b/regions/core/core.py index 71689f1f..8623d201 100644 --- a/regions/core/core.py +++ b/regions/core/core.py @@ -146,13 +146,13 @@ def to_sky(self, wcs, mode='local', tolerance=None): """ @abc.abstractmethod - def to_mask(self, mode='center'): + def to_mask(self, mode='center', subpixels=5): """ Returns a mask for the aperture. Parameters ---------- - mode : { 'center' | 'any' | 'all' | 'exact' } + mode : { 'center' | 'any' | 'all' | 'exact' | 'subpixels'} The following modes are available: * ``'center'``: returns 1 for pixels where the center is in the region, and 0 otherwise. @@ -162,6 +162,16 @@ def to_mask(self, mode='center'): the region, 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. 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 -------