Skip to content
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

DEMO: read and write forces #18

Open
hainm opened this issue Jun 16, 2016 · 1 comment
Open

DEMO: read and write forces #18

hainm opened this issue Jun 16, 2016 · 1 comment

Comments

@hainm
Copy link
Owner

hainm commented Jun 16, 2016

script

from __future__ import print_function
from parmed.utils.netcdf import netcdf_file
import pytraj as pt
import numpy as np

fh = netcdf_file('data/mdfrc', mmap=False) # change mdfrc to your force filename
forces = fh.variables['forces']

# do similar thing for velocities

top = pt.load_topology('data/mdfrc.prmtop') # change prmtop to your parm7 filename
traj = pt.Trajectory(xyz=np.ascontiguousarray(forces[:], dtype='f8'), top=top)
print('original trajectory', traj)

# strip atom atoms
# change ':1-100' to your mask (e.g ':WAT')
new_traj = pt.strip(':1-100', traj)
print('stripped trajectory', new_traj)

# write trajectory
new_traj.save('test.nc', overwrite=True)
@hainm
Copy link
Owner Author

hainm commented Jun 16, 2016

expectation:

force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant