Ejemplo n.º 1
0
def plot_pcd(dim_pcd, num_intensity, val_radius, num_pd, name_dir_data):
    print("saving pcd as png")
    name_dir_plot = "%s/plot_pcd%s_intensity%s_radius%03d_num%s" % (
        name_dir_data, dim_pcd, num_intensity, val_radius * 100, num_pd)

    functions.mkdir_os(name_dir_plot)
    # "../matern/plot_pcd2_intensity200_radius003_num10"

    for idx_num in range(num_pd):
        mat_pcd_poisson = poisson_pp(num_intensity, dim_pcd)
        mat_pcd_matern_one = matern_one_pp(mat_pcd_poisson, val_radius)
        mat_pcd_matern_two = matern_two_pp(mat_pcd_poisson, val_radius)

        vec_lim = np.array([-0.1, 1.1])
        functions.plot_pcd(mat_pcd_poisson,
                           "%s/type0_%s.png" % (name_dir_plot, idx_num),
                           x_lim=vec_lim,
                           y_lim=vec_lim,
                           z_lim=vec_lim)
        functions.plot_pcd(mat_pcd_matern_one,
                           "%s/type1_%s.png" % (name_dir_plot, idx_num),
                           x_lim=vec_lim,
                           y_lim=vec_lim,
                           z_lim=vec_lim)
        functions.plot_pcd(mat_pcd_matern_two,
                           "%s/type2_%s.png" % (name_dir_plot, idx_num),
                           x_lim=vec_lim,
                           y_lim=vec_lim,
                           z_lim=vec_lim)
Ejemplo n.º 2
0
def make_pcd(dim_pcd, num_intensity, val_radius, num_pd, name_dir_data):
    name_dir_pcd = "%s/pcd%s_intensity%s_radius%03d_num%s" % (
        name_dir_data, dim_pcd, num_intensity, val_radius * 100, num_pd)
    functions.mkdir_os(name_dir_pcd)
    # "../matern/pcd2_intensity200_radius003_num100"

    for i in range(3):
        functions.mkdir_pcd("%s/type%s" % (name_dir_pcd, i))
        # "../matern/pcd2_intensity200_radius003_num100/type0/pcd_pd"

    for idx_num in range(num_pd):
        if idx_num % 10 == 0:
            print("pcd_%s" % idx_num)
        else:
            pass
        mat_pcd_poisson = poisson_pp(num_intensity, dim_pcd)
        mat_pcd_matern_one = matern_one_pp(mat_pcd_poisson, val_radius)
        mat_pcd_matern_two = matern_two_pp(mat_pcd_poisson, val_radius)

        np.savetxt("%s/type0/pcd_pd/pcd_%s.txt" % (name_dir_pcd, idx_num),
                   mat_pcd_poisson,
                   delimiter='\t')
        np.savetxt("%s/type1/pcd_pd/pcd_%s.txt" % (name_dir_pcd, idx_num),
                   mat_pcd_matern_one,
                   delimiter='\t')
        np.savetxt("%s/type2/pcd_pd/pcd_%s.txt" % (name_dir_pcd, idx_num),
                   mat_pcd_matern_two,
                   delimiter='\t')
Ejemplo n.º 3
0
def plot_pd(name_dir_plot, name_pcd, list_pd, vec_range=None):
    functions.mkdir_os(name_dir_plot)
    # "../lattice/plot_pd1_pcd2_side20_square010_num100"

    num_pd = len(list_pd)
    if vec_range is None:
        vec_min = np.empty(num_pd)
        vec_max = np.empty(num_pd)
        for _k in range(num_pd):
            mat_pd = list_pd[_k]
            vec_min[_k] = np.min(mat_pd[:, 0])
            vec_max[_k] = np.max(mat_pd[:, 1])
        val_min = np.min(vec_min)
        val_max = np.max(vec_max)
    else:
        val_min, val_max = vec_range

    val_pers = val_max - val_min
    val_ratio = 0.2
    val_min -= val_ratio * val_pers
    val_max += val_ratio * val_pers

    for k in range(num_pd):
        mat_pd = list_pd[k]
        fig = plt.figure()
        ax = fig.add_subplot(111)
        hist = ax.hist2d(mat_pd[:, 0],
                         mat_pd[:, 1],
                         bins=[
                             np.linspace(val_min, val_max, 80),
                             np.linspace(val_min, val_max, 80)
                         ],
                         norm=matplotlib.colors.LogNorm())

        num_multiplicity = int(hist[1].max() + 1)
        if num_multiplicity > 3:
            hist[3].set_clim(1, num_multiplicity)
        else:
            hist[3].set_clim(1, int(10**num_multiplicity))
        fig.colorbar(hist[3], ax=ax)

        x = np.linspace(val_min, val_max, 2)
        plt.plot(x, x, "k-", linewidth=0.3)
        plt.savefig("%s/%s_%s.png" % (name_dir_plot, name_pcd, k))
        # "../lattice/plot_pd1_pcd2_side20_square010_num100/square010_3.png"
        plt.close()
