def extrapolate_2d(x, C, pred, fix_points, mirror):
    # find the prediction matrix shape and flatten it
    P, M = C.shape
    c = C.flatten()

    # find data parameters
    x_max = x.max()
    N_0, N_1 = x.shape

    # create a empty matrix
    if mirror == "0":
        new = np.empty((2 * N_0 - 1, N_1 + pred), dtype=x.dtype)
        plane = N_0 - 1   # index of first non-mirrored point
    else:
        new = np.empty((2 * N_0, N_1 + pred), dtype=x.dtype)
        plane = N_0     # index of first non-mirrored plane

    last = new.shape[0]     # number of rows in new matrix

    # fill the matrix with the mirrored version of each column
    for i in range(N_1):
        new[:, i] = make_mirror(x[:, i], mirror)

    # fill each new column with predicted values
    # i,j give coordinates of top-left corner of PxM reading matrix
    # after filling a column, replace the whole column with the mirrored column

    for j in range(N_1 - M, N_1 - M + pred):  # column index loop
        for i in range(plane - P + 1, last - P + 1):  # row index loop
            new[i + P - 1, j + M] = np.sum(new[i:i + P, j:j + M].flat * c)

            if fix_points:  # reduce predicted point is needed
                if new[i + P - 1, j + M] > x_max:
                    new[i + P - 1, j + M] = ((x_max * x_max) /
                                             (new[i + P - 1, j + M]))

        # fill the column with the mirrored column so it can be read in the
        # next interation of the loop
        new[:, j + M] = make_mirror(new[plane:, j + M], mirror)

    return new[plane:]
Extrapolate points along the 1st axis using the lp2d algorithm.
dataset/ETHPy150Open jjhelmus/nmrglue/nmrglue/process/proc_lp.py/extrapolate_2d