pytraj.frame

class pytraj.trajectory.frame.Frame

Bases: object

A snapshot of trajectory, hodling coordinates, unicell (box), vector (optional), force (optional), ... This class is for internal use.

Parameters:

n_atoms : int, default=0

create a new Frame with n_atoms

frame : a Frame, default=None

make a copy from frame

atommask : AtomMask, default=None

make a copy from frame with atommask

Examples

>>> import pytraj as pt
>>> # create an empty Frame
>>> frame = pt.Frame()
>>> frame.n_atoms
0
>>> # create a Frame with 304 atoms
>>> frame = pt.Frame(304)
>>> frame.n_atoms
304
>>> # create an empty Frame then append coordinate
>>> traj = pt.datafiles.load_tz2()
>>> f0 = traj[0]
>>> frame = pt.Frame()
>>> frame.append_xyz(f0.xyz)
<Frame with 223 atoms>
>>> frame.n_atoms == f0.n_atoms
True
>>> # copy from other Frame
>>> frame2 = pt.Frame(frame)
>>> # create a Frame as a pointer (does not own any memory), used for fast iterating
>>> frame = pt.Frame(f0.n_atoms, f0.xyz, _as_ptr=True)
>>> frame.n_atoms == f0.n_atoms
True

Attributes

box unitcell
coordinates return a copy of Frame’s coordinates
force force, default None
mass return mass array
n_atoms
n_frames
shape
size
temperature
time
top
velocity
xyz

Methods

append_xyz(self, __Pyx_memviewslice xyz) append 3D array and return itself
atom(self, int atomnum) return xyz coordinates of idx-th atom
center_of_geometry(self, AtomMask atmask) return Vec3 storing center of geometry
center_of_mass(self, AtomMask atmask) return Vec3 storing center of mass
copy(self) return a deep copy of Frame
has_box(self)
has_force(self)
has_velocity(self)
is_(self, Frame other) check if Frame is itself or not
rmsd(self, Frame frame, AtomMask atommask=None) Calculate rmsd betwen two frames
rmsd_nofit(self, Frame frame, bool mass=False) Calculate rmsd betwen two frames without fitting
rmsfit(self[, ref]) do the fitting to reference Frame by rotation and translation
set_mass(self, Topology top) set mass for Frame, requires a Topology
set_nobox(self) set nobox
strip(self, AtomMask atm) strip
swap_atoms swap coordinates for an array of atom pairs
to_ndarray(self) return a ndarray as a view of Frame’s coordinates
append_xyz(self, __Pyx_memviewslice xyz)

append 3D array and return itself

atom(self, int atomnum)

return xyz coordinates of idx-th atom

Examples

>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2()
>>> frame = traj[0]
>>> frame.atom(10)
array('d', [0.27399998903274536, 11.727999687194824, 8.701000213623047])
box

unitcell

center_of_geometry(self, AtomMask atmask)

return Vec3 storing center of geometry

center_of_mass(self, AtomMask atmask)

return Vec3 storing center of mass

coordinates

return a copy of Frame’s coordinates

copy(self)

return a deep copy of Frame

force

force, default None

has_box(self)
has_force(self)
has_velocity(self)
is_(self, Frame other)

check if Frame is itself or not

mass

return mass array

n_atoms
n_frames
rmsd(self, Frame frame, AtomMask atommask=None, mask=None, top=None, bool mass=False, get_mvv=False)

Calculate rmsd betwen two frames

Parameters:

frame : Frame instance

mass : bool, default = False

get_mvv : bool

if True: return rmsd, Matrix_3x3, Vec3, Vec3 if False: return rmsd

rmsd_nofit(self, Frame frame, bool mass=False)

Calculate rmsd betwen two frames without fitting

Parameters:

frame : Frame instance

mass : bool, default = False

rmsfit(self, ref=None, AtomMask atm=None)

do the fitting to reference Frame by rotation and translation

set_mass(self, Topology top)

set mass for Frame, requires a Topology

set_nobox(self)

set nobox

Examples

>>> import pytraj as pt
>>> traj = pt.datafiles.load_tz2_ortho()
>>> frame = traj[0]
>>> frame.box
<Box: ortho, (x, y, z, alpha, beta, gamma) = (35.262779662258, 41.845547679864616, 36.16862952899312, 90.0, 90.0, 90.0)>
>>> frame.set_nobox()
>>> frame.box
<Box: nobox, (x, y, z, alpha, beta, gamma) = (0.0, 0.0, 0.0, 0.0, 0.0, 0.0)>
shape
size
strip(self, AtomMask atm)

strip

Parameters:atm: AtomMask
Returns:self
swap_atoms

swap coordinates for an array of atom pairs

Parameters:int_view: 2D-int array-like, shape=(2, n_atoms)
temperature
time
to_ndarray(self)

return a ndarray as a view of Frame’s coordinates

top
velocity
xyz