Skip to content

striqt.sensor.sinks

Sinks that receive the analyzed captures of a sweep.

MemoryCacheSink

MemoryCacheSink(
    sweep_spec: Sweep[Any, Any, SC, Any],
    format_path: PathFormatter | None = None,
    *,
    force: bool = False,
)

Bases: SinkBase

collect the dataset of every acquisition in memory until pop is called.

Nothing is written. close leaves the collected datasets in place.

NoSink

NoSink(
    sweep_spec: Sweep[Any, Any, SC, Any],
    format_path: PathFormatter | None = None,
    *,
    force: bool = False,
)

Bases: SinkBase

a sink that discards the analyzed dataset of each acquisition.

append counts the acquisition and returns capture_result unchanged, and nothing is written. flush logs the acquisition count on the sink logger at INFO.

SinkBase

SinkBase(
    sweep_spec: Sweep[Any, Any, SC, Any],
    format_path: PathFormatter | None = None,
    *,
    force: bool = False,
)

Bases: Generic[SC]

base sink that accepts the analyzed dataset of one acquisition at a time.

A sink is constructed from a Sweep, reads the sink block of that sweep, and is entered as a context manager before the first append. Writes run on 1 worker thread.

append

append(
    capture_result: DelayedDataset,
) -> Dataset | DelayedDataset

materialize capture_result and keep the dataset for pop.

The call blocks until a pending peripheral read of the acquisition completes.

ZarrCaptureSink

ZarrCaptureSink(
    sweep_spec: Sweep[Any, Any, SC, Any],
    format_path: PathFormatter | None = None,
    *,
    force: bool = False,
    action_spec: ActionSpec | None = None,
)

Bases: ZarrSinkBase

write the dataset of each acquisition into a zarr store allocated for the whole sweep.

open allocates every data variable and coordinate of the store from the sweep spec, with one row per port per burst segment of every expanded capture along capture, and keeps the metadata in memory until each append for a directory store or until close for a zip store. The power units attrs of the allocated variables and coordinates are in the power family of the source. append places the arrays of a DelayedDataset on the union grid of the sweep and writes every chunk that the acquisition completes. Each chunk is written once. A burst segment re-acquired after a stream overflow is a further row: (capture_index, burst_index) may repeat, with a later start_time. close writes the partial chunks, trims the store to the rows written, and consolidates the metadata.

rows_written property

rows_written: int

the number of rows written so far

append

append(capture_result: DelayedDataset) -> DelayedDataset

queue the rows of capture_result for writing.

The queued rows are written from the head while the head is ready. A row is ready when the acquisition has no pending peripheral read or the read has completed. The rows behind a pending row wait, so the store keeps the acquisition order.

ZarrSinkBase

ZarrSinkBase(
    sweep_spec: Sweep[Any, Any, SC, Any],
    format_path: PathFormatter | None = None,
    *,
    force: bool = False,
)

Bases: SinkBase

open the zarr store at sink.path and log the written path at close.

Raises:

  • ValueError –

    if sweep_spec.sink.path is None

ZarrTimeAppendSink

ZarrTimeAppendSink(
    sweep_spec: Sweep,
    format_path: PathFormatter | None = None,
    *,
    force: bool = False,
    batch_size: int | None = None,
)

Bases: ZarrSinkBase

append the spectrogram of each acquisition along the spectrogram time axis.

The acquisitions of one write batch share one capture index, and each batch is appended along capture. A batch holds at least batch_size acquisitions, counting each burst segment. The store is written without compression.

Raises:

  • ValueError –

    if sweep_spec.analysis has no spectrogram, or if the sink writes a .zarr.zip file