Pepper render routines with time-slice calls
parent
5a0673d66f
commit
be21f9829e
|
@ -140,7 +140,7 @@ def render_baritems(
|
||||||
# - if instead we are in a downsamplig state then we to
|
# - if instead we are in a downsamplig state then we to
|
||||||
x_gt = 6
|
x_gt = 6
|
||||||
uppx = curve.x_uppx()
|
uppx = curve.x_uppx()
|
||||||
print(f'BARS UPPX: {uppx}')
|
# print(f'BARS UPPX: {uppx}')
|
||||||
in_line = should_line = curve.isVisible()
|
in_line = should_line = curve.isVisible()
|
||||||
if (
|
if (
|
||||||
in_line
|
in_line
|
||||||
|
@ -280,26 +280,25 @@ class Viz(msgspec.Struct): # , frozen=True):
|
||||||
arr = shm.array
|
arr = shm.array
|
||||||
|
|
||||||
# get relative slice indexes into array
|
# get relative slice indexes into array
|
||||||
(
|
# (
|
||||||
abs_slc,
|
# abs_slc,
|
||||||
read_slc,
|
# read_slc,
|
||||||
mask,
|
# mask,
|
||||||
) = self.flume.slice_from_time(
|
# ) = self.flume.slice_from_time(
|
||||||
arr,
|
# arr,
|
||||||
start_t=lbar,
|
# start_t=lbar,
|
||||||
stop_t=rbar,
|
# stop_t=rbar,
|
||||||
)
|
# )
|
||||||
|
# slice_view = arr[mask]
|
||||||
|
|
||||||
# TODO: should we just add/use a method
|
# TODO: should we just add/use a method
|
||||||
# on the shm to do this?
|
# on the shm to do this?
|
||||||
|
|
||||||
# ifirst = arr[0]['index']
|
ifirst = arr[0]['index']
|
||||||
# slice_view = arr[
|
slice_view = arr[
|
||||||
# lbar - ifirst:
|
lbar - ifirst:
|
||||||
# (rbar - ifirst) + 1
|
(rbar - ifirst) + 1
|
||||||
# ]
|
]
|
||||||
|
|
||||||
slice_view = arr[mask]
|
|
||||||
|
|
||||||
if not slice_view.size:
|
if not slice_view.size:
|
||||||
return None
|
return None
|
||||||
|
@ -349,7 +348,7 @@ class Viz(msgspec.Struct): # , frozen=True):
|
||||||
|
|
||||||
def datums_range(
|
def datums_range(
|
||||||
self,
|
self,
|
||||||
index_field: str = 'time',
|
index_field: str = 'index',
|
||||||
|
|
||||||
) -> tuple[
|
) -> tuple[
|
||||||
int, int, int, int, int, int
|
int, int, int, int, int, int
|
||||||
|
@ -359,11 +358,11 @@ class Viz(msgspec.Struct): # , frozen=True):
|
||||||
|
|
||||||
'''
|
'''
|
||||||
l, r = self.view_range()
|
l, r = self.view_range()
|
||||||
l = round(l)
|
|
||||||
r = round(r)
|
|
||||||
|
|
||||||
# # TODO: avoid this and have shm passed
|
if index_field == 'index':
|
||||||
# # in earlier.
|
l, r = round(l), round(r)
|
||||||
|
|
||||||
|
# # TODO: avoid this and have shm passed in earlier?
|
||||||
# if self.shm is None:
|
# if self.shm is None:
|
||||||
# # haven't initialized the viz yet
|
# # haven't initialized the viz yet
|
||||||
# return (0, l, 0, 0, r, 0)
|
# return (0, l, 0, 0, r, 0)
|
||||||
|
@ -383,22 +382,14 @@ class Viz(msgspec.Struct): # , frozen=True):
|
||||||
stop,
|
stop,
|
||||||
)
|
)
|
||||||
|
|
||||||
def bars_range(self) -> tuple[int, int, int, int]:
|
|
||||||
'''
|
|
||||||
Return a range tuple for the bars present in view.
|
|
||||||
|
|
||||||
'''
|
|
||||||
start, l, datum_start, datum_stop, r, stop = self.datums_range()
|
|
||||||
return l, datum_start, datum_stop, r
|
|
||||||
|
|
||||||
def read(
|
def read(
|
||||||
self,
|
self,
|
||||||
array_field: Optional[str] = None,
|
array_field: Optional[str] = None,
|
||||||
index_field: str = 'time',
|
index_field: str = 'index',
|
||||||
|
|
||||||
) -> tuple[
|
) -> tuple[
|
||||||
int, int, np.ndarray,
|
int, int, np.ndarray,
|
||||||
int, int, np.ndarray,
|
int, int, np.ndarray,
|
||||||
]:
|
]:
|
||||||
'''
|
'''
|
||||||
Read the underlying shm array buffer and
|
Read the underlying shm array buffer and
|
||||||
|
@ -410,10 +401,6 @@ class Viz(msgspec.Struct): # , frozen=True):
|
||||||
# readable data
|
# readable data
|
||||||
array = self.shm.array
|
array = self.shm.array
|
||||||
|
|
||||||
# indexes = array[index_field]
|
|
||||||
# ifirst = indexes[0]
|
|
||||||
# ilast = indexes[-1]
|
|
||||||
|
|
||||||
(
|
(
|
||||||
ifirst,
|
ifirst,
|
||||||
l,
|
l,
|
||||||
|
@ -423,36 +410,40 @@ class Viz(msgspec.Struct): # , frozen=True):
|
||||||
ilast,
|
ilast,
|
||||||
) = self.datums_range(index_field=index_field)
|
) = self.datums_range(index_field=index_field)
|
||||||
|
|
||||||
(
|
abs_slc = slice(ifirst, ilast)
|
||||||
abs_slc,
|
|
||||||
read_slc,
|
|
||||||
mask,
|
|
||||||
) = self.flume.slice_from_time(
|
|
||||||
array,
|
|
||||||
start_t=lbar,
|
|
||||||
stop_t=rbar,
|
|
||||||
)
|
|
||||||
|
|
||||||
# (
|
# TODO: support time slicing
|
||||||
# abs_slc,
|
if index_field == 'time':
|
||||||
# read_slc,
|
(
|
||||||
# in_view,
|
abs_slc,
|
||||||
# ) = self.flume.view_data(
|
read_slc,
|
||||||
# self.plot,
|
mask,
|
||||||
# )
|
) = self.flume.slice_from_time(
|
||||||
# get read-relative indices adjusting
|
array,
|
||||||
# for master shm index.
|
start_t=lbar,
|
||||||
# lbar_i = max(l, ifirst) - ifirst
|
stop_t=rbar,
|
||||||
# rbar_i = min(r, ilast) - ifirst
|
)
|
||||||
in_view = array[read_slc]
|
in_view = array[read_slc]
|
||||||
|
|
||||||
|
# array-index slicing
|
||||||
|
# TODO: can we do time based indexing using arithmetic presuming
|
||||||
|
# a uniform time stamp step size?
|
||||||
|
else:
|
||||||
|
# get read-relative indices adjusting for master shm index.
|
||||||
|
lbar_i = max(l, ifirst) - ifirst
|
||||||
|
rbar_i = min(r, ilast) - ifirst
|
||||||
|
|
||||||
|
# NOTE: the slice here does NOT include the extra ``+ 1``
|
||||||
|
# BUT the ``in_view`` slice DOES..
|
||||||
|
read_slc = slice(lbar_i, rbar_i)
|
||||||
|
in_view = array[lbar_i: rbar_i + 1]
|
||||||
|
|
||||||
|
# XXX: same as ^
|
||||||
|
# to_draw = array[lbar - ifirst:(rbar - ifirst) + 1]
|
||||||
|
|
||||||
if array_field:
|
if array_field:
|
||||||
array = array[array_field]
|
array = array[array_field]
|
||||||
|
|
||||||
# TODO: we could do it this way as well no?
|
|
||||||
# to_draw = array[lbar - ifirst:(rbar - ifirst) + 1]
|
|
||||||
# in_view = array[lbar_i: rbar_i + 1]
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
# abs indices + full data set
|
# abs indices + full data set
|
||||||
abs_slc.start,
|
abs_slc.start,
|
||||||
|
|
Loading…
Reference in New Issue