def testing_boundary_flow_noisy_parallel():
    data = pd.read_csv('Sample_Data/data13.csv')
    data_np = data.to_numpy()
    data_np = data_np.T[1:]
    noisy_data = noising_data(data_np, 0.03,
                              seed=998)  # good seed, don't change!!
    noisy_data = put_on_sphere(noisy_data)
    final_p = sphere_centroid_finder_vecs(noisy_data, 3, 0.05, 0.01)
    #print(final_p)
    h = choose_h_gaussian(
        noisy_data, final_p,
        50)  # needs to be very high! # needs to be very high!
    radius = choose_h_binary(noisy_data, final_p, 30)
    upper, curve, lower, upper_directions, lower_directions = principal_boundary(
        noisy_data,
        3,
        0.02,
        h,
        radius,
        start_point=final_p,
        kernel_type="gaussian",
        max_iter=10,
        parallel_transport=True)
    #print(curve)
    x_upper, y_upper, z_upper = upper.T
    x_curve, y_curve, z_curve = curve.T
    x_lower, y_lower, z_lower = lower.T
    x_upperv, y_upperv, z_upperv = upper_directions.T
    x_lowerv, y_lowerv, z_lowerv = lower_directions.T

    phi = np.linspace(0, np.pi, 20)
    theta = np.linspace(0, 2 * np.pi, 40)
    x = np.outer(np.sin(theta), np.cos(phi))
    y = np.outer(np.sin(theta), np.sin(phi))
    z = np.outer(np.cos(theta), np.ones_like(phi))

    fig, ax = plt.subplots(1, 1, subplot_kw={'projection': '3d'})
    ax.plot_surface(x, y, z, color='k', rstride=1, cstride=1,
                    alpha=0.1)  # alpha affects transparency of the plot
    xx, yy, zz = noisy_data.T
    ax.scatter(xx, yy, zz, color="k", s=50)

    ax.plot(x_curve, y_curve, z_curve, color="r", s=50)
    ax.quiver(x_upper,
              y_upper,
              z_upper,
              x_upperv,
              y_upperv,
              z_upperv,
              length=0.05,
              color="b")
    ax.quiver(x_lower,
              y_lower,
              z_lower,
              x_lowerv,
              y_lowerv,
              z_lowerv,
              length=0.05,
              color="g")
    plt.show()
Beispiel #2
0
def testing_boundary_flow():
    data = pd.read_csv('Sample_Data/data5.csv')
    data_np = data.to_numpy()
    data_np = data_np.T[1:]
    final_p = sphere_centroid_finder_vecs(data_np, 3, 0.05, 0.01)
    #print(final_p)
    h = choose_h_gaussian(data_np, final_p, 20) # needs to be very high! # needs to be very high!
    radius = choose_h_binary(data_np, final_p, 50)
    upper, curve, lower = principal_boundary(data_np, 3, 0.02, h, radius, start_point=final_p, kernel_type="gaussian", max_iter=10)
    #print(curve)
    x_upper, y_upper, z_upper = upper.T
    x_curve, y_curve, z_curve = curve.T
    x_lower, y_lower, z_lower = lower.T

    phi = np.linspace(0, np.pi, 20)
    theta = np.linspace(0, 2 * np.pi, 40)
    x = np.outer(np.sin(theta), np.cos(phi))
    y = np.outer(np.sin(theta), np.sin(phi))
    z = np.outer(np.cos(theta), np.ones_like(phi))

    fig, ax = plt.subplots(1, 1, subplot_kw={'projection':'3d'})
    ax.plot_surface(x, y, z, color='k', rstride=1, cstride=1, alpha=0.1) # alpha affects transparency of the plot
    xx, yy, zz = data_np.T
    ax.scatter(xx, yy, zz, color="k", s=50)
    ax.scatter(x_curve, y_curve, z_curve, color="r", s=50)
    ax.scatter(x_upper, y_upper, z_upper, color="b", s=50)
    ax.scatter(x_lower, y_lower, z_lower, color="g", s=50)

    plt.show()

#testing_boundary_flow()
Beispiel #3
0
sampled_X_on_sphere = put_on_sphere(sampled_X)
# print(sampled_X_on_sphere[0])

# Find centroid of data #
final_p = sphere_centroid_finder_vecs(sampled_X_on_sphere, sampled_X.shape[1],
                                      0.05, 0.01)
# print(final_p)

final_p_img = final_p.reshape(m, n)
plt.imshow(final_p_img, cmap=plt.get_cmap('gray'))
plt.show()

h = choose_h_gaussian(sampled_X_on_sphere, final_p,
                      85)  # needs to be very high!
radius = choose_h_binary(sampled_X_on_sphere, final_p, 40)
upper, curve, lower = principal_boundary(sampled_X_on_sphere, sampled_X.shape[1], 0.02, h, radius, \
    start_point=final_p, kernel_type="gaussian", max_iter=40)

print("upper")
for j in range(5):
    for i in range(9):
        plt.subplot(330 + 1 + i)
        plt.imshow(upper[i + 9 * j].reshape(m, n), cmap=plt.get_cmap('gray'))
    plt.show()

print("curve")
for j in range(5):
    for i in range(9):
        plt.subplot(330 + 1 + i)
        plt.imshow(curve[i + 9 * j].reshape(m, n), cmap=plt.get_cmap('gray'))
    plt.show()
print("lower")