Ejemplo n.º 4
0
def plot_pcd(num_sample, num_pd, name_dir_data):
    print("saving pcd as png")
    val_r_small = 2
    name_dir_plot = "%s/plot_pcd3_sample%s_num%s" % (name_dir_data, num_sample,
                                                     num_pd)
    functions.mkdir_os(name_dir_plot)
    # "../torus/plot_pcd3_sample500_num40"

    for idx_num in range(num_pd):
        mat_pcd = make_torus(val_r_big=val_r_small * (0.5 +
                                                      (idx_num / num_pd)),
                             val_r_small=val_r_small,
                             num_sample=num_sample)

        functions.plot_pcd(mat_pcd,
                           "%s/torus_%s.png" % (name_dir_plot, idx_num),
                           markersize=2,
                           z_lim=np.array(
                               [-1.5 * val_r_small, 1.5 * val_r_small]))
Ejemplo n.º 5
0
def main():
    args = parser_()
    name_dir = args.path
    name_data = args.data
    num_pd = args.num_pd
    dim_pcd = args.dim_pcd
    num_side = args.side
    num_intensity = args.intensity
    val_radius = args.radius
    num_sample = args.sample

    functions.mkdir_os(name_dir)
    name_dir_data = "%s/%s" % (name_dir, name_data)
    functions.mkdir_os(name_dir_data)

    if name_data == "lattice":
        list_param = [["gauss", 0.10]]
        list_param.extend([["square", np.sqrt(i + 2) * 0.10] for i in range(3)])
        lattice.make_pcd(list_param, dim_pcd, num_side, num_pd, name_dir_data)
        lattice.plot_pcd(list_param, dim_pcd, 5, 10, name_dir_data)

    elif name_data == "matern":
        matern.make_pcd(dim_pcd, num_intensity, val_radius, num_pd,
                        name_dir_data)
        matern.plot_pcd(dim_pcd, num_intensity, val_radius, 10, name_dir_data)

    elif name_data == "circle":
        circle.make_pcd(num_pd, name_dir_data)
        circle.plot_pcd(10, name_dir_data)

    elif name_data == "torus":
        torus.make_pcd(num_sample, num_pd, name_dir_data)
        torus.plot_pcd(num_sample, num_pd, name_dir_data)

    else:
        pass
Ejemplo n.º 6
0
def plot_pcd(num_pd, name_dir_data):
    print("saving pcd as png")
    name_dir_plot = "%s/plot_pcd2_num%s" % (name_dir_data, num_pd)
    functions.mkdir_os(name_dir_plot)
    # "../circle/plot_pcd2_num200"

    for idx_num in range(num_pd):
        val_radius = 1 + 8 * np.power(np.random.uniform(0, 1), 2)
        vec_center = np.array([
            np.power(np.random.uniform(0, 2), 2),
            np.power(np.random.uniform(0, 2), 2)
        ]) + 1.5 * val_radius
        num_points = int(
            np.ceil(
                np.random.randint(np.ceil(np.pi * val_radius / 2), 4 * np.pi *
                                  val_radius)) + (2 * np.random.uniform(0, 1)))
        if num_points < 4:
            num_points = 4
        else:
            pass

        mat_pcd = make_circle(vec_center, val_radius, num_points)
        idx_label = "f"
        if np.random.rand(1) > 0.5:
            idx_label = "t"
            mat_pcd = np.r_[mat_pcd, make_circle([0, 0], 0.2, 10)]
        else:
            pass

        vec_lim = np.array([-2, 15])
        functions.plot_pcd(mat_pcd[:, 0:2],
                           "%s/circle_%s_%s.png" %
                           (name_dir_plot, idx_label, idx_num),
                           markersize=2,
                           x_lim=vec_lim,
                           y_lim=vec_lim)
