Created
January 30, 2018 18:58
-
-
Save mattwthompson/3071329482f2bd0cf958d60bc96e7186 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def find_nearest(distances, val): | |
idx = (np.abs(distances[:, 1] - val)).argmin() | |
return distances[idx, 0] | |
spacing = 0.05 | |
distances = np.loadtxt('distance_summary.dat') | |
min_val = np.floor(np.min(distances[:, 1]) / spacing) * spacing | |
max_val = np.ceil(np.max(distances[:, 1]) / spacing) * spacing | |
num_val = 1 + int((max_val - min_val) / spacing) | |
print('conf #\tCOM distance') | |
for val in np.linspace(min_val, max_val, num_val): | |
idx = find_nearest(distances, val) | |
print(int(idx), '\t', round(val, 3)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment