LinWave#

class waveline.linwave.LinWave(address)[source]#

Interface for linWave device.

The device is controlled via TCP/IP:

  • Control port: 5432

  • Streaming ports: 5433 for channel 1 and 5434 for channel 2

The interface is asynchronous and using asyncio for TCP/IP communication. This is especially beneficial for this kind of streaming applications, where most of the time the app is waiting for more data packets (read more). Please refer to the examples for implementation details.

__init__(address)[source]#

Initialize device.

Parameters:

address (str) – IP address of device. Use the method discover to get IP addresses of available linWave devices.

Returns:

Instance of LinWave

Example

There are two ways constructing and using the LinWave class:

  1. Without context manager, manually calling the connect and close method:

    >>> async def main():
    >>>     lw = waveline.LinWave("192.168.0.100")
    >>>     await lw.connect()
    >>>     print(await lw.get_info())
    >>>     ...
    >>>     await lw.close()
    >>> asyncio.run(main())
    
  2. Using the async context manager:

    >>> async def main():
    >>>     async with waveline.LinWave("192.168.0.100") as lw:
    >>>         print(await lw.get_info())
    >>>         ...
    >>> asyncio.run(main())
    

Methods

__init__(address)

Initialize device.

acquire([raw, poll_interval_seconds])

High-level method to continuously acquire data.

close()

Close connection.

connect()

Connect to device.

discover([timeout])

Discover linWave devices in network.

get_ae_data()

Get AE data records.

get_info()

Get device information.

get_setup(channel)

Get setup information.

get_status()

Get status information.

get_tr_data([raw])

Get transient data records.

get_tr_snapshot(channel, samples[, ...])

Get snapshot of transient data.

identify([channel])

Blink LEDs to identify device or single channel.

set_channel(channel, enabled)

Enable/disable channel.

set_continuous_mode(channel, enabled)

Enable/disable continuous mode.

set_ddt(channel, microseconds)

Set duration discrimination time (DDT).

set_filter(channel[, highpass, lowpass, order])

Set IIR filter frequencies and order.

set_range(channel, range_volts)

Set input range.

set_range_index(channel, range_index)

Set input range by index.

set_status_interval(channel, seconds)

Set status interval.

set_threshold(channel, microvolts)

Set threshold for hit-based acquisition.

set_tr_decimation(channel, factor)

Set decimation factor of transient data and streaming data.

set_tr_enabled(channel, enabled)

Enable/disable recording of transient data.

set_tr_postduration(channel, samples)

Set post-duration samples for transient data.

set_tr_pretrigger(channel, samples)

Set pre-trigger samples for transient data.

start_acquisition()

Start data acquisition.

start_pulsing(channel[, interval, count, cycles])

Start pulsing.

stop_acquisition()

Stop data acquisition.

stop_pulsing()

Stop pulsing.

stream(channel, blocksize, *[, raw, timeout])

Async generator to stream channel data.

Attributes

CHANNELS

Available channels

MAX_SAMPLERATE

Maximum sampling rate in Hz

PORT

Control port number

RANGES

connected

Check if connected to device.

CHANNELS = (1, 2)#

Available channels

MAX_SAMPLERATE = 10000000#

Maximum sampling rate in Hz

PORT = 5432#

Control port number

classmethod discover(timeout=0.5)[source]#

Discover linWave devices in network.

Parameters:

timeout (float) – Timeout in seconds

Return type:

List[str]

Returns:

List of IP adresses

property connected: bool#

Check if connected to device.

async connect()[source]#

Connect to device.

async close()[source]#

Close connection.

async identify(channel=0)[source]#

Blink LEDs to identify device or single channel.

Parameters:

channel (int) – Channel number (0 for all to identify device)

Note

Available since firmware version 2.10.

async get_info()[source]#

Get device information.

Return type:

Info

async get_status()[source]#

Get status information.

Return type:

Status

async get_setup(channel)[source]#

Get setup information.

Parameters:

channel (int) – Channel number

Return type:

Setup

async set_range_index(channel, range_index)[source]#

Set input range by index.

Retrieve selectable ranges with the get_info method.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • range_index (int) – Input range index (0: 0.05 V, 1: 5 V)

async set_range(channel, range_volts)[source]#

Set input range.

Retrieve selectable ranges with the get_info method.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • range_volts (float) – Input range in volts (0.05, 5)

Deprecated: Please us the set_range_index method instead.

async set_channel(channel, enabled)[source]#

Enable/disable channel.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • enabled (bool) – Set to True to enable channel

async set_continuous_mode(channel, enabled)[source]#

Enable/disable continuous mode.

Threshold will be ignored in continous mode. The length of the records is determined by ddt with set_ddt.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • enabled (bool) – Set to True to enable continuous mode

async set_ddt(channel, microseconds)[source]#

Set duration discrimination time (DDT).

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • microseconds (int) – DDT in µs