Ejemplo n.º 7
0
def plot_pcd(list_param, dim_pcd, num_side, num_pd, name_dir_data):
    print("saving pcd as png")
    num_param = len(list_param)
    for idx_param in range(num_param):
        name_dir_plot = "%s/plot_pcd%s_side%s_num%s" % (name_dir_data, dim_pcd,
                                                        num_side, num_pd)
        functions.mkdir_os(name_dir_plot)
        # "../lattice/plot_pcd2_side20_num20"

        for idx_num in range(num_pd):
            list_pcd = make_lattice(num_side, dim_pcd)
            num_pcd = len(list_pcd)
            for idx_point in range(num_pcd):
                list_pcd[idx_point] += measure(list_param[idx_param][0],
                                               list_param[idx_param][1],
                                               dim_pcd)
            vec_lim = np.array([-1, num_side])
            functions.plot_pcd(np.asarray(list_pcd),
                               "%s/%s%03d_%s.png" %
                               (name_dir_plot, list_param[idx_param][0],
                                list_param[idx_param][1] * 100, idx_num),
                               x_lim=vec_lim,
                               y_lim=vec_lim,
                               z_lim=vec_lim)
Ejemplo n.º 8
0
def main():
    print("saving pd as png")
    args = parser_()
    name_dir = args.path
    name_data = args.data
    num_pd = args.num_pd
    num_plot = args.num_plot
    dim_pcd = args.dim_pcd
    dim_pd = args.dim_pd
    scale = args.scale

    num_side = args.side
    num_intensity = args.intensity
    val_radius = args.radius
    num_sample = args.sample

    name_dir_data = "%s/%s" % (name_dir, name_data)

    if name_data == "lattice":
        list_param = [["gauss", 0.10]]
        list_param.extend([["square", np.sqrt(i + 2) * 0.10]
                           for i in range(3)])
        name_dir_plot = "%s/plot_pd%s_pcd%s_side%s_num%s" % (
            name_dir_data, dim_pd, dim_pcd, num_side, num_pd)
        functions.mkdir_os(name_dir_plot)
        # "../lattice/plot_pd1_pcd2_side20_num100"
        for i in range(4):
            name_pcd = "%s%03d" % (list_param[i][0], list_param[i][1] * 100)
            name_dir_pcd = "%s/pcd%s_side%s_%s_num%s" % (
                name_dir_data, dim_pcd, num_side, name_pcd, num_pd)
            # "../lattice/pcd2_side20_square010_num100"
            list_pd = make_list_pd(name_dir_pcd, num_plot, dim_pd, scale=scale)
            plot_pd(name_dir_plot,
                    name_pcd,
                    list_pd,
                    vec_range=np.array([0.4, 0.8]))
            # "../lattice/plot_pd1_pcd2_side20_num10/square010_3.png"

    elif name_data == "matern":
        name_dir_plot = "%s/plot_pd%s_pcd%s_intensity%s_radius%03d_num%s" % (
            name_dir_data, dim_pd, dim_pcd, num_intensity, val_radius * 100,
            num_pd)
        functions.mkdir_os(name_dir_plot)
        # "../matern/plot_pd1_pcd2_intensity200_radius003_num100
        for i in range(3):
            name_dir_pcd = "%s/pcd%s_intensity%s_radius%03d_num%s/type%s" % (
                name_dir_data, dim_pcd, num_intensity, val_radius * 100,
                num_pd, i)
            # "../matern/pcd2_intensity200_radius003_num100"
            list_pd = make_list_pd(name_dir_pcd, num_plot, dim_pd, scale=scale)
            plot_pd(name_dir_plot,
                    "type%s" % i,
                    list_pd,
                    vec_range=np.array([0, 0.15]))
            # "../matern/pcd2_intensity200_radius003_num100/type1_3.png"

    elif name_data == "circle":
        name_dir_plot = "%s/plot_pd%s_pcd3_num%s" % (name_dir_data, dim_pd,
                                                     num_pd)
        functions.mkdir_os(name_dir_plot)
        # "../circle/plot_pd1_pcd3_num200"
        name_dir_pcd = "%s/pcd3_num%s" % (name_dir_data, num_pd)
        # "../circle/pcd3_num200"
        list_pd = make_list_pd(name_dir_pcd, num_plot, dim_pd, scale=scale)
        plot_pd(name_dir_plot, "cricle", list_pd, vec_range=np.array([0, 15]))

    elif name_data == "torus":
        name_dir_plot = "%s/plot_pd%s_pcd3_sample%s_num%s" % (
            name_dir_data, dim_pd, num_sample, num_pd)
        functions.mkdir_os(name_dir_plot)
        # "../torus/plot_pd1_pcd3_sample500_num40/pcd_pd"
        name_dir_pcd = "%s/pcd3_sample%s_num%s" % (name_dir_data, num_sample,
                                                   num_pd)
        # "../torus/pcd3_sample500_num40/pcd_pd"
        list_pd = make_list_pd(name_dir_pcd, num_plot, dim_pd, scale=scale)
        plot_pd(name_dir_plot, "torus", list_pd, vec_range=np.array([0, 2]))

    else:
        pass