Skip to content

Datalogger

This module provides functions to record and stream data from a streaming device.

FUNCTION DESCRIPTION
get_dataframe

Convert a list of tuples to a pandas DataFrame

record

Record data from a streaming device

stream

Stream data from a streaming device

monitor_plot

Monitor a data stream in real-time

Documentation last updated: 2025-06-11

get_dataframe

get_dataframe(
    data_store: Iterable[tuple[NamedTuple, datetime]],
    fields: Iterable[str],
) -> DataFrame

Convert a list of tuples to a pandas DataFrame. The first element of each tuple is a NamedTuple, the second element is a datetime object.

PARAMETER DESCRIPTION
data_store

list of tuples

TYPE: Iterable[tuple[NamedTuple, datetime]]

fields

list of field names

TYPE: Iterable[str]

RETURNS DESCRIPTION
DataFrame

pd.DataFrame: DataFrame object

monitor_plot

monitor_plot(
    data_store: Iterable[tuple[NamedTuple, datetime]]
    | DataFrame,
    y: str,
    x: str = "timestamp",
    *,
    kind: str = "line",
    lapsed_counts: int = 100,
    stop_trigger: Event | None = None,
    dataframe_maker: Callable | None = None,
) -> Event

Monitor a data stream in real-time.

PARAMETER DESCRIPTION
data_store

list of tuples or dataframe containing the data to plot

TYPE: Iterable[tuple[NamedTuple, datetime]] | DataFrame

y

y-axis field name

TYPE: str

x

x-axis field name. Defaults to 'timestamp'.

TYPE: str DEFAULT: 'timestamp'

kind

plot type. Defaults to 'line'.

TYPE: str DEFAULT: 'line'

lapsed_counts

number of counts to wait before stopping. Defaults to 100.

TYPE: int DEFAULT: 100

stop_trigger

event to stop the monitoring. Defaults to None.

TYPE: Event | None DEFAULT: None

dataframe_maker

function to convert data_store to a DataFrame. Defaults to None.

TYPE: Callable | None DEFAULT: None

RETURNS DESCRIPTION
Event

threading.Event: event to stop the monitoring

record

record(
    on: bool,
    show: bool = False,
    clear_cache: bool = False,
    *,
    device: StreamingDevice,
    data_store: deque,
    split_stream: bool = True,
    callback: Callable[[str], Any] | None = None,
    query: Any | None = None,
    event: Event | None = None,
)

Record data from a streaming device.

PARAMETER DESCRIPTION
on

start or stop recording

TYPE: bool

show

display the data as it is recorded. Defaults to False.

TYPE: bool DEFAULT: False

clear_cache

clear the data cache before starting. Defaults to False.

TYPE: bool DEFAULT: False

device

streaming device object

TYPE: StreamingDevice

data_store

data cache

TYPE: deque

split_stream

whether to split the stream and data processing threads. Defaults to True.

TYPE: bool DEFAULT: True

query

query to pass to the streaming device. Defaults to None.

TYPE: Any | None DEFAULT: None

event

event to set or clear. Defaults to None.

TYPE: Event | None DEFAULT: None

stream

stream(
    on: bool,
    show: bool = False,
    *,
    device: StreamingDevice,
    data_store: deque,
    split_stream: bool = True,
    callback: Callable[[str], Any] | None = None,
    query: Any | None = None,
    event: Event | None = None,
)

Stream data from a streaming device.

PARAMETER DESCRIPTION
on

start or stop streaming

TYPE: bool

show

display the data as it is streamed. Defaults to False.

TYPE: bool DEFAULT: False

device

streaming device object

TYPE: StreamingDevice

data_store

data cache

TYPE: deque

split_stream

whether to split the stream and data processing threads. Defaults to True.

TYPE: bool DEFAULT: True

query

query to pass to the streaming device. Defaults to None.

TYPE: Any | None DEFAULT: None

event

event to set or clear. Defaults to None.

TYPE: Event | None DEFAULT: None