Slicec to an extra index around each timestamp input

pre_viz_calls
Tyler Goodlet 2022-12-08 15:43:11 -05:00
parent 45463fd797
commit a1ae0518bb
1 changed files with 8 additions and 7 deletions

View File

@ -328,10 +328,10 @@ def slice_from_time(
# compute (presumed) uniform-time-step index offsets # compute (presumed) uniform-time-step index offsets
i_start_t = round(start_t) i_start_t = round(start_t)
read_i_start = ((i_start_t - t_first) // step) - 1 read_i_start = round(((i_start_t - t_first) // step)) - 1
i_stop_t = round(stop_t) i_stop_t = round(stop_t)
read_i_stop = (i_stop_t - t_first) // step read_i_stop = round((i_stop_t - t_first) // step) + 1
# always clip outputs to array support # always clip outputs to array support
# for read start: # for read start:
@ -346,11 +346,6 @@ def slice_from_time(
min(read_i_stop, read_i_max), min(read_i_stop, read_i_max),
) )
samples = (i_stop_t - i_start_t) // step
index_diff = read_i_stop - read_i_start + 1
if index_diff > (samples + 3):
breakpoint()
# check for larger-then-latest calculated index for given start # check for larger-then-latest calculated index for given start
# time, in which case we do a binary search for the correct index. # time, in which case we do a binary search for the correct index.
# NOTE: this is usually the result of a time series with time gaps # NOTE: this is usually the result of a time series with time gaps
@ -418,6 +413,12 @@ def slice_from_time(
): ):
read_i_stop = read_i_start + new_read_i_stop read_i_stop = read_i_start + new_read_i_stop
# sanity checks for range size
# samples = (i_stop_t - i_start_t) // step
# index_diff = read_i_stop - read_i_start + 1
# if index_diff > (samples + 3):
# breakpoint()
# read-relative indexes: gives a slice where `shm.array[read_slc]` # read-relative indexes: gives a slice where `shm.array[read_slc]`
# will be the data spanning the input time range `start_t` -> # will be the data spanning the input time range `start_t` ->
# `stop_t` # `stop_t`