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
评论列表
文章目录