Beispiel #1
0
def plot_norm_fig(scheme):
    plt.figure(figsize=(6, 5))
    ax = plt.axes()
    """
    Set labels
    """
    plt.xlabel(r'Step')
    plt.ylabel(r'Norm')
    """
    Set range
    """
    x_st = -0.45
    x_ed = 1.45
    y_st = -0.35
    y_ed = 1.35

    # plt.xlim([x_st, x_ed])
    # plt.ylim([y_st, y_ed])
    #plt.xscale('log')
    plt.yscale('log')
    """
    Data part
    """
    # file check
    if not os.path.exists(PATH_DATA + "/%s_norm1.txt" % scheme):
        return
    # read file
    file = FT.TextFile(PATH_DATA + "/%s_norm1.txt" % scheme)
    d = file.get_data()
    l1, = ax.plot(FT.col(d, 1), FT.col(d, 2))
    file = FT.TextFile(PATH_DATA + "/%s_norm2.txt" % scheme)
    d = file.get_data()
    l2, = ax.plot(FT.col(d, 1), FT.col(d, 2))
    file = FT.TextFile(PATH_DATA + "/%s_norminf.txt" % scheme)
    d = file.get_data()
    li, = ax.plot(FT.col(d, 1), FT.col(d, 2))
    plt.legend([l1, l2, li], ["Norm1", "Norm2", "Norminf"], loc='best')

    plt.grid(True)
    plt.tight_layout()
    plt.savefig(PATH_FIG + "/%s_norm.png" % scheme)
    plt.close()
Beispiel #2
0
def add_a_scheme(ax, scheme):
    file = find_section_file("./data/", scheme, "phi")
    if len(file) < 1:
        return

    fd = FT.TextFile(PATH_DATA + "/" + file[0])
    d = fd.get_data()
    l1, = ax.plot(FT.col(d, 1), FT.col(d, 4), ".")

    avgx = np.average(FT.col(d, 2))

    return l1, avgx
Beispiel #3
0
def add_a_scheme(ax, named, scheme):
    file = find_section_file("./data/", scheme, named, "phi")
    if len(file) < 1:
        return

    fd = FT.TextFile(PATH_DATA + "/" + file[0])
    d = fd.get_data()
    ncol = 1
    if named == "x":
        ncol = 2
    l, = ax.plot(FT.col(d, ncol), FT.col(d, 4), ".")

    ncol = 2
    if named == "x":
        ncol = 1
    avg = np.average(FT.col(d, ncol))

    return l, avg
Beispiel #4
0
def plot_setion(scheme):
    plt.figure(figsize=(6, 5))
    ax = plt.axes()
    """
    Set labels
    """
    plt.xlabel(r'Y')
    plt.ylabel(r'$\phi$')
    """
    Set range
    """
    x_st = 0.2
    x_ed = 1.0
    y_st = -0.35
    y_ed = 1.35

    plt.xlim([x_st, x_ed])
    # plt.ylim([y_st, y_ed])
    #plt.xscale('log')
    # plt.yscale('log')
    """
    Data part
    """
    file = find_section_file("./data/", scheme, "phi")
    if len(file) < 1:
        return

    fd = FT.TextFile(PATH_DATA + "/" + file[0])
    d = fd.get_data()
    l1, = ax.plot(FT.col(d, 2), FT.col(d, 4), ".")

    avgx = np.average(FT.col(d, 1))

    lexact = add_section_exact(plt, avgx)
    plt.legend([l1, lexact], [scheme, "Exact"], loc='best')

    plt.text(0.3, 0.23, r'x = %.2f' % avgx, va="center")

    plt.grid(True)
    plt.tight_layout()
    plt.savefig(PATH_FIG + "/" + scheme + "_section.png")
    plt.close()