当前位置: 首页>>代码示例>>Python>>正文


Python RectangularROI.contains方法代码示例

本文整理汇总了Python中glue.core.roi.RectangularROI.contains方法的典型用法代码示例。如果您正苦于以下问题:Python RectangularROI.contains方法的具体用法?Python RectangularROI.contains怎么用?Python RectangularROI.contains使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在glue.core.roi.RectangularROI的用法示例。


在下文中一共展示了RectangularROI.contains方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: on_mouse_release

# 需要导入模块: from glue.core.roi import RectangularROI [as 别名]
# 或者: from glue.core.roi.RectangularROI import contains [as 别名]
    def on_mouse_release(self, event):

        # Get the visible datasets
        if event.button == 1 and self.mode is not None:
            visible_data, visual = self.get_visible_data()
            data = self.get_map_data()

            if len(self.line_pos) == 0:
                self.lasso_reset()
                return

            elif self.mode is 'lasso':
                selection_path = path.Path(self.line_pos, closed=True)
                mask = selection_path.contains_points(data)

            elif self.mode is 'ellipse':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                c = CircularROI((xmax + xmin) / 2., (ymax + ymin) / 2., (xmax - xmin) / 2.)  # (xc, yc, radius)
                mask = c.contains(data[:, 0], data[:, 1])

            elif self.mode is 'rectangle':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                r = RectangularROI(xmin, xmax, ymin, ymax)
                mask = r.contains(data[:, 0], data[:, 1])

            else:
                raise ValueError("Unknown mode: {0}".format(self.mode))

            self.mark_selected(mask, visible_data)

            self.lasso_reset()
开发者ID:pllim,项目名称:glue-3d-viewer,代码行数:35,代码来源:scatter_toolbar.py

示例2: on_mouse_release

# 需要导入模块: from glue.core.roi import RectangularROI [as 别名]
# 或者: from glue.core.roi.RectangularROI import contains [as 别名]
    def on_mouse_release(self, event):

        visible_data, visual = self.get_visible_data()

        # Get the visible datasets
        if event.button == 1 and self.mode is not None:

            visible_data, visual = self.get_visible_data()
            data = self.get_map_data()
            if len(self.line_pos) == 0:
                self.lasso_reset()
                return

            elif self.mode is 'lasso':
                # Note, we use points_inside_poly here instead of calling e.g.
                # matplotlib directly, because we include some optimizations
                # in points_inside_poly
                vx, vy = np.array(self.line_pos).transpose()
                x, y = data.transpose()
                mask = points_inside_poly(x, y, vx, vy)

            elif self.mode is 'ellipse':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                c = CircularROI((xmax + xmin) / 2., (ymax + ymin) / 2., (xmax - xmin) / 2.)  # (xc, yc, radius)
                mask = c.contains(data[:, 0], data[:, 1])

            elif self.mode is 'rectangle':
                xmin, ymin = np.min(self.line_pos[:, 0]), np.min(self.line_pos[:, 1])
                xmax, ymax = np.max(self.line_pos[:, 0]), np.max(self.line_pos[:, 1])
                r = RectangularROI(xmin, xmax, ymin, ymax)
                mask = r.contains(data[:, 0], data[:, 1])

            else:
                raise ValueError("Unknown mode: {0}".format(self.mode))

            # Mask matches transposed volume data set rather than the original one.
            # The ravel here is to make mask compatible with ElementSubsetState input.
            new_mask = np.reshape(mask, self.trans_ones_data.shape)
            new_mask = np.ravel(np.transpose(new_mask))
            self.mark_selected(new_mask, visible_data)

            self.lasso_reset()
开发者ID:pllim,项目名称:glue-3d-viewer,代码行数:45,代码来源:volume_toolbar.py

示例3: release

# 需要导入模块: from glue.core.roi import RectangularROI [as 别名]
# 或者: from glue.core.roi.RectangularROI import contains [as 别名]
    def release(self, event):

        if event.button == 1:

            if self.corner2 is not None:

                r = RectangularROI(*self.bounds)

                indices_dict = {}

                for layer_artist in self.iter_data_layer_artists():

                    data = get_map_data(layer_artist, self.viewer)
                    mask = r.contains(data[:, 0], data[:, 1])

                    shape_mask = np.reshape(mask, layer_artist.layer.shape[::-1])
                    shape_mask = np.ravel(np.transpose(shape_mask))

                    indices_dict[layer_artist.layer] = np.where(shape_mask)[0]

                self.mark_selected_dict(indices_dict)

            self.reset()
开发者ID:PennyQ,项目名称:glue-3d-viewer,代码行数:25,代码来源:selection_tools.py


注:本文中的glue.core.roi.RectangularROI.contains方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。