xrf_interact.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:interactive_mpl_tutorial 作者: tacaswell 项目源码 文件源码
def _pixel_select(self, event):

        x, y = event.xdata, event.ydata
        # get index by assuming even spacing
        # TODO use kdtree?
        diff = np.hypot((self.x_pos - x), (self.y_pos - y))
        y_ind, x_ind = np.unravel_index(np.argmin(diff), diff.shape)

        # get the spectrum for this point
        new_y_data = self.counts[y_ind, x_ind, :]
        self.mask = np.zeros(self.x_pos.shape, dtype='bool')
        self.mask[y_ind, x_ind] = True
        self.mask_im.set_data(self._overlay_image)
        self._pixel_txt.set_text(
            'pixel: [{:d}, {:d}] ({:.3g}, {:.3g})'.format(
                y_ind, x_ind,
                self.x_pos[y_ind, x_ind],
                self.y_pos[y_ind, x_ind]))

        self.spec.set_ydata(new_y_data)
        self.ax_spec.relim()
        self.ax_spec.autoscale(True, axis='y')
        self.fig.canvas.draw_idle()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号