object_finding_mixin.py 文件源码

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

项目:yt 作者: yt-project 项目源码 文件源码
def find_ray_grids(self, coord, axis):
        """
        Returns the (objects, indices) of grids that an (x,y) ray intersects
        along *axis*
        """
        # Let's figure out which grids are on the slice
        mask=np.ones(self.num_grids)
        # So if gRE > coord, we get a mask, if not, we get a zero
        #    if gLE > coord, we get a zero, if not, mask
        # Thus, if the coordinate is between the two edges, we win!
        xax = self.ds.coordinates.x_axis[axis]
        yax = self.ds.coordinates.y_axis[axis]
        np.choose(np.greater(self.grid_right_edge[:,xax],coord[0]),(0,mask),mask)
        np.choose(np.greater(self.grid_left_edge[:,xax],coord[0]),(mask,0),mask)
        np.choose(np.greater(self.grid_right_edge[:,yax],coord[1]),(0,mask),mask)
        np.choose(np.greater(self.grid_left_edge[:,yax],coord[1]),(mask,0),mask)
        ind = np.where(mask == 1)
        return self.grids[ind], ind
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号