trans_per_state_vs_time
- mdtools.dtrj.trans_per_state_vs_time(dtrj, time_axis=-1, cmp_axis=0, **kwargs)[source]
Count the number of transitions leading into or out of a state for each frame in a discrete trajectory.
- Parameters:
dtrj (
array_like
) – Array containing the discrete trajectory.time_axis (
int
) – The axis of dtrj that holds the trajectory frames. This is the axis along which to search for state transitions. For ordinary discrete trajectories with shape(n, f)
or(f,)
, wheren
is the number of compounds andf
is the number of frames, set time_axis to-1
. If you parse a transposed discrete trajectory of shape(f, n)
, set time_axis to0
.cmp_axis (
int
) – The axis of dtrj that holds the compounds. This is the axis along which the histograms will be computed. For ordinary discrete trajectories, set cmp_axis to0
. For transposed discrete trajectory, set cmp_axis to-1
.kwargs (
dict
, optional) – Additional keyword arguments to parse tomdtools.dtrj.locate_trans()
. See there for possible choices. This function sets the following default values:pin = "end"
trans_type = None
min_state = None
max_state = None
- Returns:
hist_start (
numpy.ndarray
ortuple
) – 2d array or tuple of 2d arrays (if trans_type is'both'
or an iterable of ints) containing one histogram for each frame in dtrj. The histograms count how many state transitions started from a given state, i.e. how many transitions led out of a given state. Is not returned if pin is"end"
.hist_end (
numpy.ndarray
) – 2d array or tuple of 2d arrays (if trans_type is'both'
or an iterable of ints) containing one histogram for each frame in dtrj. The histograms count how many state transitions ended in a given state, i.e. how many transitions led into a given state. Is not returned if pin is"start"
.
See also
mdtools.dtrj.trans_per_state()
Count the number of transitions leading into or out of a state for the entire trajectory (not frame-wise).
mdtools.dtrj.locate_trans()
Locate the frames of state transitions inside a discrete trajectory
Notes
The histograms contain the counts for all states ranging from the minimum to the maximum state in dtrj in whole numbers. This means, the states corresponding to the counts in hist_start and hist_end are given by
numpy.arange(np.min(dtrj), np.max(dtrj)+1)
.Examples
>>> dtrj = np.array([[1, 2, 2, 3, 3, 3], ... [2, 2, 3, 3, 3, 1], ... [3, 3, 3, 1, 2, 2], ... [1, 3, 3, 3, 2, 2]]) >>> start, end = mdt.dtrj.locate_trans(dtrj, pin="both") >>> start array([[ True, False, True, False, False, False], [False, True, False, False, True, False], [False, False, True, True, False, False], [ True, False, False, True, False, False]]) >>> end array([[False, True, False, True, False, False], [False, False, True, False, False, True], [False, False, False, True, True, False], [False, True, False, False, True, False]]) >>> hist_start, hist_end = mdt.dtrj.trans_per_state_vs_time( ... dtrj, pin="both" ... ) >>> # Number of transitions starting from the 1st, 2nd or 3rd state for each frame >>> hist_start array([[2, 0, 0, 1, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 1, 1, 1, 0]]) >>> # Number of transitions ending in the 1st, 2nd or 3rd state for each frame >>> hist_end array([[0, 0, 0, 1, 0, 1], [0, 1, 0, 0, 2, 0], [0, 1, 1, 1, 0, 0]]) >>> hist_start_type, hist_end_type = mdt.dtrj.trans_per_state_vs_time( ... dtrj, pin="both", trans_type="both" ... ) >>> # Number of transitions starting from the >>> # * 1st state (hist_start_type[0][0]) >>> # * 2nd state (hist_start_type[0][1]) >>> # * 3rd state (hist_start_type[0][2]) >>> # and ending in an >>> # * higher state (hist_start_type[0]) >>> # * lower state (hist_start_type[1]) >>> hist_start_type[0] array([[2, 0, 0, 1, 0, 0], [0, 1, 1, 0, 0, 0], [0, 0, 0, 0, 0, 0]]) >>> hist_start_type[1] array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 0], [0, 0, 1, 1, 1, 0]]) >>> np.array_equal(np.sum(hist_start_type, axis=0), hist_start) True >>> # Number of transitions ending in the >>> # * 1st state (hist_end_type[0][0]) >>> # * 2nd state (hist_end_type[0][1]) >>> # * 3rd state (hist_end_type[0][2]) >>> # and starting from an >>> # * lower state (hist_end_type[0]) >>> # * higher state (hist_end_type[1]) >>> hist_end_type[0] array([[0, 0, 0, 0, 0, 0], [0, 1, 0, 0, 1, 0], [0, 1, 1, 1, 0, 0]]) >>> hist_end_type[1] array([[0, 0, 0, 1, 0, 1], [0, 0, 0, 0, 1, 0], [0, 0, 0, 0, 0, 0]]) >>> np.array_equal(np.sum(hist_end_type, axis=0), hist_end) True >>> # Number of transitions starting from the 1st, 2nd or 3rd state where the difference >>> # between the final and initial state is plus or minus one >>> hist_plus_one, hist_minus_one = mdt.dtrj.trans_per_state_vs_time( ... dtrj, pin="start", trans_type=(1, -1), wrap=True ... ) >>> hist_plus_one array([[1, 0, 0, 1, 0, 1], [0, 1, 1, 0, 0, 1], [0, 0, 0, 0, 0, 0]]) >>> hist_minus_one array([[0, 0, 0, 0, 0, 0], [0, 0, 0, 0, 0, 1], [0, 0, 0, 1, 0, 0]])