pylablib.devices.PhysikInstrumente package

Submodules

pylablib.devices.PhysikInstrumente.base module

exception pylablib.devices.PhysikInstrumente.base.PhysikInstrumenteError[source]

Bases: DeviceError

Generic Physik Instrumente error

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

exception pylablib.devices.PhysikInstrumente.base.PhysikInstrumenteBackendError(exc)[source]

Bases: PhysikInstrumenteError, DeviceBackendError

Generic Physik Instrumente backend communication error

add_note()

Exception.add_note(note) – add a note to the exception

args
with_traceback()

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

class pylablib.devices.PhysikInstrumente.base.GenericPIController(conn, auto_online=True)[source]

Bases: ICommBackendWrapper, IMultiaxisStage

Generic Physik Instrumente controller.

Parameters:
  • conn – connection parameters (usually port or a tuple containing port and baudrate)

  • auto_online – if True, switch to the online mode upon connection; in this online mode controller parameters are controlled remotely instead of the front panel (including external voltages), while in the offline mode most of the parameters are still controlled manually, and the remote connection is mostly used for readout

Error

alias of PhysikInstrumenteError

open()[source]

Open the backend

query(comm, multiline=False, reply=True)[source]

Query a single command to the controller.

If multiline==True, expect a multi-line reply and return a list with separate reply lines; otherwise, expect a single-line reply and raise an error if multi-line reply is received.

If reply==False, expect no reply at all (used for, e.g., set commands).

query_axis(comm, axis=None, subidx=None, kind='str')[source]

Query the given command for the given axis.

axis can be a single axis name (e.g., "A"), a list of axes, or None, which queries all axes. If axis is a single axis, simply return the corresponding value; otherwise, return a dict {axis: value}. kind can specify value kind: "str" (return as is), "float", "int", or "bool".

set_axis(comm, value, axis=None, subidx=None, reply=False)[source]

Query the given value for the given axis.

value can be a single value (set the same for all specified axes), a list of values (one per axis), or a dict {axis: value}. axis can be a single axis name (e.g., "A"), a list of axes, or None, which queries all axes. If reply==False, expect no reply.

get_id()[source]

Get the device ID string

get_help()[source]

Get the help for all commands; might take a long time on low-speed serial connections

is_online_enabled()[source]

Check if online mode is enabled

enable_online(enable=True)[source]

Enable or disable online mode

get_axis_parameter(pid, axis=None, kind='str')[source]

Get value of the given parameter id for the given axis (all axes by default)

set_axis_parameter(pid, value, axis=None, kind='str')[source]

Get value of the given parameter id for the given axis (all axes by default)

apply_settings(settings)

Apply the settings.

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

close()

Close the backend

get_all_axes()

Get the list of all available axes (taking mapping into account)

get_device_variable(key)

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

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_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

remap_axes(mapping, accept_original=True)

Rename axes to the new labels.

mapping is the new axes mapping, which can be a list of new axes name (corresponding to the old axes in order returned by get_all_axes()), or a dictionary {alias: original} of the new axes aliases.

set_device_variable(key, value)

Set the value of a settings parameter

unlock()

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

class pylablib.devices.PhysikInstrumente.base.PIE516(conn, auto_online=True)[source]

Bases: GenericPIController

Physik Instrumente E-516 controller.

Parameters:
  • conn – serial connection parameters (usually port or a tuple containing port and baudrate)

  • auto_online – if True, switch to the online mode upon connection; in this online mode controller parameters such as voltages or positions are controlled remotely instead of the front panel (including external voltages), while in the offline mode most of the parameters are still controlled manually, and the remote connection is mostly used for readout

is_servo_enabled(axis=None)[source]

Check if the servo is enabled on the given axis (all axes by default)

enable_servo(enable=True, axis=None)[source]

Enable or disable servo on the given axis (all axes by default)

is_drift_compensation_enabled(axis=None)[source]

Check if the drift compensation is enabled on the given axis (all axes by default)

enable_drift_compensation(enable=True, axis=None)[source]

Enable or disable drift compensation on the given axis (all axes by default)

is_velocity_control_enabled(axis=None)[source]

Check if the velocity control is enabled on the given axis (all axes by default)

enable_velocity_control(enable=True, axis=None)[source]

Enable or disable velocity control on the given axis (all axes by default)

get_voltage_setpoint(axis=None)[source]

Get the current voltage setpoint on the given axis (all axes by default)

get_voltage(axis=None)[source]

Get the actual voltage value on the given axis (all axes by default)

set_voltage(voltage, axis=None)[source]

Get the target voltage on the given axis (all axes by default)

get_voltage_lower_limit(axis=None)[source]

Get the lower output voltage limit on the given axis (all axes by default)

set_voltage_lower_limit(voltage, axis=None)[source]

Get the lower output voltage limit on the given axis (all axes by default)

get_voltage_upper_limit(axis=None)[source]

Get the upper output voltage limit on the given axis (all axes by default)

set_voltage_upper_limit(voltage, axis=None)[source]

Get the upper output voltage limit on the given axis (all axes by default)

get_velocity(axis=None)[source]

Get velocity on the given axis (all axes by default)

set_velocity(velocity, axis=None)[source]

Set velocity on the given axis (all axes by default)

get_position(axis=None)[source]

Get the current position on the given axis

get_target_position(axis=None)[source]

Get the target motion position on the given axis

move_to(position, axis=None)[source]

Move the given axis to the given position

move_by(distance, axis=None)[source]

Move the given axis by the given distance

stop(axis=None)[source]

Stop motion on the given axis (all axes by default)

