Trajectory Loader#

Automatic loading of trajectories from a directory.

class nearl.io.trajloader.TrajectoryLoader(trajs=None, trajtype=None, trajids=None, **kwarg)[source]#

Bases: object

A class to systematically load trajectories for further processing in the pipeline.

Parameters:
trajsstr or list

A list of trajectories to be loaded

trajtypetrajectory_like

The trajectory type to be used while loading the trajectory

**kwargdict

The loading options (stride, frame_indices, mask)

Examples

import nearl
import nearl.data
trajs = [
  nearl.data.MINI_TRAJ,
  nearl.data.MINI_TRAJ,
  nearl.data.MINI_TRAJ,
  nearl.data.MINI_TRAJ,
]
loader = nearl.TrajectoryLoader(trajs)
print(f"{len(loader)} trajectories detected")  # 4 trajectories detected
loader[3].visualize()  # Visualize the last trajectory
print(loader.loading_options)  # Print the loading options
for traj in loader:
  print(traj)  # Print the trajectory information
Attributes:
trajslist

A list of trajectories to be loaded

trajtypetrajectory_like, optional, default = nearl.io.traj.Trajectory

The trajectory type to be used while loading the trajectory

loading_optionsdict, optional

Get the loading options (stride, frame_indices, mask)

property loading_options#

Get the loading options (stride, frame_indices, mask)

get_loading_options(index)[source]#

Get the loading options if the user manually defines the loading options for specific trajectories

Parameters:
indexint

The index of the trajectory object to be retrieved

append(trajs=None, trajtype=None, **kwarg)[source]#

Append a trajectory or a list of trajectories to the trajectory loader.

Parameters:
trajsstr or list

Trajectory file names

trajtypetrajectory_like, optional, default = nearl.io.traj.Trajectory

The trajectory type to be used while loading the trajectory