Interface for reading and writing to a GROMACS XTC file. This is a file-like objec that supports both reading and writing. It also supports the context manager ptorocol, so you can use it with the python ‘with’ statement.
The conventional units in the XTC file are nanometers and picoseconds. The format only supports saving coordinates, the time, the md step, and the unit cell parametrs (box vectors)
Parameters: | filename : str
mode : {‘r’, ‘w’}
force_overwrite : bool
|
---|---|
Other Parameters: | |
min_chunk_size : int, default=100
chunk_size_multiplier : int, default=1.5
|
See also
Examples
>>> # read the data from from an XTC file
>>> with XTCTrajectoryFile('traj.xtc') as f:
>>> xyz, time, step, box = f.read()
>>> # write some random coordinates to an XTC file
>>> with XTCTrajectoryFile('output.xtc', 'w') as f:
>>> f.write(np.random.randn(10,1,3))
x.__init__(...) initializes x; see help(type(x)) for signature
Methods
close | Close the XTC file handle |
read([n_frames, stride, atom_indices]) | Read data from an XTC file |
seek(offset[, whence]) | Move to a new file position |
tell | Current file position |
write(xyz[, time, step, box]) | Write data to an XTC file |
Attributes
distance_unit |
Close the XTC file handle
Read data from an XTC file
Parameters: | n_frames : int, None
stride : int, optional
atom_indices : array_like, optional
|
---|---|
Returns: | xyz : np.ndarray, shape=(n_frames, n_atoms, 3), dtype=np.float32
time : np.ndarray, shape=(n_frames), dtype=np.float32
step : np.ndarray, shape=(n_frames), dtype=np.int32
box : np.ndarray, shape=(n_frames, 3, 3), dtype=np.float32
|
Move to a new file position
Parameters: | offset : int
whence : {0, 1, 2}
|
---|
Current file position
Returns: | offset : int
|
---|
Write data to an XTC file
Parameters: | xyz : np.ndarray, dtype=np.float32, shape=(n_frames, n_atoms, 3)
time : np.ndarray, dtype=float32, shape=(n_frames), optional
step : np.ndarray, dtype=int32, shape=(n_frames), optional
box : np.ndarray, dtype=float32, shape=(n_frames, 3, 3), optional
|
---|