get_position_lower_limit(axis=None)[source]

Get the lower position limit on the given axis (all axes by default)

set_position_lower_limit(position, axis=None)[source]

Get the lower position limit on the given axis (all axes by default)

get_position_upper_limit(axis=None)[source]

Get the upper position limit on the given axis (all axes by default)

set_position_upper_limit(position, axis=None)[source]

Get the upper position limit on the given axis (all axes by default)

Error

alias of PhysikInstrumenteError

apply_settings(settings)

Apply the settings.

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

close()

Close the backend

enable_online(enable=True)

Enable or disable online mode

get_all_axes()

Get the list of all available axes (taking mapping into account)

get_axis_parameter(pid, axis=None, kind='str')

Get value of the given parameter id for the given axis (all axes by default)

get_device_variable(key)

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

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_help()

Get the help for all commands; might take a long time on low-speed serial connections

get_id()

Get the device ID string

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_online_enabled()

Check if online mode is enabled

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

query(comm, multiline=False, reply=True)

Query a single command to the controller.

If multiline==True, expect a multi-line reply and return a list with separate reply lines; otherwise, expect a single-line reply and raise an error if multi-line reply is received.

If reply==False, expect no reply at all (used for, e.g., set commands).

query_axis(comm, axis=None, subidx=None, kind='str')

Query the given command for the given axis.

axis can be a single axis name (e.g., "A"), a list of axes, or None, which queries all axes. If axis is a single axis, simply return the corresponding value; otherwise, return a dict {axis: value}. kind can specify value kind: "str" (return as is), "float", "int", or "bool".

remap_axes(mapping, accept_original=True)

Rename axes to the new labels.

mapping is the new axes mapping, which can be a list of new axes name (corresponding to the old axes in order returned by get_all_axes()), or a dictionary {alias: original} of the new axes aliases.

set_axis(comm, value, axis=None, subidx=None, reply=False)

Query the given value for the given axis.

value can be a single value (set the same for all specified axes), a list of values (one per axis), or a dict {axis: value}. axis can be a single axis name (e.g., "A"), a list of axes, or None, which queries all axes. If reply==False, expect no reply.

set_axis_parameter(pid, value, axis=None, kind='str')

Get value of the given parameter id for the given axis (all axes by default)

set_device_variable(key, value)

Set the value of a settings parameter

unlock()

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

class pylablib.devices.PhysikInstrumente.base.PIE515(conn, auto_online=True)[source]

Bases: IMultiaxisStage, SCPIDevice

Physik Instrumente E-515 controller.

Parameters:
  • conn – connection parameters (usually port or a tuple containing port and baudrate)

  • auto_online – if True, switch to the online mode upon connection; in this online mode controller parameters are controlled remotely instead of the front panel (including external voltages), while in the offline mode most of the parameters are still controlled manually, and the remote connection is mostly used for readout

Error

alias of PhysikInstrumenteError

ReraiseError

alias of PhysikInstrumenteBackendError

open()[source]

Open the connection

close()[source]

Close the connection

is_online_enabled()[source]

Check if online mode is enabled

enable_online(enable=True, safe=False)[source]

Enable or disable online mode.

If safe==True and enable==True, set the current voltage and position setpoints to be equal to the currently read values; this avoids sudden change of output voltages when enabling the online mode. Note that this only works if all servo modes are off (enabling online mode always forcibly turns them off, which might lead to the output voltage jump).

get_current_axis()[source]

Select the current measurement channel

select_axis(axis)[source]

Select the current default axis

is_servo_enabled(axis=None)[source]

Check if the servo is enabled on the given axis (current axis by default)

enable_servo(enable=True, axis=None)[source]

Enable or disable servo on the given axis (current axis by default)

get_voltage_setpoint(axis=None)[source]

Get the current voltage setpoint on the given axis (current axis by default)

get_voltage(axis=None)[source]

Get the actual voltage value on the given axis (current axis by default)

set_voltage(voltage, axis=None)[source]

Get the target voltage on the given axis (current axis by default)

get_voltage_lower_limit(axis=None)[source]

Get the lower output voltage limit on the given axis (current axis by default)

set_voltage_lower_limit(voltage, axis=None)[source]

Get the lower output voltage limit on the given axis (current axis by default)

get_voltage_upper_limit(axis=None)[source]

Get the upper output voltage limit on the given axis (current axis by default)

set_voltage_upper_limit(voltage, axis=None)[source]

Get the upper output voltage limit on the given axis (current axis by default)

get_position(axis=None)[source]

Get current measured position on the given axis (current axis by default)

get_target_position(axis=None)[source]

Get the target motion position on the given axis

move_to(position, axis=None)[source]

Move the given axis to the given position

move_by(distance, axis=None)[source]

Move the given axis by the given distance

get_position_lower_limit(axis=None)[source]

Get the lower position limit on the given axis (current axis by default)

set_position_lower_limit(position, axis=None)[source]

Get the lower position limit on the given axis (current axis by default)

get_position_upper_limit(axis=None)[source]

Get the upper position limit on the given axis (current axis by default)

set_position_upper_limit(position, axis=None)[source]

Get the upper position limit on the given axis (current axis by default)

BackendError

alias of DeviceBackendError

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.

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.

get_all_axes()

Get the list of all available axes (taking mapping into account)

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

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.

remap_axes(mapping, accept_original=True)

Rename axes to the new labels.

mapping is the new axes mapping, which can be a list of new axes name (corresponding to the old axes in order returned by get_all_axes()), or a dictionary {alias: original} of the new axes aliases.

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.

Module contents