{"action":"created","issue":{"url":"https://api.github.com/repos/pytraj/pytraj/issues/358","labels_url":"https://api.github.com/repos/pytraj/pytraj/issues/358/labels{/name}","comments_url":"https://api.github.com/repos/pytraj/pytraj/issues/358/comments","events_url":"https://api.github.com/repos/pytraj/pytraj/issues/358/events","html_url":"https://github.com/pytraj/pytraj/issues/358","id":79238501,"number":358,"title":"Q&A","user":{"login":"hainm","id":4451957,"avatar_url":"https://avatars.githubusercontent.com/u/4451957?v=3","gravatar_id":"","url":"https://api.github.com/users/hainm","html_url":"https://github.com/hainm","followers_url":"https://api.github.com/users/hainm/followers","following_url":"https://api.github.com/users/hainm/following{/other_user}","gists_url":"https://api.github.com/users/hainm/gists{/gist_id}","starred_url":"https://api.github.com/users/hainm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hainm/subscriptions","organizations_url":"https://api.github.com/users/hainm/orgs","repos_url":"https://api.github.com/users/hainm/repos","events_url":"https://api.github.com/users/hainm/events{/privacy}","received_events_url":"https://api.github.com/users/hainm/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-05-22T01:48:47Z","updated_at":"2015-05-22T05:36:01Z","closed_at":null,"body":"Draft for Q&A (will be copied to ipython-notebook)\r\n\r\n#### pytraj developers don't recommnd to use traj.xyz  (as a numpy 3D array with shape=(n_frames, n_atoms, 3))?\r\n\r\nBecause `Trajectory` object in `pytraj` is a wrapper of C++ vector<Frame> in `cpptraj`. Everytime calling `traj.xyz` method, a copy of 3D array is made. User can not inplace update coords of each frame or specific atoms. Instead using traj[index] to do this. However, `traj.xyz` is still available to conviently access read-only data.\r\n\r\n```python\r\ntraj['@CA'] = xyz # inplace update `xyz` coords of all CA atoms\r\n```\r\n\r\nSo why not designing `xyz` as `mdtraj` with numpy? Because `cpptraj` already has more than few hundreds types of action/analysis combination (from things very simple like calculating distance, dihedral, ... to very smart 'autoimage' action). If we design like `mdtraj`, we need to copy data from `Frame` object (cpptraj) to numpy data. If we want to use `cpptraj`'s action/analysis, we again need to copy data from numpy back to `Frame` object."},"comment":{"url":"https://api.github.com/repos/pytraj/pytraj/issues/comments/104516719","html_url":"https://github.com/pytraj/pytraj/issues/358#issuecomment-104516719","issue_url":"https://api.github.com/repos/pytraj/pytraj/issues/358","id":104516719,"user":{"login":"hainm","id":4451957,"avatar_url":"https://avatars.githubusercontent.com/u/4451957?v=3","gravatar_id":"","url":"https://api.github.com/users/hainm","html_url":"https://github.com/hainm","followers_url":"https://api.github.com/users/hainm/followers","following_url":"https://api.github.com/users/hainm/following{/other_user}","gists_url":"https://api.github.com/users/hainm/gists{/gist_id}","starred_url":"https://api.github.com/users/hainm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hainm/subscriptions","organizations_url":"https://api.github.com/users/hainm/orgs","repos_url":"https://api.github.com/users/hainm/repos","events_url":"https://api.github.com/users/hainm/events{/privacy}","received_events_url":"https://api.github.com/users/hainm/received_events","type":"User","site_admin":false},"created_at":"2015-05-22T05:36:01Z","updated_at":"2015-05-22T05:36:01Z","body":"#### Should I use `Trajectory` class or `TrajectoryIterator`?\r\n\r\nif memory is not a big problem, you should use `Trajectory` class, which hold a chunks of frames in memory. Things are much faster (like frame iterator). However, if the trajectory file is too big, it's highly recommended to use `TrajectoryIterator` to save memory. You still can use fancy indexing for this iterator (either returning a `Frame` or a mutable `Trajectory` object)\r\n\r\n"}}