pylablib.devices.Tektronix package

Submodules

pylablib.devices.Tektronix.base module

exception pylablib.devices.Tektronix.base.TektronixError[source]

Bases: pylablib.core.devio.base.DeviceError

Generic Tektronix devices error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

exception pylablib.devices.Tektronix.base.TektronixBackendError(exc)[source]

Bases: pylablib.devices.Tektronix.base.TektronixError, pylablib.core.devio.comm_backend.DeviceBackendError

Generic Tektronix backend communication error

args
with_traceback()

Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.

pylablib.devices.Tektronix.base.muxchannel(*args, **kwargs)[source]

Multiplex the function over its channel argument

class pylablib.devices.Tektronix.base.TTriggerParameters(source, level, coupling, slope)

Bases: tuple

count()

Return number of occurrences of value.

coupling
index()

Return first index of value.

Raises ValueError if the value is not present.

level
slope
source
class pylablib.devices.Tektronix.base.ITektronixScope(addr, nchannels='auto')[source]

Bases: pylablib.core.devio.SCPI.SCPIDevice

Generic Tektronix oscilloscope.

Parameters:
  • addr – device address; usually a VISA address string such as "USB0::0x0699::0x0364::C000000::INSTR"
  • nchannels – can specify number of channels on the oscilloscope; by default, autodetect number of channels (might take several seconds on connection)
Error

alias of TektronixError

ReraiseError

alias of TektronixBackendError

get_channels_number()[source]

Get the number of channels

get_channels(only_main=False)[source]

Get the list of all input channels (if only_main==True) or all available channels (if only_main==False)

normalize_channel_name(channel)[source]

Normalize channel name as represented by the oscilloscope

grab_single(wait=True, software_trigger=False, wait_timeout=None)[source]

Set single waveform grabbing and wait for acquisition.

If wait==True, wait until the acquisition is complete; otherwise, return immediately. if software_trigger==True, send the software trigger after setup (i.e., the device triggers immediately regardless of the input).

wait_for_grabbing(timeout=None)[source]

Wait until the acquisition is complete

grab_continuous(enable=True)[source]

Start or stop continuous grabbing

stop_grabbing()[source]

Stop grabbing or waiting (equivalent to self.grab_continuous(False))

is_continuous()[source]

Check if grabbing is continuous or single

is_grabbing()[source]

Check if acquisition is in progress.

Return True if the oscilloscope is recording data, or if the trigger is armed/ready and waiting; return False if the acquisition is stopped. To check if the trigger has been triggered, use get_trigger_state().

get_edge_trigger_source()[source]

Get edge trigger source.

Can be an integer indicating channel number or a name of a special channel.

set_edge_trigger_source(channel)[source]

Get edge trigger source.

Can be an integer indicating channel number or a name of a special channel.

get_edge_trigger_coupling()[source]

Get edge trigger coupling ("ac" or "dc")

set_edge_trigger_coupling(coupling)[source]

Set edge trigger coupling ("ac" or "dc")

get_edge_trigger_slope()[source]

Get edge trigger slope ("fall" or "rise")

set_edge_trigger_slope(slope)[source]

Set edge trigger slope ("fall" or "rise")

get_trigger_level()[source]

Get edge trigger level (in Volts)

set_trigger_level(level)[source]

Set edge trigger level (in Volts)

setup_edge_trigger(source, level, coupling='dc', slope='rise')[source]

Setup edge trigger.

Set source, level, coupling and slope (see corresponding methods for details).

get_trigger_mode()[source]

Get trigger mode.

Can be either "auto" or "norm".

set_trigger_mode(trigger_mode='auto')[source]

Set trigger mode.

Can be either "auto" or "norm".

get_trigger_state()[source]

Get trigger state.

Can be "armed" (acquiring pretrigger), "ready" (pretrigger acquired, wait for trigger event), "trigger" (triggered, acquiring the rest of the waveform), "auto" ("auto" mode trigger is acquiring data in the absence of trigger), "save" (acquisition is stopped), or "scan" (oscilloscope in the scan mode)

force_trigger()[source]

Force trigger event

get_horizontal_span()[source]

Get horizontal span (in seconds)

set_horizontal_span(span)[source]

Set horizontal span (in seconds)

get_horizontal_offset()[source]

Get horizontal offset (position of the center of the sweep; in seconds)

set_horizontal_offset(offset=0.0)[source]

Set horizontal offset (position of the center of the sweep; in seconds)

get_vertical_span(channel)[source]

Get channel vertical span (in V)

set_vertical_span(channel, span)[source]

Set channel vertical span (in V)

get_vertical_position(channel)[source]

Get channel vertical position (offset of the zero volt line; in V)

set_vertical_position(channel, position)[source]

Set channel vertical position (offset of the zero volt line; in V)

is_channel_enabled(channel)[source]

Check if channel is enabled

enable_channel(channel, enabled=True)[source]

Enable or disable given channel

get_selected_channel()[source]

Get selected source channel.

Return number if it is a real channel, or a string name otherwise.

select_channel(channel)[source]

Select a channel to read data.

Doesn’t need to be called explicitly, if read_multiple_sweeps() or read_sweep() are used.

get_coupling(channel)[source]

Get channel coupling.

Can be "ac", "dc", or "gnd".

set_coupling(channel, coupling='dc')[source]

Set channel coupling.

Can be "ac", "dc", or "gnd".

get_probe_attenuation(channel)[source]

Get channel probe attenuation

set_probe_attenuation(channel, attenuation)[source]

Set channel probe attenuation

get_points_number(kind='send')[source]

Get number of datapoints in various context.

kind defines the context. It can be "acq" (number of points acquired), "trace" (number of points in the source of the read-out trace; can be lower than "acq" if the data resolution is reduced, or if the source is not a channel data), or "send" (number of points in the sent waveform; can be lower than "trace" if get_data_pts_range() is used to specify and incomplete range). Not all kinds are defined for all scope model (e.g., "trace" is not defined for TDS2000 series oscilloscopes).

For length of read-out trace, see also get_data_pts_range().

set_points_number(pts_num, reset_limits=True)[source]

Set number of datapoints to record when acquiring a trace.

If reset_limits==True, reset the datapoints range (set_data_pts_range()) to the full range. The actual set value (returned by this method) can be different from the requested value.

get_data_pts_range()[source]

Get range of data points to read.

The range is defined from 1 to the points number (returned by get_points_number()).

set_data_pts_range(rng=None)[source]

Set range of data points to read.

The range is defined from 1 to the points number (returned by get_points_number() with kind="acq"). If rng is None, set the full range.

set_data_format(fmt='default')[source]

Set data transfer format.

fmt is a string describing the format; can be either "ascii", or a numpy-style format string (e.g., "<u2"). If "default", use the oscilloscope default format (usually binary with smallest appropriate byte size).

get_data_format()[source]

Get data transfer format.

Return a string describing the format; can be either "ascii", or a numpy-style format string (e.g., "<u2").

get_wfmpre(channel=None, enable=True)[source]

Get preamble dictionary describing all scaling and format data for the given channel or a list of channels.

Can be acquired once and used in subsequent multiple reads to save time on re-requesting. If channel is None, use the currently selected channel. If enable==True, make sure that the requested channel is enabled; getting preamble for disabled channels raises an error.

read_raw_data(channel=None, fmt=None, timeout=None)[source]

Request, read and parse raw data at a given channel.

fmt is data format (e.g., "i1", "<i2", or "ascii") or "default", which uses the default oscilloscope format (usually binary with smallest appropriate byte size). If fmt is None, use the current format. If channel is None, use the currently selected channel.

Returned data is raw (i.e., not scaled and without x axis).

read_multiple_sweeps(channels, wfmpres=None, ensure_fmt=False, timeout=None, return_wfmpres=None)[source]

Read data from a multiple channels channel.

Parameters:
  • channels – list of channel indices or names
  • wfmpres – optional list or dictionary of preambles (obtained using get_wfmpre()); if it is None, obtain during reading, which slows down the data acquisition a bit
  • ensure_fmt – if True, make sure that oscilloscope data format agrees with the one in wfmpre
  • timeout – read timeout
  • return_wfmpres – if True, return tuple (sweeps, wfmpres), where wfmpres can be used for further sweep readouts.
read_sweep(channel, wfmpre=None, ensure_fmt=True, timeout=None)[source]

Read data from a single channel.

Parameters:
  • channel – channel index or name
  • wfmpre – optional preamble dictionary (obtained using get_wfmpre()); if it is None, obtain during reading, which slows down the data acquisition a bit
  • ensure_fmt – if True, make sure that oscilloscope data format agrees with the one in wfmpre
  • timeout – read timeout
BackendError

alias of pylablib.core.devio.comm_backend.DeviceBackendError

class NoParameterCaller(device, kind)

Bases: object

Class to simplify calling functions without a parameter

apply_settings(settings)

Apply the settings.

settings is a dict {name: value} of the available device settings. Non-applicable settings are ignored.

ask(msg, data_type='string', delay=0.0, timeout=None, read_echo=False)

Write a message and read a reply.

msg is the query message, delay is the delay between write and read. Other parameters are the same as in read(). If read_echo==True, assume that the device first echoes the input and skip it.

close()

Close the backend

flush(one_line=False)

Flush the read buffer (read all the available data and return the number of bytes read).

If one_line==True, read only a single line.

static get_arg_type(arg)

Autodetect argument type

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_esr(timeout=None)

Get the device status register (by default, "*ESR?" command)

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_id(timeout=None)

Get the device IDN. (query SCPI '*IDN?' command)

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

is_opened()

Check if the device is connected

lock(timeout=None)

Lock the access to the device from other threads/processes (isn’t necessarily implemented)

locking(timeout=None)

Context manager for lock & unlock

open()

Open the backend

static parse_array_data(data, fmt, include_header=False)

Parse the data returned by the device. fmt is DataFormat description in numpy format (e.g., "<u2").

If include_header==True, the data is assumed to be in a (somewhat) standard SCPI format: b'#', then a single digit s denoting length of the size block, then s digits denoting length of the data (in bytes) followed by the actual data. Otherwise (include_header==False), assume that the header is already removed.

read(data_type='string', timeout=None)

Read data from the device.

data_type determines the type of the data. Can be 'raw' (just raw data), 'string' (with trailing and leading spaces stripped), 'int', 'float', 'bool' (interprets 0 or 'off' as False, anything else as True), 'value' (returns tuple (value, unit), where value is float), a callable (return the result of this callable applied to the string value), a dictionary (return the stored value corresponding to the string value, or to the value converted into integer if the string value is not present), or a list of data types (the result is treated as a list of values with the given types separated by commas). timeout overrides the default value.

read_binary_array_data(include_header=False, timeout=None, flush_term=True)

Read a binary data in the from the device.

The data assumes the standard binary transfer header consisting of "#" symbol, then a single digit with the size of the length string, then the length string containing the length of the binary data (in bytes). If include_header==True, return the data with the header; otherwise, return only the content. If flush_term==True, flush the following line to skip terminator characters after the binary data, which are added by some devices. timeout overrides the default value.

reconnect(new_instrument=True, ignore_error=True)

Remake the connection.

If new_instrument==True, create a new backend instance. If ignore_error==True, ignore errors on closing.

reset()

Reset the device (by default, "*RST" command)

set_device_variable(key, value)

Set the value of a settings parameter

sleep(delay)

Wait for delay seconds

unlock()

Unlock the access to the device from other threads/processes (isn’t necessarily implemented)

using_write_buffer()

Context manager for using a write buffer.

While it’s active, all the consecutive write() operations are bundled together with ; delimiter. The actual write is performed at the read()/ask() operation or at the end of the block.

wait(wait_type='sync', timeout=None, wait_callback=None)

Pause execution until device overlapped commands are complete.

wait_type is either 'sync' (perform wait_sync()), 'dev' (perform wait_dev()) or 'none' (do nothing).

wait_dev()

Pause execution of the device commands until device overlapped commands (e.g., taking sweeps) are complete.

Note that the code execution is not paused.

wait_sync(timeout=None, wait_callback=None)

Pause execution of the script until device overlapped commands (e.g., taking sweeps) are complete.

timeout and wait_callback override default constructor parameters.

write(msg, arg=None, arg_type=None, unit=None, bool_selector=None, wait_sync=None, read_echo=False, read_echo_delay=0.0)

Send a command.

Parameters:
  • msg (str) – Text message.
  • arg – Optional argument to append in the end. If a list of arguments is supplied, the result is joined with ",".
  • arg_type (str) – Argument type. Can be 'raw' (in which case data is sent raw), 'string', 'int', 'float', 'bool', a format string (such as '{:.3f}') or a list of argument types (for an iterable argument); if format string is used and the argument is a list or a tuple, then it is expanded as a list of arguments (e.g., arg_type='{0};{1}' with arg=[1,2] will produce a string '1;2'); if a list of types is used, each element of arg is converted using the corresponding type, and the result is joined with ",".
  • unit (str) – If not None, use it as a unit to append after the value.
  • bool_selector (tuple) – A tuple (false_value, true_value) of two strings to represent bool argument; by default, use ._bool_selector attribute.
  • wait_sync – if True, append the sync command (specified as ._wait_sync_comm attribute, "*OPC?" by default) after the message and pause the execution command is complete; useful in long set operations, where the device might ignore later inputs until the current command is complete; if None, use the class default ._default_write_sync attribute (False by default).
  • read_echo (bool) – If True, read a single line after write.
  • read_echo_delay (float) – The delay between write and read if read_echo==True.
class pylablib.devices.Tektronix.base.TDS2000(addr, nchannels='auto')[source]

Bases: pylablib.devices.Tektronix.base.ITektronixScope

Tektronix TDS2000 series oscilloscope.

Parameters:
  • addr – device address; usually a VISA address string such as "USB0::0x0699::0x0364::C000000::INSTR"
  • nchannels – can specify number of channels on the oscilloscope; by default, autodetect number of channels (might take several seconds on connection)
BackendError

alias of pylablib.core.devio.comm_backend.DeviceBackendError

Error

alias of TektronixError

class NoParameterCaller(device, kind)

Bases: object

Class to simplify calling functions without a parameter

ReraiseError

alias of TektronixBackendError

apply_settings(settings)

Apply the settings.

settings is a dict {name: value} of the available device settings. Non-applicable settings are ignored.

ask(msg, data_type='string', delay=0.0, timeout=None, read_echo=False)

Write a message and read a reply.

