How to use the regions.core.attributes.ScalarLength function in regions

To help you get started, we’ve selected a few regions examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github astropy / regions / regions / shapes / annulus.py View on Github external
class AsymmetricAnnulusPixelRegion(AnnulusPixelRegion):
    """Helper class for asymmetric annuli sky regions.

    Used for ellipse and rectangle annuli below.
    """
    _params = (
        "center",
        "inner_width",
        "inner_height",
        "outer_width",
        "outer_height",
        "angle",
    )
    center = ScalarPix("center")
    inner_width = ScalarLength("inner_width")
    outer_width = ScalarLength("outer_width")
    inner_height = ScalarLength("inner_height")
    outer_height = ScalarLength("outer_height")
    angle = QuantityLength("angle")

    def __init__(
            self,
            center,
            inner_width,
            outer_width,
            inner_height,
            outer_height,
            angle=0 * u.deg,
            meta=None,
            visual=None,
    ):
        self.center = center
github astropy / regions / regions / shapes / circle.py View on Github external
radius = 5.5

        fig, ax = plt.subplots(1, 1)

        center = PixCoord(x=x, y=y)
        reg = CirclePixelRegion(center=center, radius=radius)
        patch = reg.as_artist(facecolor='none', edgecolor='red', lw=2)
        ax.add_patch(patch)

        plt.xlim(0, 15)
        plt.ylim(0, 15)
        ax.set_aspect('equal')
    """
    _params = ('center', 'radius')
    center = ScalarPix('center')
    radius = ScalarLength('radius')

    def __init__(self, center, radius, meta=None, visual=None):
        self.center = center
        self.radius = radius
        self.meta = meta or RegionMeta()
        self.visual = visual or RegionVisual()

    @property
    def area(self):
        """Region area (`float`)."""
        return math.pi * self.radius ** 2

    def contains(self, pixcoord):
        pixcoord = PixCoord._validate(pixcoord, name='pixcoord')
        in_circle = self.center.separation(pixcoord) < self.radius
        if self.meta.get('include', True):
github astropy / regions / regions / shapes / annulus.py View on Github external
center = PixCoord(x=x, y=y)
        reg = CircleAnnulusPixelRegion(center=center, inner_radius=inner_radius,
                                       outer_radius=outer_radius)
        patch = reg.as_artist(facecolor='none', edgecolor='red', lw=2)
        ax.add_patch(patch)

        plt.xlim(-5, 20)
        plt.ylim(-5, 20)
        ax.set_aspect('equal')
    """
    _component_class = CirclePixelRegion

    _params = ("center", "inner_radius", "outer_radius")
    center = ScalarPix("center")
    inner_radius = ScalarLength("inner_radius")
    outer_radius = ScalarLength("outer_radius")

    def __init__(self, center, inner_radius, outer_radius, meta=None, visual=None):
        self.center = center
        self.inner_radius = inner_radius
        self.outer_radius = outer_radius
        self.meta = meta or RegionMeta()
        self.visual = visual or RegionVisual()

    @property
    def _inner_region(self):
        return self._component_class(self.center, self.inner_radius, self.meta, self.visual)

    @property
    def _outer_region(self):
        return self._component_class(self.center, self.outer_radius, self.meta, self.visual)
github astropy / regions / regions / shapes / annulus.py View on Github external
"""Helper class for asymmetric annuli sky regions.

    Used for ellipse and rectangle annuli below.
    """
    _params = (
        "center",
        "inner_width",
        "inner_height",
        "outer_width",
        "outer_height",
        "angle",
    )
    center = ScalarPix("center")
    inner_width = ScalarLength("inner_width")
    outer_width = ScalarLength("outer_width")
    inner_height = ScalarLength("inner_height")
    outer_height = ScalarLength("outer_height")
    angle = QuantityLength("angle")

    def __init__(
            self,
            center,
            inner_width,
            outer_width,
            inner_height,
            outer_height,
            angle=0 * u.deg,
            meta=None,
            visual=None,
    ):
        self.center = center
        self.inner_width = inner_width
