def applyLatticeLimit(lattice, bounds):
    """Remove lattice points outside the data bounds. For 2D and 3D data.

    Parameters
    ---------
        lattice : ndarray; (N, 2) or (N, 3)
            From lattice2D

        bounds : tuple,
            Minimum and maximum for axes 0 and 1
            (min0, max0, min1, max1) or axes 0, 1 and 2
            (min0, max0, min1, max1, min2, max2)

    Returns
    -------
        : ndarray; (M, 2) or (M, 3)
            Same as lattice input except only containing
            points within the bounds specified. M <= N
    """
    if len(bounds) == 4:
        goodUVs = ((lattice[:, 0] > bounds[0]) & (lattice[:, 0] < bounds[1])) & (
            (lattice[:, 1] > bounds[2]) & (lattice[:, 1] < bounds[3])
        )
    elif len(bounds) == 6:
        goodUVs = (
            ((lattice[:, 0] > bounds[0]) & (lattice[:, 0] < bounds[1]))
            & ((lattice[:, 1] > bounds[2]) & (lattice[:, 1] < bounds[3]))
            & ((lattice[:, 2] > bounds[4]) & (lattice[:, 2] < bounds[5]))
        )
    else:
        print("Bounds needs be be either 4 or 6 value tuple.")
        return None
    return lattice[goodUVs, :]