msg is the query message, delay is the delay between write and read. Other parameters are the same as in read(). If read_echo==True, assume that the device first echoes the input and skip it.

close()

Close the backend

enable_channel(channel, enabled=True)

Enable or disable given channel

flush(one_line=False)

Flush the read buffer (read all the available data and return the number of bytes read).

If one_line==True, read only a single line.

force_trigger()

Force trigger event

static get_arg_type(arg)

Autodetect argument type

get_channels(only_main=False)

Get the list of all input channels (if only_main==True) or all available channels (if only_main==False)

get_channels_number()

Get the number of channels

get_coupling(channel)

Get channel coupling.

Can be "ac", "dc", or "gnd".

get_data_format()

Get data transfer format.

Return a string describing the format; can be either "ascii", or a numpy-style format string (e.g., "<u2").

get_data_pts_range()

Get range of data points to read.

The range is defined from 1 to the points number (returned by get_points_number()).

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_edge_trigger_coupling()

Get edge trigger coupling ("ac" or "dc")

get_edge_trigger_slope()

Get edge trigger slope ("fall" or "rise")

get_edge_trigger_source()

Get edge trigger source.

Can be an integer indicating channel number or a name of a special channel.

get_esr(timeout=None)

Get the device status register (by default, "*ESR?" command)

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_horizontal_offset()

Get horizontal offset (position of the center of the sweep; in seconds)

get_horizontal_span()

Get horizontal span (in seconds)

get_id(timeout=None)

Get the device IDN. (query SCPI '*IDN?' command)

get_points_number(kind='send')

Get number of datapoints in various context.

kind defines the context. It can be "acq" (number of points acquired), "trace" (number of points in the source of the read-out trace; can be lower than "acq" if the data resolution is reduced, or if the source is not a channel data), or "send" (number of points in the sent waveform; can be lower than "trace" if get_data_pts_range() is used to specify and incomplete range). Not all kinds are defined for all scope model (e.g., "trace" is not defined for TDS2000 series oscilloscopes).

For length of read-out trace, see also get_data_pts_range().

get_probe_attenuation(channel)

Get channel probe attenuation

get_selected_channel()

Get selected source channel.

Return number if it is a real channel, or a string name otherwise.

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_trigger_level()

Get edge trigger level (in Volts)

get_trigger_mode()

Get trigger mode.

Can be either "auto" or "norm".

get_trigger_state()

Get trigger state.

Can be "armed" (acquiring pretrigger), "ready" (pretrigger acquired, wait for trigger event), "trigger" (triggered, acquiring the rest of the waveform), "auto" ("auto" mode trigger is acquiring data in the absence of trigger), "save" (acquisition is stopped), or "scan" (oscilloscope in the scan mode)

get_vertical_position(channel)

Get channel vertical position (offset of the zero volt line; in V)

get_vertical_span(channel)

Get channel vertical span (in V)

get_wfmpre(channel=None, enable=True)

Get preamble dictionary describing all scaling and format data for the given channel or a list of channels.

Can be acquired once and used in subsequent multiple reads to save time on re-requesting. If channel is None, use the currently selected channel. If enable==True, make sure that the requested channel is enabled; getting preamble for disabled channels raises an error.

grab_continuous(enable=True)

Start or stop continuous grabbing

grab_single(wait=True, software_trigger=False, wait_timeout=None)

Set single waveform grabbing and wait for acquisition.

If wait==True, wait until the acquisition is complete; otherwise, return immediately. if software_trigger==True, send the software trigger after setup (i.e., the device triggers immediately regardless of the input).

is_channel_enabled(channel)

Check if channel is enabled

is_continuous()

Check if grabbing is continuous or single

is_grabbing()

Check if acquisition is in progress.

Return True if the oscilloscope is recording data, or if the trigger is armed/ready and waiting; return False if the acquisition is stopped. To check if the trigger has been triggered, use get_trigger_state().

is_opened()

Check if the device is connected

lock(timeout=None)

Lock the access to the device from other threads/processes (isn’t necessarily implemented)

locking(timeout=None)

Context manager for lock & unlock

normalize_channel_name(channel)

Normalize channel name as represented by the oscilloscope

open()

Open the backend

static parse_array_data(data, fmt, include_header=False)

Parse the data returned by the device. fmt is DataFormat description in numpy format (e.g., "<u2").

If include_header==True, the data is assumed to be in a (somewhat) standard SCPI format: b'#', then a single digit s denoting length of the size block, then s digits denoting length of the data (in bytes) followed by the actual data. Otherwise (include_header==False), assume that the header is already removed.

read(data_type='string', timeout=None)

Read data from the device.

data_type determines the type of the data. Can be 'raw' (just raw data), 'string' (with trailing and leading spaces stripped), 'int', 'float', 'bool' (interprets 0 or 'off' as False, anything else as True), 'value' (returns tuple (value, unit), where value is float), a callable (return the result of this callable applied to the string value), a dictionary (return the stored value corresponding to the string value, or to the value converted into integer if the string value is not present), or a list of data types (the result is treated as a list of values with the given types separated by commas). timeout overrides the default value.

