Roi#

class glue.core.roi.Roi[source]#

Bases: object

A geometrical 2D region of interest.

Glue uses ROIs to represent user-drawn regions on plots. There are many specific sub-classes of Roi, but they all have a contains method to test whether a collection of 2D points lies inside the region. ROI bounds are generally designed as being exclusive (that is, points situated exactly on a border are considered to lie outside the region).

Methods Summary

center()

Return the (x, y) coordinates of the ROI center

contains(x, y)

Test which of a set of (x, y) points fall within the region of interest.

contains3d(x, y, z)

Test which of a set of projected (x, y, z) points fall within the linked 2D region of interest.

copy()

Return a clone of the Roi

defined()

Returns True if the ROI is defined

move_to(x, y)

Translate the ROI to a center of (x, y)

rotate_by(dtheta, **kwargs)

Rotate the Roi around center by angle dtheta.

rotate_to(theta)

Rotate anticlockwise around center to position angle theta.

to_polygon()

Returns vertices vx, vy of a polygon approximating the Roi, where each is an array of vertex coordinates in x and y.

transformed([xfunc, yfunc])

A transformed version of the Roi

Methods Documentation

center()[source]#

Return the (x, y) coordinates of the ROI center

contains(x, y)[source]#

Test which of a set of (x, y) points fall within the region of interest.

Parameters:
xfloat or array-like

x coordinate(s) of point(s).

yfloat or array-like

y coordinate(s) of point(s).

Returns:
insidebool or ~numpy.ndarray

An boolean iterable, where each element is True if the corresponding (x, y) tuple is inside the Roi.

Raises:
UndefinedROI

If not defined.

contains3d(x, y, z)[source]#

Test which of a set of projected (x, y, z) points fall within the linked 2D region of interest.

Parameters:
xndarray

Array of x locations

yndarray

Array of y locations

zndarray

Array of z locations

Returns:
ndarray

A boolean array, where each element is True if the corresponding (x, y, z) tuple is projected inside the associated 2D Roi.

Raises:
UndefinedROI

If not defined.

copy()[source]#

Return a clone of the Roi

defined()[source]#

Returns True if the ROI is defined

move_to(x, y)[source]#

Translate the ROI to a center of (x, y)

rotate_by(dtheta, **kwargs)[source]#

Rotate the Roi around center by angle dtheta.

Parameters:
dthetafloat

Change in anticlockwise rotation angle around center in radian.

rotate_to(theta)[source]#

Rotate anticlockwise around center to position angle theta.

Parameters:
thetafloat

Angle of anticlockwise rotation around center in radian.

to_polygon()[source]#

Returns vertices vx, vy of a polygon approximating the Roi, where each is an array of vertex coordinates in x and y.

transformed(xfunc=None, yfunc=None)[source]#

A transformed version of the Roi