pytektronix package

Submodules

pytektronix.command_group_objects module

class pytektronix.command_group_objects.Channel(chan_num: int, instr: Scope, accepted_values: dict, is_digital: bool = False, strict: bool = True, cn: str = 'ch')

Bases: CommandGroupObject

__init__(chan_num: int, instr: Scope, accepted_values: dict, is_digital: bool = False, strict: bool = True, cn: str = 'ch')
property accepted_values

The accepted_values property.

property coupling

The coupling property.

property offset: float

The offset property.

property position: float

The position property.

property probe_resistance: float

Get channel PROBE RESISTANCE in OHMS

property scale: float

The scale property.

class pytektronix.command_group_objects.Horizontal(instr: Scope, accepted_values: dict, strict: bool = True, cn: str = 'horizontal')

Bases: CommandGroupObject

__init__(instr: Scope, accepted_values: dict, strict: bool = True, cn: str = 'horizontal')
property accepted_values

The accepted_values property.

property position: float

Gets current horizontal POSITION

property sample_rate

Get the current horizontal SAMPLERATE

property scale

Get the current horizontal SCALE [S]

class pytektronix.command_group_objects.TrigStrings(*args: Any, **kwargs: Any)

Bases: MultiValueEnum

ARMED = ('armed', 'arm')
AUTO = 'auto'
BUS = 'bus'
EDGE = ('edge', 'edg')
LOGIC = ('logic', 'logi')
NORMAL = ('normal', 'norm')
PULSE = ('pulse', 'puls')
READY = ('ready', 'rea')
SAVE = ('save', 'sav')
TRIGGERED = ('triggered', 'trig')
VIDEO = ('video', 'vid')
class pytektronix.command_group_objects.Trigger(instr: Scope, accepted_values: dict, strict: bool = True, cn: str = 'trigger:a')

Bases: CommandGroupObject

__init__(instr: Scope, accepted_values: dict, strict: bool = True, cn: str = 'trigger:a')
property accepted_values

The accepted_values property.

autoset() None

Automatically set trigger level to 50% of range

force() None

Checks if the scope is ready, and then forces a trigger event

property level: float

Get current trigger LEVEL

property mode

Get current trigger MODE

property source

Get current trigger SOURCE

property state

Get current trigger STATE

property trig_type

Get current trigger TYPE

class pytektronix.command_group_objects.WFStrings(*args: Any, **kwargs: Any)

Bases: MultiValueEnum

ASCII = ('ascii', 'asc')
FASTEST = 'fastest'
FPBINARY = ('fpbinary', 'fpb')
RIBINARY = ('ribinary', 'rib')
RPBINARY = ('rpbinary', 'rpb')
SFPBINARY = ('sfpbinary', 'sfp')
SRIBINARY = ('sribinary', 'sri')
SRPBINARY = ('srpbinary', 'srp')
class pytektronix.command_group_objects.WaveformTransfer(instr: Scope, accepted_values: dict, strict: bool = False, auto_init=True)

Bases: CommandGroupObject

__init__(instr: Scope, accepted_values: dict, strict: bool = False, auto_init=True)
property accepted_values

The accepted_values property.

property data_encoding

The data_encoding property.

property data_source

The data_source property.

property data_start: int

The data_start property.

property data_stop: int

The data_stop property.

property data_width: int

The data_width property.

get_data() bytearray
get_data_preamble()
initialize_data(data_source: str = 'CH1')
property num_points: int

The num_points property.

pytektronix.pytektronix_base_classes module

class pytektronix.pytektronix_base_classes.CommandGroupObject

Bases: object

A command group meta object which all command group classes can inherit.

abstract property accepted_values
property supported_models
class pytektronix.pytektronix_base_classes.DebugScope(loud: bool = False)

Bases: Scope

__init__(loud: bool = False)
ask(q: str)

An ask method to query the scope which expects to return a string (lowercase) must be included in any scope class

write(q: str)

A method to send a command to the scope without waiting for a response

class pytektronix.pytektronix_base_classes.LoggedVISA(resource_id: str | None = None, loud: bool = False, log: bool = True)

Bases: Scope

__init__(resource_id: str | None = None, loud: bool = False, log: bool = True)
ask(q: str) str

Sends a query string to the oscilloscope

close()

Closes the visa connection

log(value: str, err: bool = False, err_str: str | None = None) None

Logs the commands sent to the scope, and notes if there was an error

read_raw()
write(command: str) None

Writes a command string to the oscilloscope

class pytektronix.pytektronix_base_classes.LoggedVXI11(*args: Any, **kwargs: Any)

Bases: Instrument, Scope

__init__(IP: str, loud: bool = False)
ask(q: str)

An ask method to query the scope which expects to return a string (lowercase) must be included in any scope class

make_init(fpath: Path | None = None)
write(query: str)

A method to send a command to the scope without waiting for a response

class pytektronix.pytektronix_base_classes.Scope

Bases: object

An abstract metaclass for any type of scope communication (VISA, VXI11, DEBUG, etc.)

abstract ask() str

An ask method to query the scope which expects to return a string (lowercase) must be included in any scope class

abstract write() None

A method to send a command to the scope without waiting for a response

exception pytektronix.pytektronix_base_classes.ScopeNotSupportedError(message: str = 'NO SCOPE SUPPORT')

Bases: Exception

An Error type to demonstrate when a setting has no scope support

__init__(message: str = 'NO SCOPE SUPPORT')
exception pytektronix.pytektronix_base_classes.ScopeStateError(message: str = 'INVALID SCOPE STATE')

Bases: Exception