read_binary_array_data(include_header=False, timeout=None, flush_term=True)

Read a binary data in the from the device.

The data assumes the standard binary transfer header consisting of "#" symbol, then a single digit with the size of the length string, then the length string containing the length of the binary data (in bytes). If include_header==True, return the data with the header; otherwise, return only the content. If flush_term==True, flush the following line to skip terminator characters after the binary data, which are added by some devices. timeout overrides the default value.

read_multiple_sweeps(channels, wfmpres=None, ensure_fmt=False, timeout=None, return_wfmpres=None)

Read data from a multiple channels channel.

Parameters:
  • channels – list of channel indices or names
  • wfmpres – optional list or dictionary of preambles (obtained using get_wfmpre()); if it is None, obtain during reading, which slows down the data acquisition a bit
  • ensure_fmt – if True, make sure that oscilloscope data format agrees with the one in wfmpre
  • timeout – read timeout
  • return_wfmpres – if True, return tuple (sweeps, wfmpres), where wfmpres can be used for further sweep readouts.
read_raw_data(channel=None, fmt=None, timeout=None)

Request, read and parse raw data at a given channel.

fmt is data format (e.g., "i1", "<i2", or "ascii") or "default", which uses the default oscilloscope format (usually binary with smallest appropriate byte size). If fmt is None, use the current format. If channel is None, use the currently selected channel.

Returned data is raw (i.e., not scaled and without x axis).

read_sweep(channel, wfmpre=None, ensure_fmt=True, timeout=None)

Read data from a single channel.

Parameters:
  • channel – channel index or name
  • wfmpre – optional preamble dictionary (obtained using get_wfmpre()); if it is None, obtain during reading, which slows down the data acquisition a bit
  • ensure_fmt – if True, make sure that oscilloscope data format agrees with the one in wfmpre
  • timeout – read timeout
reconnect(new_instrument=True, ignore_error=True)

Remake the connection.

If new_instrument==True, create a new backend instance. If ignore_error==True, ignore errors on closing.

reset()

Reset the device (by default, "*RST" command)

select_channel(channel)

Select a channel to read data.

Doesn’t need to be called explicitly, if read_multiple_sweeps() or read_sweep() are used.

set_coupling(channel, coupling='dc')

Set channel coupling.

Can be "ac", "dc", or "gnd".

set_data_format(fmt='default')

Set data transfer format.

fmt is a string describing the format; can be either "ascii", or a numpy-style format string (e.g., "<u2"). If "default", use the oscilloscope default format (usually binary with smallest appropriate byte size).

set_data_pts_range(rng=None)

Set range of data points to read.

The range is defined from 1 to the points number (returned by get_points_number() with kind="acq"). If rng is None, set the full range.

set_device_variable(key, value)

Set the value of a settings parameter

set_edge_trigger_coupling(coupling)

Set edge trigger coupling ("ac" or "dc")

set_edge_trigger_slope(slope)

Set edge trigger slope ("fall" or "rise")

set_edge_trigger_source(channel)

Get edge trigger source.

Can be an integer indicating channel number or a name of a special channel.

set_horizontal_offset(offset=0.0)

Set horizontal offset (position of the center of the sweep; in seconds)

set_horizontal_span(span)

Set horizontal span (in seconds)

set_points_number(pts_num, reset_limits=True)

Set number of datapoints to record when acquiring a trace.

If reset_limits==True, reset the datapoints range (set_data_pts_range()) to the full range. The actual set value (returned by this method) can be different from the requested value.

set_probe_attenuation(channel, attenuation)

Set channel probe attenuation

set_trigger_level(level)

Set edge trigger level (in Volts)

set_trigger_mode(trigger_mode='auto')

Set trigger mode.

Can be either "auto" or "norm".

set_vertical_position(channel, position)

Set channel vertical position (offset of the zero volt line; in V)

set_vertical_span(channel, span)

Set channel vertical span (in V)

setup_edge_trigger(source, level, coupling='dc', slope='rise')

Setup edge trigger.

Set source, level, coupling and slope (see corresponding methods for details).

sleep(delay)

Wait for delay seconds

stop_grabbing()

Stop grabbing or waiting (equivalent to self.grab_continuous(False))

unlock()

Unlock the access to the device from other threads/processes (isn’t necessarily implemented)

using_write_buffer()

Context manager for using a write buffer.

While it’s active, all the consecutive write() operations are bundled together with ; delimiter. The actual write is performed at the read()/ask() operation or at the end of the block.

wait(wait_type='sync', timeout=None, wait_callback=None)

Pause execution until device overlapped commands are complete.

wait_type is either 'sync' (perform wait_sync()), 'dev' (perform wait_dev()) or 'none' (do nothing).

wait_dev()

