API for the TNGFileIterator Class
- class pytng.TNGFileIterator
File handle object for TNG files
Supports use as a context manager (“with” blocks).
- block_ids
Dictionary of block names and block ids (long longs) in the TNG file
- Returns:
block_ids – dictionary of block names (keys) and block ids (values)
- Return type:
dict
- block_strides
Dictionary of block names and the strides (in integrator steps) at which they are written in the TNG file
- Returns:
block_strides – dictionary of block names (keys) and strides of each block (values)
- Return type:
dict
- current_integrator_step
- Class that retrieves data from the file at the current integrator
step
- Returns:
current_integrator_step – The data accessor at the current integrator step
- Return type:
- make_ndarray_for_block_from_id(self, int64_t block_id) ndarray
Make a NumPy array that can hold a specified block from the block id
- Parameters:
block_id (int64_t) – a block id
- Returns:
target – A NumPy array that can hold the data values for a specified block
- Return type:
np.ndarray
See also
block_ids
dict dictionary of block names (keys) and block ids (values) available in this TNG file
- make_ndarray_for_block_from_name(self, str block_name) ndarray
Make a NumPy array that can hold a specified block from the block name
- Parameters:
block_name (str) – a block name
- Returns:
target – A NumPy array that can hold the data values for a specified block
- Return type:
np.ndarray
See also
block_ids
dict dictionary of block names (keys) and block ids (values) available in this TNG file
- n_atoms
The number of atoms in the TNG file
- Returns:
n_atoms – number of atoms
- Return type:
int
- n_data_frames
Dictionary of block names and the number of actual steps with data for that block in the TNG file
- Returns:
n_data_frames – dictionary of block names (keys) and number of steps with data (values)
- Return type:
dict
- n_steps
The number of integrator steps in the TNG file
- Returns:
n_steps – number of integrator steps
- Return type:
int
- particle_dependencies
Dictionary of block names and whether the block is particle dependent
- Returns:
particle_dependencies – dictionary of block names (keys) and particle dependencies (values)
- Return type:
dict
- read_step(self, step) TNGCurrentIntegratorStep
Read a step (integrator step) from the file
- Parameters:
step (int) – step to read from the file
- Returns:
current_integrator_step – The data accessor at the current integrator step
- Return type:
- Raises:
ValueError – attempt to read a negative step or step number greater than that in the input file
- step
The current integrator step being read
- Returns:
step – the current step in the TNG file
- Return type:
int
- values_per_frame
Dictionary of block names and the number of values per frame for the block
- Returns:
values_per_frame – dictionary of block names (keys) and number of values per frame (values)
- Return type:
dict
- class pytng.TNGCurrentIntegratorStep
Retrieves data at the curent trajectory step
- frame_strides_blockid
frame_stride
- Returns:
frame_strides_blockid – Dictionary of frame strides
- Return type:
dict
- Type:
Dictionary of blockid
- get_blockid(self, int64_t block_id, ndarray data)
Get a block ID present at the current step and read it into a NumPy array
- Parameters:
block_id (int64_t) – TNG block id to read from the current step
data (np.ndarray) – NumPy array to read the data into, the required shape is determined by the block dependency and the number of values per frame.
- Raises:
TypeError – The dtype of the numpy array provided is not supported by TNG datatypes or does not match the underlying datatype.
IOError – The block data type cannot be understood.
IndexError – The shape of the numpy array provided does not match the shape of the data to be read from disk.
- get_box(self, ndarray data) ndarray
Get the box vectors present at the current step and read them into a NumPy array. The box vectors are a (3,3) matrix comprised of 3 three-dimensional basis vectors for the coordinate system of the simulation. The vectors can be accessed in their proper shape by reshaping the resulting (1,9) matrix to be (3,3) with ndarray.reshape(3,3).
- Parameters:
data (np.ndarray) – NumPy array to read the data into. As this is NOT a particle dependent block, the shape should be (1, n_values_per_frame) ie (1,9)
- get_forces(self, ndarray data) ndarray
Get the forces present at the current step and read them into a NumPy array
- Parameters:
data (np.ndarray) – NumPy array to read the data into. As this is a particle dependent block, the shape should be (n_atoms, n_values_per_frame) ie (n_atoms, 3).
- get_positions(self, ndarray data) ndarray
Get the positions present at the current step and read them into a NumPy array
- Parameters:
data (np.ndarray) – NumPy array to read the data into. As this is a particle dependent block, the shape should be (n_atoms, n_values_per_frame) ie (n_atoms, 3).
- get_time(self)
Get the time of the current integrator step being read from the file
- Returns:
time – the time of the current step
- Return type:
int
- get_velocities(self, ndarray data) ndarray
Get the velocities present at the current step and read them into a NumPy array
- Parameters:
data (np.ndarray) – NumPy array to read the data into. As this is a particle dependent block, the shape should be (n_atoms, n_values_per_frame) ie (n_atoms, 3).
- read_success
Indicates whether the last attempt to read data was successful
- Returns:
read_success – Whether the last attempt to read data was successful
- Return type:
bool
- step
The current integrator step being read
- Returns:
step – the current step in the TNG file
- Return type:
int