def get_index(i, j, k, N1, N2=None, N0=None):
    """Gets 1D index from 3D indices. Assumes row-major ordering. WARNING: N0 is passed last when all of N0,N1,N2 are specified!

    Parameters
    ----------
    i : int
        3D index x
    j : int
        3D index y
    k : int
        3D index z
    N1 : int
        size of the array y
    N2 : int, optional, default=N1
        size of the array z
    N0 : int, optional, default=N1
        size of the array x

    Returns
    -------
    Id : int
        corresponding 1D index

    """
    N2 = N2 or N1
    return k + N2 * (j + N1 * i)
