Temporal Data Module

The temporal data module supplies the common time/frame interface used by imagery, detections, and tracks.

Core Classes

temporal_data.TemporalData

Represents an object which can hold temporal data such as times and frames

TemporalData requires at least one one-dimensional temporal coordinate:

  • times as a NumPy datetime64 array;

  • frames as a one-dimensional integer array.

If both are provided, they must have the same length. get_index() supports exact lookup or lookup of the nearest preceding value, which is used to align sparse imagery to the display timeline.

Basic Usage

import numpy as np

from vista.temporal_data.temporal_data import TemporalData

data = TemporalData(
    times=np.array(["2026-01-01T00:00:00", "2026-01-01T00:00:01"], dtype="datetime64[ns]"),
    frames=np.array([10, 20]),
)

exact_index = data.get_index(20, is_time=False)
preceding_index = data.get_index(15, is_time=False, nearest=True)

Module Reference

Base class for items which can hold temporal data (times and/or frames)

class vista.temporal_data.temporal_data.TemporalData(*, times=None, frames=None)[source]

Bases: object

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

invalidate_caches()[source]

Invalidate the internal time and frame index caches

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

times: NDArray[datetime64] | None = None
frames: NDArray[int64] | 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

get_value(index, is_time)[source]

Get the value of a particular index

Parameters:
  • index (int) – Index to find the value of

  • is_time (bool) – Whether the value is a time (True) or frame (False)

Returns:

Value for the time or frame

Return type:

np.datetime64, int

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]

invalidate_caches()[source]
__init__(*, times=None, frames=None)
vista.temporal_data.temporal_data.all_have_times_frames(data)[source]

Return a tuple of whether the objects in the list (all_have_times, all_have_frames)

Parameters:

data (list) – List of TemporalData objects

Returns:

Tuple of whether the objects (all_have_times, all_have_frames)

Return type:

(bool, bool)

Notes

Will return (True, True) for empty list