github astropy / regions / regions / shapes / rectangle.py View on Github external
fig, ax = plt.subplots(1, 1)

        center = PixCoord(x=x, y=y)
        reg = RectanglePixelRegion(center=center, width=width,
                                   height=height, angle=angle)
        patch = reg.as_artist(facecolor='none', edgecolor='red', lw=2)
        ax.add_patch(patch)

        plt.xlim(0, 30)
        plt.ylim(0, 20)
        ax.set_aspect('equal')
    """
    _params = ('center', 'width', 'height', 'angle')
    center = ScalarPix('center')
    width = ScalarLength('width')
    height = ScalarLength('height')
    angle = QuantityLength('angle')

    def __init__(self, center, width, height, angle=0 * u.deg, meta=None, visual=None):
        self.center = center
        self.width = width
        self.height = height
        self.angle = angle
        self.meta = meta or {}
        self.visual = visual or {}

    @property
    def area(self):
        """Region area (float)"""
        return self.width * self.height

    def contains(self, pixcoord):
github astropy / regions / regions / shapes / annulus.py View on Github external
center = PixCoord(x=x, y=y)
        reg = CircleAnnulusPixelRegion(center=center, inner_radius=inner_radius,
                                       outer_radius=outer_radius)
        patch = reg.as_artist(facecolor='none', edgecolor='red', lw=2)
        ax.add_patch(patch)

        plt.xlim(-5, 20)
        plt.ylim(-5, 20)
        ax.set_aspect('equal')
    """
    _component_class = CirclePixelRegion

    _params = ("center", "inner_radius", "outer_radius")
    center = ScalarPix("center")
    inner_radius = ScalarLength("inner_radius")
    outer_radius = ScalarLength("outer_radius")

    def __init__(self, center, inner_radius, outer_radius, meta=None, visual=None):
        self.center = center
        self.inner_radius = inner_radius
        self.outer_radius = outer_radius
        self.meta = meta or RegionMeta()
        self.visual = visual or RegionVisual()

    @property
    def _inner_region(self):
        return self._component_class(self.center, self.inner_radius, self.meta, self.visual)

    @property
    def _outer_region(self):
        return self._component_class(self.center, self.outer_radius, self.meta, self.visual)
github astropy / regions / regions / shapes / annulus.py View on Github external
class AsymmetricAnnulusPixelRegion(AnnulusPixelRegion):
    """Helper class for asymmetric annuli sky regions.

    Used for ellipse and rectangle annuli below.
    """
    _params = (
        "center",
        "inner_width",
        "inner_height",
        "outer_width",
        "outer_height",
        "angle",
    )
    center = ScalarPix("center")
    inner_width = ScalarLength("inner_width")
    outer_width = ScalarLength("outer_width")
    inner_height = ScalarLength("inner_height")
    outer_height = ScalarLength("outer_height")
    angle = QuantityLength("angle")

    def __init__(
            self,
            center,
            inner_width,
            outer_width,
            inner_height,
            outer_height,
            angle=0 * u.deg,
            meta=None,
            visual=None,
    ):
github astropy / regions / regions / shapes / ellipse.py View on Github external
theta = Angle(30, 'deg')
        e = Ellipse2D(amplitude=100., x_0=x0, y_0=y0, a=a, b=b, theta=theta.radian)
        y, x = np.mgrid[0:20, 0:30]
        fig, ax = plt.subplots(1, 1)
        ax.imshow(e(x, y), origin='lower', interpolation='none', cmap='Greys_r')

        center = PixCoord(x=x0, y=y0)
        reg = EllipsePixelRegion(center=center, width=2*a, height=2*b, angle=theta)
        patch = reg.as_artist(facecolor='none', edgecolor='red', lw=2)
        ax.add_patch(patch)

    """
    _params = ('center', 'width', 'height', 'angle')
    center = ScalarPix('center')
    width = ScalarLength('width')
    height = ScalarLength('height')
    angle = QuantityLength('angle')

    def __init__(self, center, width, height, angle=0. * u.deg, meta=None,
                 visual=None):
        self.center = center
        self.width = width
        self.height = height
        self.angle = angle
        self.meta = meta or RegionMeta()
        self.visual = visual or RegionVisual()

    @property
    def area(self):
        """Region area (float)"""
        return math.pi / 4 * self.width * self.height
github astropy / regions / regions / shapes / rectangle.py View on Github external
fig, ax = plt.subplots(1, 1)

        center = PixCoord(x=x, y=y)
        reg = RectanglePixelRegion(center=center, width=width,
                                   height=height, angle=angle)
        patch = reg.as_artist(facecolor='none', edgecolor='red', lw=2)
        ax.add_patch(patch)

        plt.xlim(0, 30)
        plt.ylim(0, 20)
        ax.set_aspect('equal')
    """
    _params = ('center', 'width', 'height', 'angle')
    center = ScalarPix('center')
    width = ScalarLength('width')
    height = ScalarLength('height')
    angle = QuantityLength('angle')

    def __init__(self, center, width, height, angle=0 * u.deg, meta=None, visual=None):
        self.center = center
        self.width = width
        self.height = height
        self.angle = angle
        self.meta = meta or {}
        self.visual = visual or {}

    @property
    def area(self):
        """Region area (float)"""
        return self.width * self.height
github astropy / regions / regions / shapes / annulus.py View on Github external
Used for ellipse and rectangle annuli below.
    """
    _params = (
        "center",
        "inner_width",
        "inner_height",
        "outer_width",
        "outer_height",
        "angle",
    )
    center = ScalarPix("center")
    inner_width = ScalarLength("inner_width")
    outer_width = ScalarLength("outer_width")
    inner_height = ScalarLength("inner_height")
    outer_height = ScalarLength("outer_height")
    angle = QuantityLength("angle")

    def __init__(
            self,
            center,
            inner_width,
            outer_width,
            inner_height,
            outer_height,
            angle=0 * u.deg,
            meta=None,
            visual=None,
    ):
        self.center = center
        self.inner_width = inner_width
        self.outer_width = outer_width