Skip to content

Commit

Permalink
Revert "[generate_dtrj.py]: New Command-Line Option --every (WIP)"
Browse files Browse the repository at this point in the history
This reverts commit 8e2e8c2.
  • Loading branch information
andthum committed Oct 4, 2023
1 parent 8e2e8c2 commit 406fb18
Showing 1 changed file with 12 additions and 32 deletions.
44 changes: 12 additions & 32 deletions misc/dtrj_lifetimes/generate_dtrj.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,6 @@
left-censoring of the state lifetimes or a discarded equilibration
period. Note that the generated trajectory will always have the
shape given with \--shape. Default: ``1000``.
--every
Only write out every n-th frame to the generated trajectory. Note
that the generated trajectory will always have the shape given with
\--shape. Default: ``1``.
--seed
Seed to use for the random number generator. If ``None``, a random
seed will be generated by calling ``secrets.randbits(128)``.
Expand All @@ -128,20 +124,18 @@
1. Select a random state. Thereby, ensure that the selected state
is different from the previously selected state. If \--adjacent
is given, the next state must be a neighbor (+/- 1) of the
previous state.
is given, the next state must be a neighbor of the previous
state.
2. Draw a random number from the selected lifetime distribution.
The drawn number is rounded to the nearest integer. If the drawn
number is zero, the selected state is discarded and the loop
restarts at Step 1.
3. Extend the discrete trajectory with the selected state by as many
frames as determined by the drawn lifetime. Redo Steps 1-3 until
the trajectory has at least the desired length (determined by
\--shape, \--discard and \--every).
4. Discard the given number of frames at the beginning of the
trajectory (\--discard). Only keep every n-th frame of the
trajectory (\--every). Clip frames at the end of the trajectory
that exceed the given trajectory length (\--shape).
the trajectory has (at least) the desired length.
4. Discard a given number of frames (\--discard) at the beginning of
the trajectory and clip the trajectory at the end such that it
has the number of frames given with \--shape.
The generalized gamma distribution reduces to many other distributions,
e.g. to the
Expand Down Expand Up @@ -623,18 +617,7 @@
default=1000,
help=(
"Number of frames to discard at the beginning of the generated"
" trajectory. Default: %(default)s."
),
)
parser.add_argument(
"--every",
dest="EVERY",
type=int,
required=False,
default=1,
help=(
"Only write out every n-th frame to the generated trajectory."
" Default: %(default)s."
" trajectory. Default: %(default)s"
),
)
parser.add_argument(
Expand All @@ -645,7 +628,7 @@
default=None,
help=(
"Seed to use for the random number generator. Default:"
" %(default)s."
" %(default)s"
),
)
parser.add_argument(
Expand Down Expand Up @@ -693,13 +676,11 @@
raise ValueError(
"--discard ({}) must not be negative".format(args.DISCARD)
)
if args.EVERY < 1:
raise ValueError("--every ({}) must be positive".format(args.EVERY))
if args.SEED is not None and args.SEED < 0:
raise ValueError("--seed ({}) must not be negative".format(args.SEED))

n_cmps, n_frames = shape
n_frames_tot = n_frames * args.EVERY + args.DISCARD
n_frames_tot = n_frames + args.DISCARD
n_states = len(beta)
state_ix = np.arange(n_states, dtype=np.uint8)
if args.SEED is None:
Expand Down Expand Up @@ -778,10 +759,9 @@
# Calculate the censored lifetime from
# `n_frames_append`. The maximum possible value for
# `n_frames_append` is
# ``n_frames_tot = n_frames * args.EVERY +
# args.DISCARD``. However, the maximum possible value
# for `lt_cen` is ``n_frames * args.EVERY``.
lt_cen = min(n_frames_append, n_frames * args.EVERY)
# ``n_frames_tot = n_frames + args.DISCARD``. However,
# the maximum possible value for `lt_cen` is `n_frames`.
lt_cen = min(n_frames_append, n_frames)
lts_cen[six].append(lt_cen)
# Increase the frame counter.
n_frames_cmp += n_frames_append
Expand Down

0 comments on commit 406fb18

Please sign in to comment.