Memory / Buffer Management

Bases: PicoScopeBase, shared_ps6000a_psospa

PicoScope OSP (A) API specific functions

Methods:

Name Description
get_maximum_available_memory

Return the maximum sample depth for the current resolution.

memory_segments

Configure the number of memory segments.

memory_segments_by_samples

Set the samples per memory segment.

set_data_buffer

Allocates and assigns a data buffer for a specified channel on the 6000A series.

set_data_buffer_for_enabled_channels

Sets data buffers for enabled channels set by picosdk.set_channel()

set_data_buffer_rapid_capture

Allocates and assigns multiple data buffers for rapid block capture on a specified channel.

set_data_buffers

Allocate and assign max and min NumPy-backed data buffers.

set_data_buffers_rapid_capture

Allocate and assign max and min NumPy-backed data buffers for rapid block

get_maximum_available_memory()

Return the maximum sample depth for the current resolution. Wraps ps6000aGetMaximumAvailableMemory to query how many samples can be captured at self.resolution. Returns: int: Maximum number of samples supported. Raises: PicoSDKException: If the device has not been opened.

memory_segments(n_segments)

Configure the number of memory segments.

This wraps the ps6000aMemorySegments API call.

Parameters:
  • n_segments (int) –

    Desired number of memory segments.

Returns:
  • int( int ) –

    Number of samples available in each segment.

memory_segments_by_samples(n_samples)

Set the samples per memory segment.

This wraps ps6000aMemorySegmentsBySamples which divides the capture memory so that each segment holds n_samples samples.

Parameters:
  • n_samples (int) –

    Number of samples per segment.

Returns:
  • int( int ) –

    Number of segments the memory was divided into.

set_data_buffer(channel, samples, segment=0, datatype=DATA_TYPE.INT16_T, ratio_mode=RATIO_MODE.RAW, action=ACTION.CLEAR_ALL | ACTION.ADD, buffer=None)

Allocates and assigns a data buffer for a specified channel on the 6000A series.

Parameters:
  • channel (int) –

    The channel to associate the buffer with (e.g., CHANNEL.A).

  • samples (int) –

    Number of samples to allocate in the buffer.

  • segment (int, default: 0 ) –

    Memory segment to use.

  • datatype (DATA_TYPE, default: INT16_T ) –

    C data type for the buffer (e.g., INT16_T).

  • ratio_mode (RATIO_MODE, default: RAW ) –

    Downsampling mode.

  • action (ACTION, default: CLEAR_ALL | ADD ) –

    Action to apply to the data buffer (e.g., CLEAR_ALL | ADD).

  • buffer (ndarray | None, default: None ) –

    Send a preallocated numpy buffer to be populated. If left as None, this function creates its own buffer.

Returns:
  • ndarray | None

    np.array | None: The allocated buffer or None when clearing existing buffers.

Raises:
  • PicoSDKException

    If an unsupported data type is provided.

set_data_buffer_for_enabled_channels(samples, segment=0, datatype=DATA_TYPE.INT16_T, ratio_mode=RATIO_MODE.RAW, clear_buffer=True, captures=0)

Sets data buffers for enabled channels set by picosdk.set_channel()

Parameters:
  • samples (int) –

    The sample buffer or size to allocate.

  • segment (int, default: 0 ) –

    The memory segment index.

  • datatype (DATA_TYPE, default: INT16_T ) –

    The data type used for the buffer.

  • ratio_mode (RATIO_MODE, default: RAW ) –

    The ratio mode (e.g., RAW, AVERAGE).

  • clear_buffer (bool, default: True ) –

    If True, clear the buffer first

  • captures (int, default: 0 ) –

    If larger than 0, it will create multiple buffers for RAPID mode.

Returns:
  • dict( dict ) –

    A dictionary mapping each channel to its associated data buffer.

set_data_buffer_rapid_capture(channel, samples, captures, segment=0, datatype=DATA_TYPE.INT16_T, ratio_mode=RATIO_MODE.RAW, action=ACTION.CLEAR_ALL | ACTION.ADD)

Allocates and assigns multiple data buffers for rapid block capture on a specified channel.

Parameters:
  • channel (int) –

    The channel to associate the buffer with (e.g., CHANNEL.A).

  • samples (int) –

    Number of samples to allocate in the buffer.

  • captures (int) –

    Number of rapid block captures

  • segment (int, default: 0 ) –

    Memory segment to start at.

  • datatype (DATA_TYPE, default: INT16_T ) –

    C data type for the buffer (e.g., INT16_T).

  • ratio_mode (RATIO_MODE, default: RAW ) –

    Downsampling mode.

  • action (ACTION, default: CLEAR_ALL | ADD ) –

    Action to apply to the data buffer (e.g., CLEAR_ALL | ADD).

Returns:
  • ndarray | None

    np.array | None: The allocated buffer or None when clearing existing buffers.

Raises:
  • PicoSDKException

    If an unsupported data type is provided.

set_data_buffers(channel, samples, segment=0, datatype=DATA_TYPE.INT16_T, ratio_mode=RATIO_MODE.AGGREGATE, action=ACTION.CLEAR_ALL | ACTION.ADD, buffers=None)

Allocate and assign max and min NumPy-backed data buffers.

Parameters:
  • channel (int) –

    The channel to associate the buffers with.

  • samples (int) –

    Number of samples to allocate.

  • segment (int, default: 0 ) –

    Memory segment to use.

  • datatype (DATA_TYPE, default: INT16_T ) –

    C data type for the buffer (e.g., INT16_T).

  • ratio_mode (RATIO_MODE, default: AGGREGATE ) –

    Downsampling mode.

  • action (ACTION, default: CLEAR_ALL | ADD ) –

    Action to apply to the data buffer.

  • buffers (ndarray | None, default: None ) –

    Send preallocated 2D numpy buffers to be populated. Min buffer first, followed by max buffer. If left as None, this function creates its own buffers.

Returns:
  • tuple[ndarray, ndarray]

    tuple[np.ndarray, np.ndarray]: Tuple of (buffer_min, buffer_max) NumPy arrays.

Raises:
  • PicoSDKException

    If an unsupported data type is provided.

set_data_buffers_rapid_capture(channel, samples, captures, segment=0, datatype=DATA_TYPE.INT16_T, ratio_mode=RATIO_MODE.RAW, action=ACTION.CLEAR_ALL | ACTION.ADD)

Allocate and assign max and min NumPy-backed data buffers for rapid block capture on a specified channel.

Parameters:
  • channel (int) –

    The channel to associate the buffer with (e.g., CHANNEL.A).

  • samples (int) –

    Number of samples to allocate in the buffer.

  • captures (int) –

    Number of rapid block captures

  • segment (int, default: 0 ) –

    Memory segment to start at.

  • datatype (DATA_TYPE, default: INT16_T ) –

    C data type for the buffer (e.g., INT16_T).

  • ratio_mode (RATIO_MODE, default: RAW ) –

    Downsampling mode.

  • action (ACTION, default: CLEAR_ALL | ADD ) –

    Action to apply to the data buffer (e.g., CLEAR_ALL | ADD).

Returns:
  • ndarray | None

    np.array | None: The allocated buffer or None when clearing existing buffers.

Raises:
  • PicoSDKException

    If an unsupported data type is provided.