def find_slice_grids(self, coord, axis):
"""
Returns the (objects, indices) of grids that a slice 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 edges, we win!
np.choose(np.greater(self.grid_right_edge[:,axis],coord),(0,mask),mask)
np.choose(np.greater(self.grid_left_edge[:,axis],coord),(mask,0),mask)
ind = np.where(mask == 1)
return self.grids[ind], ind
评论列表
文章目录