Pause execution of the device commands until device overlapped commands (e.g., taking sweeps) are complete.

Note that the code execution is not paused.

wait_for_grabbing(timeout=None)

Wait until the acquisition is complete

wait_sync(timeout=None, wait_callback=None)

Pause execution of the script until device overlapped commands (e.g., taking sweeps) are complete.

timeout and wait_callback override default constructor parameters.

write(msg, arg=None, arg_type=None, unit=None, bool_selector=None, wait_sync=None, read_echo=False, read_echo_delay=0.0)

Send a command.

Parameters:
  • msg (str) – Text message.
  • arg – Optional argument to append in the end. If a list of arguments is supplied, the result is joined with ",".
  • arg_type (str) – Argument type. Can be 'raw' (in which case data is sent raw), 'string', 'int', 'float', 'bool', a format string (such as '{:.3f}') or a list of argument types (for an iterable argument); if format string is used and the argument is a list or a tuple, then it is expanded as a list of arguments (e.g., arg_type='{0};{1}' with arg=[1,2] will produce a string '1;2'); if a list of types is used, each element of arg is converted using the corresponding type, and the result is joined with ",".
  • unit (str) – If not None, use it as a unit to append after the value.
  • bool_selector (tuple) – A tuple (false_value, true_value) of two strings to represent bool argument; by default, use ._bool_selector attribute.
  • wait_sync – if True, append the sync command (specified as ._wait_sync_comm attribute, "*OPC?" by default) after the message and pause the execution command is complete; useful in long set operations, where the device might ignore later inputs until the current command is complete; if None, use the class default ._default_write_sync attribute (False by default).
  • read_echo (bool) – If True, read a single line after write.
  • read_echo_delay (float) – The delay between write and read if read_echo==True.
class pylablib.devices.Tektronix.base.DPO2000(addr, nchannels='auto')[source]

Bases: pylablib.devices.Tektronix.base.ITektronixScope

Tektronix DPO2000 series oscilloscope.

Parameters:
  • addr – device address; usually a VISA address string such as "USB0::0x0699::0x0364::C000000::INSTR"
  • nchannels – can specify number of channels on the oscilloscope; by default, autodetect number of channels (might take several seconds on connection)
BackendError

alias of pylablib.core.devio.comm_backend.DeviceBackendError

Error

alias of TektronixError

class NoParameterCaller(device, kind)

Bases: object

Class to simplify calling functions without a parameter

ReraiseError

alias of TektronixBackendError

apply_settings(settings)

Apply the settings.

settings is a dict {name: value} of the available device settings. Non-applicable settings are ignored.

ask(msg, data_type='string', delay=0.0, timeout=None, read_echo=False)

Write a message and read a reply.

msg is the query message, delay is the delay between write and read. Other parameters are the same as in read(). If read_echo==True, assume that the device first echoes the input and skip it.

close()

Close the backend

enable_channel(channel, enabled=True)

Enable or disable given channel

flush(one_line=False)

Flush the read buffer (read all the available data and return the number of bytes read).

If one_line==True, read only a single line.

force_trigger()

Force trigger event

static get_arg_type(arg)

Autodetect argument type

get_channels(only_main=False)

Get the list of all input channels (if only_main==True) or all available channels (if only_main==False)

get_channels_number()

Get the number of channels

get_coupling(channel)

Get channel coupling.

Can be "ac", "dc", or "gnd".

get_data_format()

Get data transfer format.

Return a string describing the format; can be either "ascii", or a numpy-style format string (e.g., "<u2").

get_data_pts_range()

Get range of data points to read.

The range is defined from 1 to the points number (returned by get_points_number()).

get_device_variable(key)

Get the value of a settings, status, or full info parameter

get_edge_trigger_coupling()

Get edge trigger coupling ("ac" or "dc")

get_edge_trigger_slope()

Get edge trigger slope ("fall" or "rise")

get_edge_trigger_source()

Get edge trigger source.

Can be an integer indicating channel number or a name of a special channel.

get_esr(timeout=None)

Get the device status register (by default, "*ESR?" command)

get_full_info(include=0)

