Compare commits
5 Commits
f6ff7606ad
...
feature/co
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6b7641f152 | ||
|
|
cd7097ad46 | ||
|
|
a0ca2d8657 | ||
|
|
9ff3badab1 | ||
|
|
0f47475f22 |
@@ -434,6 +434,34 @@ def center_of_masses(
|
|||||||
]
|
]
|
||||||
).T[mask]
|
).T[mask]
|
||||||
return np.array(positions)
|
return np.array(positions)
|
||||||
|
|
||||||
|
|
||||||
|
@map_coordinates
|
||||||
|
def center_of_atoms(
|
||||||
|
frame: CoordinateFrame, atom_indices=None, shear: bool = False
|
||||||
|
) -> NDArray:
|
||||||
|
if atom_indices is None:
|
||||||
|
atom_indices = list(range(len(frame)))
|
||||||
|
res_ids = frame.residue_ids[atom_indices]
|
||||||
|
if shear:
|
||||||
|
coords = frame[atom_indices]
|
||||||
|
box = frame.box
|
||||||
|
sort_ind = res_ids.argsort(kind="stable")
|
||||||
|
i = np.concatenate([[0], np.where(np.diff(res_ids[sort_ind]) > 0)[0] + 1])
|
||||||
|
coms = coords[sort_ind[i]][res_ids - min(res_ids)]
|
||||||
|
cor = pbc_diff(coords, coms, box)
|
||||||
|
coords = coms + cor
|
||||||
|
else:
|
||||||
|
coords = frame.whole[atom_indices]
|
||||||
|
mask = np.bincount(res_ids)[1:] != 0
|
||||||
|
positions = np.array(
|
||||||
|
[
|
||||||
|
np.bincount(res_ids, weights=c)[1:]
|
||||||
|
/ np.bincount(res_ids)[1:]
|
||||||
|
for c in coords.T
|
||||||
|
]
|
||||||
|
).T[mask]
|
||||||
|
return np.array(positions)
|
||||||
|
|
||||||
|
|
||||||
@map_coordinates
|
@map_coordinates
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ def shifted_correlation(
|
|||||||
num_frames = int(len(frames) * window)
|
num_frames = int(len(frames) * window)
|
||||||
ls = np.logspace(0, np.log10(num_frames + 1), num=points)
|
ls = np.logspace(0, np.log10(num_frames + 1), num=points)
|
||||||
idx = np.unique(np.int_(ls) - 1)
|
idx = np.unique(np.int_(ls) - 1)
|
||||||
t = np.array([frames[i].time for i in idx]) - frames[0].time
|
dt = round(frames[1].time - frames[0].time, 6) # round to avoid bad floats
|
||||||
|
t = idx * dt
|
||||||
|
|
||||||
result = np.array(
|
result = np.array(
|
||||||
[
|
[
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ def nojump(frame: CoordinateFrame, usecache: bool = True) -> CoordinateFrame:
|
|||||||
).T
|
).T
|
||||||
|
|
||||||
delta = delta[selection, :]
|
delta = delta[selection, :]
|
||||||
delta = delta @ frame.box
|
delta = np.array(delta @ frame.box)
|
||||||
return frame - delta
|
return frame - delta
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user