def select_points_in_box(xy, dim):
    """Only return the points within the limits of the box.

    Parameters
    ----------
    xy : ndarray
        Locations of each point.
    dim : tuple or float
        Dimension of the box (x0, y0, dx, dy) or just a float indicating a box jutting out
        from the origin.

    Returns
    -------
    ndarray
        xy of selected points
    """

    if type(dim) is float or type(dim) is int:
        dim = (0, 0, dim, dim)

    x0 = dim[0]
    x1 = dim[0] + dim[2]
    y0 = dim[1]
    y1 = dim[1] + dim[3]

    selectix = (xy[:,0]>=x0) & (xy[:,0]<=x1) & (xy[:,1]>=y0) & (xy[:,1]<=y1)

    return xy[selectix]