Get dict {name: value} containing full device information (including status and settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_full_status(include=0)

Get dict {name: value} containing the device status (including settings).

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_horizontal_offset()

Get horizontal offset (position of the center of the sweep; in seconds)

get_horizontal_span()

Get horizontal span (in seconds)

get_id(timeout=None)

Get the device IDN. (query SCPI '*IDN?' command)

get_points_number(kind='send')

Get number of datapoints in various context.

kind defines the context. It can be "acq" (number of points acquired), "trace" (number of points in the source of the read-out trace; can be lower than "acq" if the data resolution is reduced, or if the source is not a channel data), or "send" (number of points in the sent waveform; can be lower than "trace" if get_data_pts_range() is used to specify and incomplete range). Not all kinds are defined for all scope model (e.g., "trace" is not defined for TDS2000 series oscilloscopes).

For length of read-out trace, see also get_data_pts_range().

get_probe_attenuation(channel)

Get channel probe attenuation

get_selected_channel()

Get selected source channel.

Return number if it is a real channel, or a string name otherwise.

get_settings(include=0)

Get dict {name: value} containing all the device settings.

include specifies either a list of variables (only these variables are returned), a priority threshold (only values with the priority equal or higher are returned), or "all" (all available variables). Since the lowest priority is -10, setting include=-10 queries all available variables, which is equivalent to include="all".

get_trigger_level()

Get edge trigger level (in Volts)

get_trigger_mode()

Get trigger mode.

Can be either "auto" or "norm".

get_trigger_state()

Get trigger state.

Can be "armed" (acquiring pretrigger), "ready" (pretrigger acquired, wait for trigger event), "trigger" (triggered, acquiring the rest of the waveform), "auto" ("auto" mode trigger is acquiring data in the absence of trigger), "save" (acquisition is stopped), or "scan" (oscilloscope in the scan mode)

get_vertical_position(channel)

Get channel vertical position (offset of the zero volt line; in V)

get_vertical_span(channel)

Get channel vertical span (in V)

get_wfmpre(channel=None, enable=True)

Get preamble dictionary describing all scaling and format data for the given channel or a list of channels.

Can be acquired once and used in subsequent multiple reads to save time on re-requesting. If channel is None, use the currently selected channel. If enable==True, make sure that the requested channel is enabled; getting preamble for disabled channels raises an error.

grab_continuous(enable=True)

Start or stop continuous grabbing

grab_single(wait=True, software_trigger=False, wait_timeout=None)

Set single waveform grabbing and wait for acquisition.

If wait==True, wait until the acquisition is complete; otherwise, return immediately. if software_trigger==True, send the software trigger after setup (i.e., the device triggers immediately regardless of the input).

is_channel_enabled(channel)

Check if channel is enabled

is_continuous()

Check if grabbing is continuous or single

is_grabbing()

Check if acquisition is in progress.

Return True if the oscilloscope is recording data, or if the trigger is armed/ready and waiting; return False if the acquisition is stopped. To check if the trigger has been triggered, use get_trigger_state().

is_opened()

Check if the device is connected

lock(timeout=None)

Lock the access to the device from other threads/processes (isn’t necessarily implemented)

locking(timeout=None)

Context manager for lock & unlock

normalize_channel_name(channel)

Normalize channel name as represented by the oscilloscope

open()

Open the backend

static parse_array_data(data, fmt, include_header=False)

Parse the data returned by the device. fmt is DataFormat description in numpy format (e.g., "<u2").

If include_header==True, the data is assumed to be in a (somewhat) standard SCPI format: b'#', then a single digit s denoting length of the size block, then s digits denoting length of the data (in bytes) followed by the actual data. Otherwise (include_header==False), assume that the header is already removed.

read(data_type='string', timeout=None)

Read data from the device.

data_type determines the type of the data. Can be 'raw' (just raw data), 'string' (with trailing and leading spaces stripped), 'int', 'float', 'bool' (interprets 0 or 'off' as False, anything else as True), 'value' (returns tuple (value, unit), where value is float), a callable (return the result of this callable applied to the string value), a dictionary (return the stored value corresponding to the string value, or to the value converted into integer if the string value is not present), or a list of data types (the result is treated as a list of values with the given types separated by commas). timeout overrides the default value.

read_binary_array_data(include_header=False, timeout=None, flush_term=True)

Read a binary data in the from the device.

The data assumes the standard binary transfer header consisting of "#" symbol, then a single digit with the size of the length string, then the length string containing the length of the binary data (in bytes). If include_header==True, return the data with the header; otherwise, return only the content. If flush_term==True, flush the following line to skip terminator characters after the binary data, which are added by some devices. timeout overrides the default value.

read_multiple_sweeps(channels, wfmpres=None, ensure_fmt=False, timeout=None, return_wfmpres=None)

Read data from a multiple channels channel.

Parameters:
  • channels – list of channel indices or names
  • wfmpres – optional list or dictionary of preambles (obtained using get_wfmpre()); if it is None, obtain during reading, which slows down the data acquisition a bit
  • ensure_fmt – if True, make sure that oscilloscope data format agrees with the one in wfmpre
  • timeout – read timeout
  • return_wfmpres – if True, return tuple (sweeps, wfmpres), where wfmpres can be used for further sweep readouts.
read_raw_data(channel=None, fmt=None, timeout=None)

Request, read and parse raw data at a given channel.

fmt is data format (e.g., "i1", "<i2", or "ascii") or "default", which uses the default oscilloscope format (usually binary with smallest appropriate byte size). If fmt is None, use the current format. If channel is None, use the currently selected channel.

Returned data is raw (i.e., not scaled and without x axis).

read_sweep(channel, wfmpre=None, ensure_fmt=True, timeout=None)

Read data from a single channel.

Parameters:
  • channel – channel index or name
  • wfmpre – optional preamble dictionary (obtained using get_wfmpre()); if it is None, obtain during reading, which slows down the data acquisition a bit
  • ensure_fmt – if True, make sure that oscilloscope data format agrees with the one in wfmpre
  • timeout – read timeout
reconnect(new_instrument=True, ignore_error=True)

Remake the connection.

If new_instrument==True, create a new backend instance. If ignore_error==True, ignore errors on closing.

reset()

Reset the device (by default, "*RST" command)

select_channel(channel)

Select a channel to read data.

Doesn’t need to be called explicitly, if read_multiple_sweeps() or read_sweep() are used.

set_coupling(channel, coupling='dc')

Set channel coupling.

Can be "ac", "dc", or "gnd".

set_data_format(fmt='default')

Set data transfer format.

fmt is a string describing the format; can be either "ascii", or a numpy-style format string (e.g., "<u2"). If "default", use the oscilloscope default format (usually binary with smallest appropriate byte size).

set_data_pts_range(rng=None)

Set range of data points to read.

The range is defined from 1 to the points number (returned by get_points_number() with kind="acq"). If rng is None, set the full range.

set_device_variable(key, value)

Set the value of a settings parameter

set_edge_trigger_coupling(coupling)

Set edge trigger coupling ("ac" or "dc")

set_edge_trigger_slope(slope)

Set edge trigger slope ("fall" or "rise")

set_edge_trigger_source(channel)

Get edge trigger source.

Can be an integer indicating channel number or a name of a special channel.

set_horizontal_offset(offset=0.0)

Set horizontal offset (position of the center of the sweep; in seconds)

set_horizontal_span(span)

Set horizontal span (in seconds)

set_points_number(pts_num, reset_limits=True)

Set number of datapoints to record when acquiring a trace.

If reset_limits==True, reset the datapoints range (set_data_pts_range()) to the full range. The actual set value (returned by this method) can be different from the requested value.

set_probe_attenuation(channel, attenuation)

Set channel probe attenuation

set_trigger_level(level)

Set edge trigger level (in Volts)

set_trigger_mode(trigger_mode='auto')

Set trigger mode.

Can be either "auto" or "norm".

set_vertical_position(channel, position)

Set channel vertical position (offset of the zero volt line; in V)

set_vertical_span(channel, span)

Set channel vertical span (in V)

setup_edge_trigger(source, level, coupling='dc', slope='rise')

Setup edge trigger.

Set source, level, coupling and slope (see corresponding methods for details).

sleep(delay)

Wait for delay seconds

stop_grabbing()

Stop grabbing or waiting (equivalent to self.grab_continuous(False))

unlock()

Unlock the access to the device from other threads/processes (isn’t necessarily implemented)

using_write_buffer()

Context manager for using a write buffer.

While it’s active, all the consecutive write() operations are bundled together with ; delimiter. The actual write is performed at the read()/ask() operation or at the end of the block.

wait(wait_type='sync', timeout=None, wait_callback=None)

Pause execution until device overlapped commands are complete.

wait_type is either 'sync' (perform wait_sync()), 'dev' (perform wait_dev()) or 'none' (do nothing).

wait_dev()

Pause execution of the device commands until device overlapped commands (e.g., taking sweeps) are complete.

Note that the code execution is not paused.

wait_for_grabbing(timeout=None)

Wait until the acquisition is complete

wait_sync(timeout=None, wait_callback=None)

Pause execution of the script until device overlapped commands (e.g., taking sweeps) are complete.

timeout and wait_callback override default constructor parameters.

write(msg, arg=None, arg_type=None, unit=None, bool_selector=None, wait_sync=None, read_echo=False, read_echo_delay=0.0)

Send a command.

Parameters:
  • msg (str) – Text message.
  • arg – Optional argument to append in the end. If a list of arguments is supplied, the result is joined with ",".
  • arg_type (str) – Argument type. Can be 'raw' (in which case data is sent raw), 'string', 'int', 'float', 'bool', a format string (such as '{:.3f}') or a list of argument types (for an iterable argument); if format string is used and the argument is a list or a tuple, then it is expanded as a list of arguments (e.g., arg_type='{0};{1}' with arg=[1,2] will produce a string '1;2'); if a list of types is used, each element of arg is converted using the corresponding type, and the result is joined with ",".
  • unit (str) – If not None, use it as a unit to append after the value.
  • bool_selector (tuple) – A tuple (false_value, true_value) of two strings to represent bool argument; by default, use ._bool_selector attribute.
  • wait_sync – if True, append the sync command (specified as ._wait_sync_comm attribute, "*OPC?" by default) after the message and pause the execution command is complete; useful in long set operations, where the device might ignore later inputs until the current command is complete; if None, use the class default ._default_write_sync attribute (False by default).
  • read_echo (bool) – If True, read a single line after write.
  • read_echo_delay (float) – The delay between write and read if read_echo==True.

Module contents