frame_slicing

mdtools.check.frame_slicing(start, stop, step, n_frames_tot=None, verbose=True)[source]

Check if the input parameters are suitable for slicing MDAnalysis trajectories.

Basically, the same rules as for slicing numpy arrays apply with the following limitations:

  • start must be positive or zero, but smaller than stop.

  • stop must be positive and greater than start but not greater than n_frames_tot (if supplied).

  • step must be positive but not greater than stop - start.

  • n_frames_tot must be positive (if supplied).

In fact, the limitations for slicing MDAnalysis trajectories are not that strict, but to ensure consistent user input for MDTools scripts, we have set up the above limitations.

Parameters:
  • start (int) – Start of the interval. The interval includes this value. Note that frame numbering starts at zero.

  • stop (int) – End of the interval. The interval excludes(!) this value.

  • step (int) – Step width.

  • n_frames_tot (int, optional) – A total value that stop must not exceed (usually the length of the trajectory). Must be positive.

  • verbose (bool, optional) – If True (default), any changes of the input parameters are printed to standard output.

Returns:

  • start (int) – The input or a corrected start point.

  • stop (int) – The input or a corrected end point.

  • step (int) – The input or a corrected step width.

  • n_frames (int) – The number of selected frames.

See also

mdtools.check.block_averaging()

Check if the number of blocks for block averaging is chosen properly

mdtools.check.frame_lag()

Check if a frame lag (‘lag time’) is chosen properly

mdtools.check.time_step()

Check whether all frames in a MDAnalysis trajectory have the same time step

MDAnalysis.coordinates.base.ReaderBase.check_slice_indices()

Check if frame indices are valid to slice a MDAnalysis trajectory

MDAnalysis.coordinates.base.FrameIteratorSliced

Iterable over the frames of a trajectory on the basis of a slice