pytraj.vector

pytraj.analysis.vector.vector(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)

perform vector calculation. See example below. Same as ‘vector’ command in cpptraj.

Parameters:

traj : Trajectory-like or iterable that produces pytraj.Frame

command : str or a list of strings, cpptraj command

frame_indices : array-like, optional, default None

only perform calculation for given frame indices

dtype : output’s dtype, default ‘ndarray’

top : Topology, optional, default None

Returns:

out : numpy ndarray, shape (n_frames, 3) if command is a string

numpy ndarray, shape (n_vectors, n_frames, 3) if command is a list of strings

Notes

It’s faster to calculate with a list of commands. For example, if you need to perform 3 calculations for ‘ucellx’, ‘boxcenter’, ‘box’ like below:

>>> data = pt.vector.vector(traj, "ucellx")
>>> data = pt.vector.vector(traj, "boxcenter")
>>> data = pt.vector.vector(traj, "box")

You should use a list of commands for faster calculation. >>> comlist = [‘ucellx’, ‘boxcenter’, ‘box’] >>> data = pt.vector.vector(traj, comlist)

Examples

>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2_ortho()
>>> data = pt.vector.vector(traj, "@CA @CB")
>>> data = pt.vector.vector(traj, [("@CA @CB"),])
>>> data = pt.vector.vector(traj, "principal z")
>>> data = pt.vector.vector(traj, "principal x")
>>> data = pt.vector.vector(traj, "ucellx")
>>> data = pt.vector.vector(traj, "boxcenter")
>>> data = pt.vector.vector(traj, "box")
pytraj.analysis.vector.vector_mask(traj=None, mask='', frame_indices=None, dtype='ndarray', top=None)

compute vector between two maskes

Parameters:

traj : Trajectory-like or iterable that produces Frame

mask: str or array of string or array of intergers, shape (n_vectors, 2)

vector maskes

frame_indices : array-like or iterable that produces integer number

frame indices

dtype : str, default ‘ndarray’

output dtype

top : Topology, optional, default None

Returns:

if mask is a string, return 2D ndarray, shape (n_frames, 3)

if mask is a list of strings or a 2D ndarray, return 3D ndarray, shape (n_vectors, n_frames, 3)

Examples

>>> # calcualte N-H vector
>>> import pytraj as pt
>>> import numpy as np
>>> traj = pt.load_sample_data('tz2')
>>> from pytraj import vector as va
>>> n_indices = pt.select_atoms('@N', traj.top)
>>> h_indices = n_indices + 1
>>> # create n-h pair for vector calculation
>>> n_h_pairs = np.array(list(zip(n_indices, h_indices)))
>>> data_vec = va.vector_mask(traj, n_h_pairs, dtype='ndarray')
>>> # compute vectors for specific frame indices (0, 4)
>>> data_vec = va.vector_mask(traj, n_h_pairs, frame_indices=[0, 4], dtype='ndarray')
pytraj.analysis.vector.minimage(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.dipole(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.center(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.corrplane(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.box(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.boxcenter(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.ucellx(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.ucelly(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.ucellz(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None

pytraj.analysis.vector.principal(traj=None, command='', frame_indices=None, dtype='ndarray', top=None)
Parameters:

traj : Trajectory-like

command : str or a list-like of strings

frame_indices : array-like, default None

if specified, only perform calculation with given frames

top : {str, Topology}, optional, default None