vista.temporal_data.temporal_data.TemporalData¶
- class vista.temporal_data.temporal_data.TemporalData(*, times=None, frames=None)[source]¶
Represents an object which can hold temporal data such as times and frames
- Parameters:
times (NDArray[np.datetime64], optional) – Timestamp for each index with nanosecond precision.
frames (NDArray[np.int_], optional) – Frame number for each index.
- get_index(val, is_time, nearest=False)[source]¶
Get the index of a value based on whether it is a time or frame, and whether it should require an exact match or the nearest preceding value
- fill_times_frames(times, frames)[source]¶
Fill in missing times from frames (or frames from times) using this object’s own times and frames
- Internal Attributes
- -------------------
- _frame_index : dict(int, int)
Mapping of frame number to index
- _frames_sorted : bool
Whether frames are sorted or not
- _time_index : dict(np.datetime64, int)
Mapping of time to index
- _times_sorted : bool
Whether times are sorted or not
- _times_sorter : NDArray[np.int_]
Indices which sort times, cached for nearest-value searches on unsorted times
- _frames_sorter : NDArray[np.int_]
Indices which sort frames, cached for nearest-value searches on unsorted frames
- __init__(*, times=None, frames=None)¶
Methods
__init__(*[, times, frames])fill_times_frames(times, frames)Fill in missing times from frames, or missing frames from times, using this object's own times and frames
get_index(val, is_time[, nearest, in_range])Get the index of a particular value
get_value(index, is_time)Get the value of a particular index
Attributes
- times: NDArray[datetime64] | None = None¶
- get_index(val, is_time, nearest=False, in_range=False)[source]¶
Get the index of a particular value
- Parameters:
val (np.datetime64, int) – Value to find the index of
is_time (bool) – Whether the value is a time (True) or frame (False)
nearest (bool, default False) – Whether to search for the nearest preceding value (True) or exact value (False)
in_range (bool, default False) – Whether the value should be required to be in the range of times or frames. Only necessary when the value is outside the range and nearest = True.
- Returns:
Array index for the value, or None if value not found
- Return type:
int or None
- fill_times_frames(times, frames)[source]¶
Fill in missing times from frames, or missing frames from times, using this object’s own times and frames
The conversion is only performed when this object has both times and frames, exactly one of the inputs is provided, and every provided value is found in this object (via
get_index). Otherwise the inputs are returned unchanged.- Parameters:
times (NDArray[np.datetime64], optional) – Times to find matching frames for, or None
frames (NDArray[np.int_], optional) – Frames to find matching times for, or None
- Returns:
times (NDArray[np.datetime64], None) – The provided times, or the times matching the provided frames when found
frames (NDArray[np.int_], None) – The provided frames, or the frames matching the provided times when found
- Return type:
tuple[NDArray[datetime64] | None, NDArray[int64] | None]
- __init__(*, times=None, frames=None)¶