Ejemplo n.º 1
0
    x = (rad * C + alt) * cosLat * np.cos(lon)
    y = (rad * C + alt) * cosLat * np.sin(lon)
    z = (rad * S + alt) * sinLat

    return np.array([x, y, z])


print(os.path.abspath(os.curdir))
data = pd.read_csv("earthquakes.csv")
# print(data.columns)
data = data[data["Magnitude"] > 8]
data = data.filter(items=['Latitude', 'Longitude', 'Depth'])

data_np = data.values
print(data_np.shape)
data_on_sphere = put_on_sphere(np.array(list(map(LLHtoECEF, data_np))))

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_on_sphere.T
ax.scatter(xx, yy, zz, color="k", s=50)
plt.show()
Ejemplo n.º 2
0
# train_X.shape = (...., 32, 32) -> (....,1024)
image_vector_size = train_X.shape[1] * train_X.shape[2]
train_X = train_X.reshape(train_X.shape[0], image_vector_size)

# Sample from train_X #
train_samples = np.random.choice(train_X.shape[0], size=SAMPLES)
sampled_X = train_X[train_samples]

# Sampled Images #
for i in range(9):
    plt.subplot(330 + 1 + i)
    plt.imshow(sampled_X[i].reshape(m, n), cmap=plt.get_cmap('gray'))
plt.show()

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, \