async set_status_interval(channel, seconds)[source]#

Set status interval.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • seconds (int) – Status interval in s

async set_tr_enabled(channel, enabled)[source]#

Enable/disable recording of transient data.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • enabled (bool) – Set to True to enable transient data

async set_tr_decimation(channel, factor)[source]#

Set decimation factor of transient data and streaming data.

The sampling rate will be 10 MHz / factor.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • factor (int) – Decimation factor

async set_tr_pretrigger(channel, samples)[source]#

Set pre-trigger samples for transient data.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • samples (int) – Pre-trigger samples

async set_tr_postduration(channel, samples)[source]#

Set post-duration samples for transient data.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • samples (int) – Post-duration samples

async set_filter(channel, highpass=None, lowpass=None, order=8)[source]#

Set IIR filter frequencies and order.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • highpass (Optional[float]) – Highpass frequency in Hz (None to disable highpass filter)

  • lowpass (Optional[float]) – Lowpass frequency in Hz (None to disable lowpass filter)

  • order (int) – Filter order

async set_threshold(channel, microvolts)[source]#

Set threshold for hit-based acquisition.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • microvolts (float) – Threshold in µV

async start_acquisition()[source]#

Start data acquisition.

async stop_acquisition()[source]#

Stop data acquisition.

async start_pulsing(channel, interval=1, count=4, cycles=1)[source]#

Start pulsing.

The number of pulses should be even, because pulses are generated by a square-wave signal (between LOW and HIGH) and the pulse signal should end LOW.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • interval (float) – Interval between pulses in seconds

  • count (int) – Number of pulses per channel (should be even), 0 for infinite pulses

  • cycles (int) – Number of pulse cycles (automatically pulse through each channel in cycles). Only useful if all channels are chosen.

async stop_pulsing()[source]#

Stop pulsing.

async get_ae_data()[source]#

Get AE data records.

Return type:

List[AERecord]

Returns:

List of AE data records (either status or hit data)

async get_tr_data(raw=False)[source]#

Get transient data records.

Parameters:

raw (bool) – Return TR amplitudes as ADC values if True, skip conversion to volts

Return type:

List[TRRecord]

Returns:

List of transient data records

async get_tr_snapshot(channel, samples, pretrigger_samples=0, *, raw=False)[source]#

Get snapshot of transient data.

The recording starts with the execution of the command. The total number of samples is the sum of samples and the pretrigger_samples. The trai and time of the returned records are always 0.

Parameters:
  • channel (int) – Channel number (0 for all channels)

  • samples (int) – Number of samples to read

  • pretrigger_samples (int) – Number of samples to read before the execution of the command

  • raw (bool) – Return TR amplitudes as ADC values if True, skip conversion to volts

Return type:

List[TRRecord]

Returns:

List of transient data records

async acquire(raw=False, poll_interval_seconds=0.05)[source]#

High-level method to continuously acquire data.

Parameters:
  • raw (bool) – Return TR amplitudes as ADC values if True, skip conversion to volts

  • poll_interval_seconds (float) – Pause between data polls in seconds

Yields:

AE and TR data records

Return type:

AsyncIterator[Union[AERecord, TRRecord]]

Example

>>> async with waveline.LinWave("192.254.100.100") as lw:
>>>     # apply settings
>>>     await lw.set_channel(channel=1, enabled=True)
>>>     await lw.set_channel(channel=2, enabled=False)
>>>     await lw.set_range_index(channel=1, range_index=0)  # 0: 50 mV
>>>     async for record in lw.acquire():
>>>         # do something with the data depending on the type
>>>         if isinstance(record, waveline.AERecord):
>>>             ...
>>>         if isinstance(record, waveline.TRRecord):
>>>             ...
stream(channel, blocksize, *, raw=False, timeout=5)[source]#

Async generator to stream channel data.

Parameters:
  • channel (int) – Channel number [1, 2]

  • blocksize (int) – Number of samples per block

  • raw (bool) – Return ADC values if True, skip conversion to volts

  • timeout (Optional[float]) – Timeout in seconds

Yields:

Tuple of

  • relative time in seconds (first block: t = 0)

  • data as numpy array in volts (or ADC values if raw is True)

Raises:

TimeoutError – If TCP socket read exceeds timeout, usually because of buffer overflows

Return type:

AsyncIterator[Tuple[float, ndarray]]

Example

>>> async with waveline.LinWave("192.168.0.100") as lw:
>>>     # apply settings
>>>     await lw.set_range_index(channel=1, range_index=0)  # 0: 50 mV
>>>     await lw.set_filter(channel=1, highpass=100e3, lowpass=500e3, order=8)
>>>     # open streaming port before start acq afterwards (order matters!)
>>>     stream = lw.stream(channel=1, blocksize=65536)
>>>     await lw.start_acquisition()
>>>     async for time, block in stream:
>>>         # do something with the data
>>>         ...