send_to_rerun
def send_to_rerun(data: Table | Scan | pa.RecordBatchReader | pa.Table
| pa.RecordBatch | pa.ChunkedArray | pa.StructArray,
spec: dict[str, Archetype],
*,
default_timeline: str | None = None)Visualize a table, scan, record batch, record batch reader, array, or table.
Arguments:
-
data- positional-only; the data to visualize -
spec- positional-only; a named set of visualizations referencing columns of data. -
default_timeline- keyword-only; a dot-separated path to a timeline column (an integer or timestamp).
Archetype
@final
class Archetype()An ergonomic shim around a Rerun Archetype.
An archetype defines visualization semantics for a value. For example, a pair of floating-point values could be interpreted as:
- a point in 2-d Euclidean space,
- a vector in 2-d Euclidean space (perhaps rooted at the origin, perhaps not), or
- a point in 2-d Hyberbolic space
among many other possible interpretations. Rerun defines archetypes for the first two: Points2D and Arrows2D.
spiral.viz.Archetype is a shim which flattens or broadcasts components of an Archetype so that
they are all aligned to one another and to their timeline.
Example
Consider a 2-d point cloud which rotates around the origin. We store it as an Arrow table with
two columns: timeline of type timestamp[ns] and cloud of type list(list(f64, 2)). The
outer lists represent the point cloud at each timestamp and the inner fixed-size-list of length
2 represents the pairs.
import math
import pyarrow as pa
from datetime import datetime
import spiral
from spiral import viz as sv
timeline = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
def point_on_circle(index, time):
x = 2 * math.pi * (index / 8 + time)
return (math.cos(x), math.sin(x))
cloud = [
[point_on_circle(index, time) for index in range(8)]
for time in timeline
]
timeline = [datetime.fromtimestamp(t) for t in timeline]
table = pa.table({
"timeline": pa.array(timeline, type=pa.timestamp("ns")),
"cloud": pa.array(cloud),
})Now we can use sv.Points2D, a spiral Archetype, to convert this data into a Rerun
visualization. sv.Points2D will automatically broadcast the timeline across the values of the
outer list.
import rerun
rerun.init("spiral 1")
sv.send_to_rerun(
table,
{"point_cloud": sv.Points2D(positions="cloud", timeline="timeline")}
)
rerun.notebook_show()ArrowComponentBatchLike
@final
class ArrowComponentBatchLike(rr.ComponentBatchLike)A Rerun shim around an Arrow arrray.
ArrowTimeColumn
@final
class ArrowTimeColumn(rr._send_columns.TimeColumnLike)A timeline represented as a series of points on that timeline.
A timeline may either be temporal or ordinal. The ArrowTimeColumn for a temporal timeline must
have type timestamp[ns]. An ordinal timeline must have type int64.
Example
A series of values may simply use their row index as a timeline:
import pyarrow as pa
import spiral
data = ['a', 'b', 'c', 'd']
ordinal_timeline = pa.array(list(range(len(data))))
spiral.viz.ArrowTimeColumn.from_name_and_data("my_timeline", ordinal_timeline)They may also use any nanosecond-resolution timestamp column. For example, a 10Hz sensor with data from 0s to 1 might use a timeline such as this:
from datetime import datetime
timeline = [0.0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9]
timeline = [datetime.fromtimestamp(t) for t in timeline]
spiral.viz.ArrowTimeColumn.from_name_and_data("my_timeline", timeline)Arrows2D
def Arrows2D(**kwargs)Arrows3D
def Arrows3D(**kwargs)Points2D
def Points2D(**kwargs)Points3D
def Points3D(**kwargs)TextLog
def TextLog(**kwargs)Scalars
def Scalars(**kwargs)