Skip to content

striqt.sensor.bindings

Sensor bindings, which pair a sweep spec type with the source, sink, and peripheral implementations that run it.

the built-in sensor bindings.

Each binding pairs a source backend with the spec types that configure the backend. The sensor_binding key of a sweep file selects a binding by name.

air7101b module-attribute

air7101b = bind_sensor(
    'air7101b',
    Sensor(source_cls=sources.deepwave.Airstack1Source),
    Schema(
        source=sources.deepwave.Air7101BSourceSpec,
        init_like=sources.deepwave.Air7101BSourceSpec,
        capture=specs.SoapyCapture,
        arm_like=specs.SoapyCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air7101b.

The source block of the action decodes to Air7101BSourceSpec, each entry of captures to SoapyCapture, and the action to Sweep.

air7101b_calibration module-attribute

air7101b_calibration = bind_sensor(
    'air7101b_calibration',
    air7101b.sensor,
    dataclasses.replace(
        air7101b.schema,
        action=specs.ManualYFactorCalibration,
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air7101b_calibration.

The source block of the action decodes to Air7101BSourceSpec, each entry of captures to SoapyCapture, and the action to ManualYFactorCalibration.

air7101b_cellular module-attribute

air7101b_cellular = bind_sensor(
    'air7101b_cellular',
    air7101b.sensor,
    dataclasses.replace(
        air7101b.schema, action=specs.Cellular5GNRSweep
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air7101b_cellular.

The source block of the action decodes to Air7101BSourceSpec, each entry of captures to SoapyCapture, and the action to Cellular5GNRSweep.

air7201b module-attribute

air7201b = bind_sensor(
    'air7201b',
    Sensor(source_cls=sources.deepwave.Airstack1Source),
    Schema(
        source=sources.deepwave.Air7201BSourceSpec,
        init_like=sources.deepwave.Air7201BSourceSpec,
        capture=specs.SoapyCapture,
        arm_like=specs.SoapyCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air7201b.

The source block of the action decodes to Air7201BSourceSpec, each entry of captures to SoapyCapture, and the action to Sweep.

air7201b_calibration module-attribute

air7201b_calibration = bind_sensor(
    'air7201b_calibration',
    air7201b.sensor,
    dataclasses.replace(
        air7201b.schema,
        action=specs.ManualYFactorCalibration,
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air7201b_calibration.

The source block of the action decodes to Air7201BSourceSpec, each entry of captures to SoapyCapture, and the action to ManualYFactorCalibration.

air7201b_cellular module-attribute

air7201b_cellular = bind_sensor(
    'air7201b_cellular',
    air7201b.sensor,
    dataclasses.replace(
        air7201b.schema, action=specs.Cellular5GNRSweep
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air7201b_cellular.

The source block of the action decodes to Air7201BSourceSpec, each entry of captures to SoapyCapture, and the action to Cellular5GNRSweep.

air8201b module-attribute

air8201b = bind_sensor(
    'air8201b',
    Sensor(source_cls=sources.deepwave.Airstack1Source),
    Schema(
        source=sources.deepwave.Air8201BSourceSpec,
        init_like=sources.deepwave.Air8201BSourceSpec,
        capture=specs.SoapyCapture,
        arm_like=specs.SoapyCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air8201b.

The source block of the action decodes to Air8201BSourceSpec, each entry of captures to SoapyCapture, and the action to Sweep.

air8201b_calibration module-attribute

air8201b_calibration = bind_sensor(
    'air8201b_calibration',
    air8201b.sensor,
    dataclasses.replace(
        air8201b.schema,
        action=specs.ManualYFactorCalibration,
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air8201b_calibration.

The source block of the action decodes to Air8201BSourceSpec, each entry of captures to SoapyCapture, and the action to ManualYFactorCalibration.

air8201b_cellular module-attribute

air8201b_cellular = bind_sensor(
    'air8201b_cellular',
    air8201b.sensor,
    dataclasses.replace(
        air8201b.schema, action=specs.Cellular5GNRSweep
    ),
)

control the Airstack1Source backend (a source backend for device control and acquisition through SoapySDR), selected by sensor_binding: air8201b_cellular.

The source block of the action decodes to Air8201BSourceSpec, each entry of captures to SoapyCapture, and the action to Cellular5GNRSweep.

dirac_delta module-attribute

dirac_delta = bind_sensor(
    'dirac_delta',
    Sensor(source_cls=sources.DiracDeltaSource),
    Schema(
        source=specs.FunctionSource,
        init_like=specs.FunctionSource,
        capture=specs.DiracDeltaCapture,
        arm_like=specs.DiracDeltaCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the DiracDeltaSource backend (a source that reads samples from get_waveform on a synthetic time base), selected by sensor_binding: dirac_delta.

The source block of the action decodes to FunctionSource, each entry of captures to DiracDeltaCapture, and the action to Sweep.

mat_file module-attribute

mat_file = bind_sensor(
    'mat_file',
    Sensor(source_cls=sources.MATSource),
    Schema(
        source=specs.MATSource,
        init_like=specs.MATSource,
        capture=specs.FileCapture,
        arm_like=specs.FileCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the MATSource backend (returns IQ waveforms from a .mat file), selected by sensor_binding: mat_file.

The source block of the action decodes to MATSource, each entry of captures to FileCapture, and the action to Sweep.

noise module-attribute

noise = bind_sensor(
    'noise',
    Sensor(source_cls=sources.NoiseSource),
    Schema(
        source=specs.FunctionSource,
        init_like=specs.FunctionSource,
        capture=specs.NoiseCapture,
        arm_like=specs.NoiseCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the NoiseSource backend (a source that reads samples from get_waveform on a synthetic time base), selected by sensor_binding: noise.

The source block of the action decodes to FunctionSource, each entry of captures to NoiseCapture, and the action to Sweep.

sawtooth module-attribute

sawtooth = bind_sensor(
    'sawtooth',
    Sensor(source_cls=sources.SawtoothSource),
    Schema(
        source=specs.FunctionSource,
        init_like=specs.FunctionSource,
        capture=specs.SawtoothCapture,
        arm_like=specs.SawtoothCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the SawtoothSource backend (a source that reads samples from get_waveform on a synthetic time base), selected by sensor_binding: sawtooth.

The source block of the action decodes to FunctionSource, each entry of captures to SawtoothCapture, and the action to Sweep.

single_tone module-attribute

single_tone = bind_sensor(
    'single_tone',
    Sensor(source_cls=sources.SingleToneSource),
    Schema(
        source=specs.FunctionSource,
        init_like=specs.FunctionSource,
        capture=specs.SingleToneCapture,
        arm_like=specs.SingleToneCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the SingleToneSource backend (a source that reads samples from get_waveform on a synthetic time base), selected by sensor_binding: single_tone.

The source block of the action decodes to FunctionSource, each entry of captures to SingleToneCapture, and the action to Sweep.

tdms_file module-attribute

tdms_file = bind_sensor(
    'tdms_file',
    Sensor(source_cls=sources.TDMSSource),
    Schema(
        source=specs.TDMSSource,
        init_like=specs.TDMSSource,
        capture=specs.FileCapture,
        arm_like=specs.FileCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the TDMSSource backend (a source of IQ waveforms from a TDMS file), selected by sensor_binding: tdms_file.

The source block of the action decodes to TDMSSource, each entry of captures to FileCapture, and the action to Sweep.

warmup module-attribute

warmup = bind_sensor(
    'warmup',
    Sensor(source_cls=sources.NoSource),
    Schema(
        source=specs.NoSource,
        init_like=specs.NoSource,
        capture=specs.SensorCapture,
        arm_like=specs.SensorCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the NoSource backend (fast paths to acquire empty buffers), selected by sensor_binding: warmup.

The source block of the action decodes to NoSource, each entry of captures to SensorCapture, and the action to Sweep.

zarr_iq module-attribute

zarr_iq = bind_sensor(
    'zarr_iq',
    Sensor(source_cls=sources.ZarrIQSource),
    Schema(
        source=specs.ZarrIQSource,
        init_like=specs.ZarrIQSource,
        capture=specs.FileCapture,
        arm_like=specs.FileCapture,
        peripherals=specs.NoPeripherals,
    ),
)

control the ZarrIQSource backend (a source of IQ samples from the iq_waveform variable of a zarr store), selected by sensor_binding: zarr_iq.

The source block of the action decodes to ZarrIQSource, each entry of captures to FileCapture, and the action to Sweep.

Controller

Controller(*args: args, **kwargs: kwargs)

Bases: Generic[SS, SP, SC, SA, PS, PC]

Open the source backend for control and acquisition.

backend instance-attribute

backend: SourceBackend[SS, SC]

__setup__ instance-attribute

__setup__: SS

schema class-attribute

schema: Schema[Any, Any, Any, Any, Any, Any]

sensor class-attribute

sensor: SensorBinding[Any, Any, Any]

source_id cached property

source_id: str

source_info cached property

source_info: SourceInfo

power_units property

power_units: PowerUnits

the unit of the squared magnitude of the IQ that acquire returns

capture_spec property

capture_spec: SC

return the specification of the currently armed capture

__init_subclass__

__init_subclass__(
    *,
    sensor: SensorBinding[SS, SP, SC],
    schema: Schema[SS, SP, SC, SA, PS, PC],
)

customize documentation on subclassing

from_sweep_spec classmethod

from_sweep_spec(
    spec: Sweep[SS, Any, SC, SA],
    format_path: PathFormatter | None = None,
) -> Controller[SS, SP, SC, SA, PS, PC]

from_source_spec classmethod

from_source_spec(
    spec: SS,
    reuse_iq: bool = False,
    rx_ports: tuple[int, ...] | None = None,
    format_path: PathFormatter | None = None,
) -> Controller[SS, SP, SC, SA, PS, PC]

arm

arm(*args: args, **kwargs: kwargs) -> SC | None

is_open

is_open(wait: bool = True) -> bool

return whether the backend of this instance is open.

Parameters:

  • wait (bool, default: True ) –

    if True, the call blocks up to the controller timeout for an open in progress; if False, the state at the time of the call is returned

Returns:

  • bool –

    False once close has run on this instance, even if another controller

  • bool –

    has since been opened for an equal source spec

close

close() -> None

__del__

__del__()

__enter__

__enter__() -> Self

__exit__

__exit__(*exc_info)

target_analysis

target_analysis(analysis: AnalysisGroup | None)

sets or disables an analysis target to auto-select acquisition overlap

discard_iq

discard_iq() -> None

drop the acquisition that reuse_iq would serve to the next matching capture.

The next acquire reads the source even when the armed capture is unchanged.

set_calibration_formatter

set_calibration_formatter(
    format_path: PathFormatter | None = None,
)

set the formatter that expands the path fields of source.calibration.

None clears the formatter. A formatter is required when the calibration path has fields such as {name}.

Raises:

  • TypeError –

    if format_path is not a PathFormatter or None

source_spec

source_spec() -> SS

read_iq

read_iq(
    overlaps: tuple[int, int] = (0, 0),
    *,
    burst_index: int = 0,
    resume: bool = False,
) -> tuple[Array, int | None]

read the IQ of one burst segment of the armed capture.

The read of segment 0, or of a segment with resume, triggers the backend and applies the transient holdoff. The read of a later segment continues the enabled stream from the samples carried over after the previous segment. The carryover is kept for the next segment and cleared after the last segment of the burst.

Parameters:

  • overlaps (tuple[int, int], default: (0, 0) ) –

    the (lead, tail) overlap in source samples around the record

  • burst_index (int, default: 0 ) –

    the index of the segment within the burst of the armed capture, from 0 to capture.burst - 1

  • resume (bool, default: False ) –

    if True, segment burst_index is read as the first segment after a stream error, with no carryover

Returns:

  • Array –

    (samples, start_time_ns): the samples as a C-contiguous complex64

  • int | None –

    array with shape (ports, count) in the namespace of the source

  • tuple[Array, int | None] –

    array_backend, and the time (in ns) of the first record sample, or

  • tuple[Array, int | None] –

    None when the record is filled from the carryover without a backend read

Raises:

  • ValueError –

    if overlaps is not 2 non-negative integers

  • OverflowError –

    on a stream overflow after the first read of a segment, or on any read of a segment that continues the stream

  • MemoryError –

    if the backend reports more samples than requested

acquire

acquire(
    overlaps: tuple[int, int] | None = None,
    *,
    burst_index: int = 0,
    resume: bool = False,
) -> AcquiredIQ

acquire one burst segment of the armed capture.

The read of segment 0, or of a segment with resume, is repeated up to source_info.retries times on a stream error or overflow. A stream error during a later segment is raised.

Parameters:

  • overlaps (tuple[int, int] | None, default: None ) –

    the (lead, tail) overlap in source samples, or None to derive the overlap from the capture and the analysis target

  • burst_index (int, default: 0 ) –

    the index of the segment within the burst, stamped on info.burst_index

  • resume (bool, default: False ) –

    if True, segment burst_index is read as the first segment after a stream error

Returns:

  • AcquiredIQ –

    the acquisition, with x of shape (ports, lead + record + tail) at

  • AcquiredIQ –

    the source rate, or the reuse_iq copy of the previous acquisition when

  • AcquiredIQ –

    the armed capture is reusable

Raises:

  • AttributeError –

    if no capture is armed

  • ValueError –

    if overlaps is neither a tuple nor None

  • ReceiveStreamError –

    on a stream error once the retries are exhausted

  • OverflowError –

    on a stream overflow once the retries are exhausted

acquire_burst

acquire_burst(
    overlaps: tuple[int, int] | None = None,
    *,
    queue: AcquisitionQueue | None = None,
    finalize: Callable[[AcquiredIQ], AcquiredIQ]
    | None = None,
) -> list[AcquiredIQ]

acquire the capture.burst segments of the armed capture.

The segments are read back to back with the stream enabled. After a stream error or overflow during segment k, the backend runs prepare_retrigger and the read is repeated, up to source_info.retries times per burst. Under bursts.on_gap='skip', segment k is read again as a first segment. Under 'except', the segments of the burst still in queue are removed and the burst restarts from segment 0.

Each segment passes through finalize before it is queued or returned. When queue is full, the put of a segment of a capture with burst above 1 is skipped with a WARNING on the source logger under 'skip' and raises under 'except'. The put of a capture with burst 1 waits for a free slot.

Parameters:

  • overlaps (tuple[int, int] | None, default: None ) –

    the (lead, tail) overlap in source samples, or None to derive the overlap from the capture and the analysis target

  • queue (AcquisitionQueue | None, default: None ) –

    the queue that receives each segment, or None to return the segments

  • finalize (Callable[[AcquiredIQ], AcquiredIQ] | None, default: None ) –

    a function applied to each segment before the queue put

Returns:

  • list[AcquiredIQ] –

    the segments in order when queue is None, otherwise an empty list

Raises:

  • ValueError –

    if burst is above 1 and capture.duration is not a whole number of trigger_strobe periods

  • AcquisitionOverrunError –

    if queue is full under bursts.on_gap='except'

  • ReceiveStreamError –

    on a stream error once the retries are exhausted

  • OverflowError –

    on a stream overflow once the retries are exhausted

  • ThreadInterruptRequest –

    in a worker thread, when cancel_threads has been called

disarm

disarm() -> None

disable the stream of the backend until the next arm or acquire.

get_resampler

get_resampler() -> ResamplerDesign

Sensor dataclass

Sensor(
    source_cls: type[SourceBackend[SS, SC]],
    sweep_spec_cls: type[ActionSpec[SS, SP, Any]] = Sweep,
    peripherals_cls: type[
        Peripherals[SP, SC] | NoPeripherals[SP, SC]
    ] = NoPeripherals,
)

Bases: Generic[SS, SP, SC]

the implementation classes of a sensor

source_cls instance-attribute

source_cls: type[SourceBackend[SS, SC]]

the source backend class instantiated from the source block of a spec

sweep_spec_cls class-attribute instance-attribute

sweep_spec_cls: type[ActionSpec[SS, SP, Any]] = (
    specs.Sweep
)

the action spec type to bind, or the default specs.Sweep to take the type from Schema.action

peripherals_cls class-attribute instance-attribute

peripherals_cls: type[
    Peripherals[SP, SC] | NoPeripherals[SP, SC]
] = NoPeripherals

the peripherals class instantiated from a Sweep; NoPeripherals opens nothing

__post_init__

__post_init__()

SensorBinding dataclass

SensorBinding(
    source_cls: type[SourceBackend[SS, SC]],
    sweep_spec_cls: type[ActionSpec[SS, SP, Any]] = Sweep,
    peripherals_cls: type[
        Peripherals[SP, SC] | NoPeripherals[SP, SC]
    ] = NoPeripherals,
)

Bases: Sensor[SS, SP, SC]

a bound Sensor with the tagged action spec class as sweep_spec_cls

__post_init__

__post_init__() -> None

bind_manual_yfactor_calibration

bind_manual_yfactor_calibration(
    name: str,
    ctrl_cls: type[
        Controller[SS, SP, Any, SA, PS, PC]
    ],
) -> type[Controller[SS, SP, Any, SA, PS, PC]]

bind the sensor of ctrl_cls for ManualYFactorCalibration under name.

The function is deprecated and emits a DeprecationWarning on each call. The replacement is bind_sensor with ctrl_cls.sensor and dataclasses.replace(ctrl_cls.schema, action=specs.ManualYFactorCalibration). The __module__ of the returned class is the module of the caller.

bind_sensor

bind_sensor(
    key: str,
    sensor: Sensor[TS2, TP2, TC2],
    schema: Schema[SS, SP, SC, SA, PS, PC],
    register: bool = True,
    *,
    module: Optional[str] = None,
) -> type[Controller[SS, SP, SC, SA, PS, PC]]

bind the implementation classes of a sensor to spec types under key.

The returned Controller subclass has the class attributes sensor (a SensorBinding) and schema. Its sensor.sweep_spec_cls is a subclass of the action spec type, tagged with key in the sensor_binding field. In that subclass, source, peripherals, captures (when the action declares the field), and analysis (when the action is a Sweep) are annotated with the types in schema. A sweep file with sensor_binding equal to key decodes to an instance of that subclass. The tagged subclass has the class attributes sensor, schema, controller (the returned class), and sweep_cls (the bound Sweep class with the same spec types, or the tagged subclass when the action is a Sweep). The tagged subclass of an unregistered binding is decoded only by explicit type.

Parameters:

  • key (str) –

    the sensor_binding value of sweep files, and the registry key

  • sensor (Sensor[TS2, TP2, TC2]) –

    the implementation classes; the sensor of a registered controller selects the same hardware for the action in schema

  • schema (Schema[SS, SP, SC, SA, PS, PC]) –

    the spec types; schema.action selects the action spec type and schema.analysis the analysis group

  • register (bool, default: True ) –

    if True, the binding is registered under key for get_controller, and the tagged subclass is added to the union that get_tagged_sweep_type returns

  • module (Optional[str], default: None ) –

    the __module__ of the returned class; the module of the caller when None

Raises:

  • TypeError –

    if sensor or schema has the wrong type, if key is already registered, if sensor.sweep_spec_cls and schema.action name different non-default types, if the check_schema of the action type rejects schema, or if a field of schema.analysis is not a registered measurement