An Error type for when the scopes current state is not correct for a given command. Examples include when forcing a trigger, the scope trigger state must be ‘READY’, and if the scopes are in ‘strict’ mode, and a trigger force is invoked, pytektronix will raise a ScopeStateError. If the ‘strict’ mode is disabled with (…strict=False) optional, then a simple warning will be printed instead, and the ‘force’ command will not be executed.

__init__(message: str = 'INVALID SCOPE STATE')

pytektronix.scopes module

class pytektronix.scopes.MDO3024(resource_id: str | None = None, vxi11: bool = False, strict: bool = True)

Bases: object

The MDO3024 class is designed to control the Tektronix MDO3024 and perhaps other 3000 Series tektronix oscilloscopes. This scope encapsulates most of the main requirements for the oscilloscope, including Triggering (force and edge & more), horizontal controls, analog and digital channels, as well as waveform capture details.

__init__(resource_id: str | None = None, vxi11: bool = False, strict: bool = True)
Parameters:
  • resource_id: The VISA name or the VXI11 ip address of the scope. Leave blank if unknow, and a connection wizard will be run.

  • vxi11: default False, set to true if connecting the the scope via VXI11 not VISA

  • strict: default True, set to False if errors should be soft and not result in a raised exception.

compute_channel_offset_range(channel: Channel) Tuple

Internal function used to compute the accepted values of the channel offset depending on probe resistance and the vertical scale.

Parameters:

Channel: which channel to check the probe resistance of

Returns:

Tuple: (accepted values)

default_setup()

Does exactly what pressing the ‘Default Setup’ or ‘Auto Setup’ button on the front panel of the oscilloscope would do

get_channel_info(channel: str) str

A getter to retreive and show all settings currently set for the Channel. returns a string of all info.

Parameters:

channel: a channel label (ch<x>, d<x>) of which to get info from

get_horizontal_info(setting: str | None = None) str

A getter to retreive and show all settings currently set for the Horizontal. returns a string of all info.

Parameters:

setting: No Effect as of now… #TODO - get individual settings

get_trigger_info(setting: str | None = None) str

A getter to retreive and show all settings currently set for the trigger. returns a string of all info.

Parameters:

setting: No Effect as of now… #TODO - get individual settings

get_waveform(format: str = 'default') bytearray | numpy.ndarray | list

A scope method to caputure data from the scope returned as a bytearray, list, or np.ndarray.

Parameters:
  • format: Specify return type as bytearray (‘default’), list (‘list’) or numpy ndarray (‘np_array’)

get_waveform_info() str

A getter to retreive and show all settings currently set for the waveform capture. returns a string of all info.

set_channel(channel: str, position: float | None = None, offset: float | None = None, scale: float | None = None, coupling: str | None = None) None

A scope method to set all channel attributes desired.

Parameters:
  • channel: channel for which settings are being changed

  • position: horizontal position of channel referenced to centerline: between (-8,8)

  • offset: vertical offset of channel referenced to centeriline (any)

  • scale: vertical scale of the desired channel

  • coupling: specify coupling of a given channel (AC, DC, DCREJECT)

set_digital() None

A scope method to set all digital channel attributes

set_horizontal(scale: float | None = None, position: float | None = None) None

A scope method to set all horizontal attributes desired.

Parameters:
  • scale: desired horizontal scale in Seconds, can be anything between (4e-10, 1000)

  • position: horizontal positioning expressed as a percentage of the screen (0, 100)

set_trigger(mode: str | None = None, trig_type: str | None = None, source: str | None = None, level: str | float | None = None) None

A scope method to set all trigger attributes desired.

Parameters:
  • mode: desired trigger mode (normal, auto)

  • trig_type: desired trigger type (edge, logic, pulse, bus, video)

  • source: trigger source channel, any digital or logic channel allowed (ch<x> or d<x>)

  • level: desired level of the trigger in Volts, or (ttl, ecl)

set_waveform(data_source: str | None = None, data_encoding: str | None = None, data_width: int | None = None, data_start: int | None = None, data_stop: int | None = None) None

A scope method to set all waveform data related attributes.

Parameters:
  • data_source: source of waveform data (ch<x>, d<x>, ref<x>, math, rf_*)

  • data_encoding: data output encoding (ascii, fastest, ribinary, rpbinary, sribinary srpbinary, fpbinary, sfpbinary)

  • data_width: width of output data in bytes (1,2,4,8 - encoding dependant)

  • data_start: at which sample to start the data capture (1 to 2e6)

  • data_stop: at which sample to stop the data capture (1 to 2e6)

class pytektronix.scopes.MSO54(resource_id: str | None = None, vxi11: bool = False, strict: bool = True)

Bases: object

__init__(resource_id: str | None = None, vxi11: bool = False, strict: bool = True)
compute_channel_offset_range(channel: Channel) Tuple
default_setup()
get_channel_info(channel: str) str
get_horizontal_info(setting: str | None = None) str
get_trigger_info(setting: str | None = None) str
get_waveform(format: str = 'default') bytearray | numpy.ndarray | list

A scope method to caputure data from the scope

get_waveform_info() str
set_channel(channel: str, position: float | None = None, offset: float | None = None, scale: float | None = None, coupling: str | None = None) None

A scope method to set all channel attributes desired

set_digital() None

A scope method to set all digital channel attributes

set_horizontal(scale: float | None = None, position: float | None = None) None

A scope method to set all horizontal attributes desired

set_trigger(trigger: str = 'a', mode: str | None = None, trig_type: str | None = None, source: str | None = None, level: str | float | None = None) None

A scope method to set all trigger attributes desired

set_waveform(data_source: str | None = None, data_encoding: str | None = None, data_width: int | None = None, data_start: int | None = None, data_stop: int | None = None) None

A scope method to set all waveform data related attributes

Module contents