Data Retrieval

Bases: PicoScopeBase, Sharedps5000aPs6000a

PicoScope 5000 (A) API specific functions

Methods:

Name Description
get_streaming_latest_values

Poll the driver for the latest streamed data on a single channel/mode.

get_streaming_latest_values_multi

Poll the driver for the latest streamed data on several channel/mode

get_time_axis

Return an array of time values based on the timebase and number

get_values

Retrieves a block of captured samples from the device once it's ready.

get_values_bulk

Retrieve data from multiple memory segments.

get_values_overlapped

Retrieve overlapped data from multiple segments for block or rapid block mode.

is_led_flashing

Check if the LED is flashing.

is_over_range

Logs and prints a warning if any channel has been over range.

is_ready

Blocks execution until the PicoScope device is ready.

no_of_streaming_values

Return the number of values currently available while streaming.

get_streaming_latest_values(*args, **kwargs)

Poll the driver for the latest streamed data on a single channel/mode.

To drain several channels (or RAW plus a downsampled mode) coherently in one driver call, use :meth:get_streaming_latest_values_multi.

Parameters:
  • channel (CHANNEL) –

    Channel the data buffer was registered for.

  • ratio_mode (RATIO_MODE) –

    Ratio mode the buffer was registered for.

  • data_type (DATA_TYPE) –

    Data type the buffer was registered for.

Returns:
  • dict

    Poll result with sample count, buffer/start indices,

  • overflow flag and trigger information.

get_streaming_latest_values_multi(requests)

Poll the driver for the latest streamed data on several channel/mode combinations in a single call.

The driver fills every requested buffer set from the same snapshot, so multi-channel captures (or simultaneous RAW + downsampled streaming) stay sample-aligned. Polling channels one at a time with :meth:get_streaming_latest_values returns misaligned snapshots.

Parameters:
  • requests (list[tuple]) –

    One (channel, ratio_mode, data_type) tuple per registered buffer set to drain, e.g. [(CHANNEL.A, RATIO_MODE.RAW, DATA_TYPE.INT16_T), (CHANNEL.B, RATIO_MODE.RAW, DATA_TYPE.INT16_T)].

Returns:
  • dict( dict ) –

    'status' plus stream-wide trigger keys (``'triggered

  • dict

    at','triggered?','auto stopped?') and a'channels'``

  • dict

    list holding one dict per request with the same per-channel keys

  • as( dict ) –

    meth:get_streaming_latest_values.

Raises:
  • PicoSDKException

    If requests is empty.

get_time_axis(timebase, samples, pre_trig_percent=None, unit='ns', ratio=0)

Return an array of time values based on the timebase and number of samples

Parameters:
  • timebase (int) –

    PicoScope timebase

  • samples (int) –

    Number of samples captured

  • pre_trig_percent (int, default: None ) –

    Percent to offset the 0 point by. If None, defaults to last used pre_trig_percent or 50.

  • unit (str, default: 'ns' ) –

    Unit of seconds the time axis is returned in. Default is 'ns' (nanoseconds).

  • ratio (int, default: 0 ) –

    If using a downsampling ratio, this will scale the time interval to reflect the reduced samples.

Returns:
  • ndarray

    np.ndarray: Array of time values in nano-seconds

get_values(samples, start_index=0, segment=0, ratio=0, ratio_mode=cst.RATIO_MODE.RAW)

Retrieves a block of captured samples from the device once it's ready. If a channel goes over-range a warning will appear.

This function should be called after confirming the device is ready using is_ready(). It invokes the underlying PicoSDK GetValues function to read the data into memory.

Parameters:
  • samples (int) –

    Number of samples to retrieve.

  • start_index (int, default: 0 ) –

    Starting index in the buffer.

  • segment (int, default: 0 ) –

    Memory segment index to retrieve data from.

  • ratio (int, default: 0 ) –

    Downsampling ratio.

  • ratio_mode (RATIO_MODE, default: RAW ) –

    Ratio mode for downsampling.

  • wait_for_ready (bool, default: True ) –

    Whether to wait for the device to be ready.

Returns:
  • int( int ) –

    Actual number of samples retrieved.

get_values_bulk(samples, from_segment_index, to_segment_index, ratio=0, ratio_mode=cst.RATIO_MODE.NONE, **_)

Retrieve data from multiple memory segments.

Parameters:
  • samples (int) –

    Total number of samples to read from each segment.

  • from_segment_index (int) –

    Index of the first segment to read.

  • to_segment_index (int) –

    Index of the last segment. If this value is less than from_segment_index the driver wraps around.

  • ratio (int, default: 0 ) –

    Downsampling ratio to apply before copying.

  • ratio_mode (RATIO_MODE, default: NONE ) –

    Downsampling mode from :class:RATIO_MODE.

Returns:
  • int

    tuple[int, list[list[str]]]: (samples, overflow)list) where samples is the

  • list[list[str]]

    number of samples copied and overflow is list of captures with where

  • tuple[int, list[list[str]]]

    channnels have exceeded their voltage range.

get_values_overlapped(start_index, no_of_samples, down_sample_ratio, down_sample_ratio_mode, from_segment_index, to_segment_index, overflow, wait_for_ready=True)

Retrieve overlapped data from multiple segments for block or rapid block mode.

Call this method before :meth:run_block_capture to defer the data retrieval request. The driver validates and performs the request when :meth:run_block_capture runs, which avoids the extra communication that occurs when calling :meth:run_block_capture followed by :meth:get_values. After the capture completes you can call :meth:get_values again to retrieve additional copies of the data. Stop further captures with :meth:stop_using_get_values_overlapped and check progress using :meth:ps6000a.PicoScope.get_no_of_processed_captures.

Parameters:
  • start_index (int) –

    Index within the circular buffer to begin reading from.

  • no_of_samples (int) –

    Number of samples to copy from each segment.

  • down_sample_ratio (int) –

    Downsampling ratio to apply.

  • down_sample_ratio_mode (int) –

    Downsampling mode from :class:RATIO_MODE.

  • from_segment_index (int) –

    First segment index to read.

  • to_segment_index (int) –

    Last segment index to read.

  • overflow (c_int16) –

    ctypes.c_int16 instance that receives any overflow flags.

  • wait_for_ready (bool, default: True ) –

    Whether to wait for the device to be ready.

Returns:
  • int( int ) –

    Actual number of samples copied from each segment.

Examples:

>>> samples = scope.get_values_overlapped(
...     start_index=0,              # read from start of buffer
...     no_of_samples=1024,         # copy 1024 samples
...     down_sample_ratio=1,        # no downsampling
...     down_sample_ratio_mode=RATIO_MODE.RAW,
...     from_segment_index=0,       # first segment only
...     to_segment_index=0,
... )
>>> scope.run_block_capture(timebase=1, samples=1024)
>>> data = scope.get_values(samples=1024)
>>> samples, scope.over_range
(1024, 0)

is_led_flashing()

Check if the LED is flashing.

Returns:
  • bool( bool ) –

    True if the LED is flashing, False otherwise.

is_over_range()

Logs and prints a warning if any channel has been over range.

The :attr:over_range attribute stores a bit mask updated by data retrieval methods like :meth:get_values and :meth:get_values_overlapped. Calling this method logs a warning if any channel went over range and returns a list of the affected channel names.

Returns:
  • list( list ) –

    List of channels that have been over range

is_ready()

Blocks execution until the PicoScope device is ready.

Continuously calls the PicoSDK IsReady function in a loop, checking if the device is prepared to proceed with data acquisition.

Returns:
  • None

    None

no_of_streaming_values()

Return the number of values currently available while streaming.