-
Notifications
You must be signed in to change notification settings - Fork 657
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Principle Axes documentation is confusing (in tutorial) and missing (in the docs) #1828
Comments
Primarily this concerns the tutorial, see https://github.com/MDAnalysis/MDAnalysisTutorial/issues/18, but we should also properly document the AtomGroup.principal_axes() and moment_of_inertia() methods. |
import numpy as np
import MDAnalysis as mda
from MDAnalysis.tests.datafiles import PSF, DCD
u = mda.Universe(PSF, DCD)
ca = u.select_atoms("name CA")
U = ca.principal_axes()
I = ca.moment_of_inertia()
# NOTE: U.I.UT instead of UT.I.U because of #33
Lambda = U.dot(I.dot(U.T))
print(Lambda)
# check that it is diagonal (to machine precision)
np.allclose(Lambda - np.diag(np.diagonal(Lambda)), 0) gives
|
Or we can simply say that UT = ca.principal_axes()
I = ca.moment_of_inertia()
U = UT.T
Lambda = UT.dot(I.dot(U)) |
Btw, we should also use |
Where is the documentation for principal_axes() and for moment_of_inertia()???? It is not part of AtomGroup – is this because it is transplanted from @richardjgowers how do we get this back into the docs? ( EDIT: I raised #1845 |
The docs are not really wrong but it is confusing that the principal axes are returned as row-vectors and not as column vectors. See my answer https://stackoverflow.com/a/49268247 for details. |
@lilyminium does this ring a bell for you? |
This should probably go into the list of AtomGroup methods I've been procrastinating on. For now, I think it would be good to explicitly say that it returns the transpose of the eigenvector matrix in the docstring. I guess you could also convert it to a tuple or list or iterator to make it more obvious, but a) that would mess up anyone already using FYI Mathematica does the same thing with |
Let's just state clearly that EDIT: see https://www.mdanalysis.org/MDAnalysisTutorial/atomgroups.html#principalaxes |
Expected behaviour
The principal axes coordinates are not transposed.
Actual behaviour
principal axes coordinates are transposed.
Code to reproduce the behaviour
Currently version of MDAnalysis:
(run
python -c "import MDAnalysis as mda; print(mda.__version__)"
)0.17.0
EDIT: fixed matrix multiplication
The text was updated successfully, but these errors were encountered: