1
0
Fork 0
mirror of https://github.com/glatterf42/sims_python_files.git synced 2024-09-19 16:13:45 +02:00

minor notes

This commit is contained in:
Lukas Winkler 2022-05-24 11:26:46 +02:00
parent 4d5e8bb575
commit 02d5bdcaeb
Signed by: lukas
GPG key ID: 54DE4D798D244853

View file

@ -180,13 +180,14 @@ def main():
print("...done.") print("...done.")
print("Searching neighbours...") print("Searching neighbours...")
a = time.perf_counter_ns() a = time.perf_counter_ns()
# TODO: this section could be optimized by seperating coordinates into batches that are calculated after each other
distances, indices = tree.query([coordinates], k=num_nearest_neighbors, workers=6) distances, indices = tree.query([coordinates], k=num_nearest_neighbors, workers=6)
# shape of closest_neighbours: (1, xxxx, 40) # shape of distances/indices: (1, xxxx, num_nearest_neighbors)
b = time.perf_counter_ns() b = time.perf_counter_ns()
print("...found neighbours.") print("...found neighbours.")
print(f"took {(b - a) / 1000 / 1000:.2f} ms") print(f"took {(b - a) / 1000 / 1000:.2f} ms")
distances = distances[0] # to (xxxx, 40) distances = distances[0] # to (xxxx, num_nearest_neighbors)
indices = indices[0] # to (xxxx, 40) indices = indices[0] # to (xxxx, num_nearest_neighbors)
print(distances.shape) print(distances.shape)
print(indices.shape) print(indices.shape)
print(indices) print(indices)
@ -210,6 +211,7 @@ def main():
# print(densities) # print(densities)
# print(densities.shape) # print(densities.shape)
print("aggregating data")
all_data = np.column_stack([list(range(densities.shape[0])), transformed_data, densities, alt_densities]) all_data = np.column_stack([list(range(densities.shape[0])), transformed_data, densities, alt_densities])
# print(all_data.shape) # print(all_data.shape)
# print(original_data.shape[0]) # print(original_data.shape[0])
@ -222,6 +224,7 @@ def main():
# all_data = all_data[sorted_index, :] # all_data = all_data[sorted_index, :]
# np.savetxt("out_"+filename.with_suffix(".csv").name, all_data[indices], delimiter=",", fmt="%.3f", header="x,y,z,vx,vy,vz,v,name") #if indices are needed # np.savetxt("out_"+filename.with_suffix(".csv").name, all_data[indices], delimiter=",", fmt="%.3f", header="x,y,z,vx,vy,vz,v,name") #if indices are needed
print("saving csv")
np.savetxt(f"out_{filename.with_suffix('.csv').name}", np.savetxt(f"out_{filename.with_suffix('.csv').name}",
export_data, export_data,
delimiter=",", delimiter=",",