def _restrict_to_spherical_volume(source, position, BoxSize):
    """
    Slice the input source such that it only includes a spherical volume
    instead the simulation box.

    This returns a CatalogSource only containing objects within a radius
    of 1/2 the minimum box side length of the box center.
    """
    origin = 0.5 * source.attrs['BoxSize']
    pos = position - origin
    r = (pos ** 2).sum(axis=-1) ** 0.5
    keep = r < 0.5 * source.attrs['BoxSize'].min()
    return source[keep]
