pylablib.devices.Lakeshore package
Submodules
pylablib.devices.Lakeshore.base module
- exception pylablib.devices.Lakeshore.base.LakeshoreError[source]
Bases:
DeviceError
Generic Lakeshore devices 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.Lakeshore.base.LakeshoreBackendError(exc)[source]
Bases:
LakeshoreError
,DeviceBackendError
Generic Lakeshore 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.Lakeshore.base.TLakeshore218AnalogSettings(bipolar, mode, channel, source, high_value, low_value, man_value)
Bases:
tuple
- bipolar
- channel
- high_value
- low_value
- man_value
- mode
- source
- class pylablib.devices.Lakeshore.base.TLakeshore218FilterSettings(enabled, points, window)
Bases:
tuple
- enabled
- points
- window
- class pylablib.devices.Lakeshore.base.TLakeshore218CurveHeader(name, serial, fmt, limit, coeff)
Bases:
tuple
- coeff
- fmt
- limit
- name
- serial
- class pylablib.devices.Lakeshore.base.Lakeshore218(conn)[source]
Bases:
SCPIDevice
Lakeshore 218 temperature controller.
The channels are enumerated from 1 to 8 and are split into 2 groups:
"A"
for 1-4 and"B"
for 5-8.- Parameters:
conn – serial connection parameters (usually port or a tuple containing port and baudrate)
- Error
alias of
LakeshoreError
- ReraiseError
alias of
LakeshoreBackendError
- get_sensor_type(group)[source]
Get sensor type for a given group (
"A"
for sensors 1-4 or"B"
for sensors 5-8).For types, see
INTYPE
command description in the Lakeshore 218 programming manual.
- set_sensor_type(group, sensor_type)[source]
Set sensor type for a given group (
"A"
for sensors 1-4 or"B"
for sensors 5-8).For types, see
INTYPE
command description in the Lakeshore 218 programming manual.
- get_sensor_curve_index(channel)[source]
Get sensor curve index for a given channel (1 to 8).
For curve descriptions, see
INCRV
command description in the Lakeshore 218 programming manual.
- set_sensor_curve_index(channel, index)[source]
Get sensor curve index for a given channel (1 to 8).
For curve descriptions, see
INCRV
command description in the Lakeshore 218 programming manual.
- get_curve_header(index)[source]
Get header of a given curve (1-9 or 21-28).
Return tuple
(name, serial, fmt, limit, coeff)
. For values descriptions, seeCRVHDR
command description in the Lakeshore 218 programming manual.
- set_curve_header(index, name=None, serial=None, fmt=None, limit=None, coeff=None)[source]
Set header of a given user curve (21-28).
For values descriptions, see
CRVHDR
command description in the Lakeshore 218 programming manual.
- get_curve(index, trim_zeros=True)[source]
Get values of a given curve (1-9 or 21-28).
Return 2-column numpy array with up to 200 points, where the first column is sensor reading, and the second is temperature; for associated sensor units, see
get_curve_header()
. Iftrim_zeros==True
, trim the trailing zero-valued points. Note, that it takes about 10 seconds to complete.
- set_curve(index, curve)[source]
Set values of a given user curve (21-28).
curve is a 2-column numpy array with up to 200 points, where the first column is sensor reading, and the second is temperature; for associated sensor units, see
get_curve_header()
. Note, that it takes about 20 seconds to complete.
- get_analog_output_settings(output)[source]
Get analog output settings for a given output (1 or 2).
For parameters, see
setup_analog_output()
andANALOG
command description in the Lakeshore 218 programming manual.
- setup_analog_output(output, bipolar=None, mode=None, channel=None, source=None, high_value=None, low_value=None, man_value=None)[source]
Setup analog output settings for a given output (1 or 2).
For parameters, see
ANALOG
command description in the Lakeshore 218 programming manual. Value ofNone
means keeping the current parameter value.
- set_analog_output_value(output, value, bipolar=False, enabled=True)[source]
Set manual analog output value.
A simplified version of
setup_analog_output()
.
- get_analog_output(output)[source]
Get value (in percents of the total range) at a given output (1 or 2)
- get_filter_settings(channel)[source]
Get input filter settings for a given channel (1 to 8).
For parameters, see
setup_filter()
andFILTER
command description in the Lakeshore 218 programming manual.
- setup_filter(channel, enabled=None, points=None, window=None)[source]
Setup input filter settings for a given channel (1 to 8).
For parameters, see
FILTER
command description in the Lakeshore 218 programming manual. Value ofNone
means keeping the current parameter value.
- 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()
. Ifread_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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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 digits
denoting length of the size block, thens
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'
(interprets0
or'off'
asFalse
, anything else asTrue
),'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). Ifinclude_header==True
, return the data with the header; otherwise, return only the content. Ifflush_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. Ifignore_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 theread()
/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'
(performwait_sync()
),'dev'
(performwait_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}'
witharg=[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; ifNone
, 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.Lakeshore.base.TLakeshore370RangeSettings(exc_mode, exc_range, res_range, autorange, enable)
Bases:
tuple
- autorange
- enable
- exc_mode
- exc_range
- res_range
- class pylablib.devices.Lakeshore.base.TLakeshore370AnalogSettings(bipolar, mode, channel, source, high_value, low_value, man_value)
Bases:
tuple
- bipolar
- channel
- high_value
- low_value
- man_value
- mode
- source
- class pylablib.devices.Lakeshore.base.TLakeshore370FilterSettings(enabled, settle_time, window)
Bases:
tuple
- enabled
- settle_time
- window
- class pylablib.devices.Lakeshore.base.Lakeshore370(conn)[source]
Bases:
SCPIDevice
Lakeshore 370 resistance bridge / temperature controller.
All channels are enumerated from 0.
- Parameters:
conn – serial connection parameters (usually port or a tuple containing port and baudrate)
- Error
alias of
LakeshoreError
- ReraiseError
alias of
LakeshoreBackendError
- get_channel_range_settings(channel)[source]
Setup the current measurement channel range parameters.
For parameters, see
setup_channel_range()
andRDGRNG
command description in the Lakeshore 370 programming manual.
- setup_channel_range(channel=None, exc_mode='v', exc_range=1, res_range=22, autorange=True, enable=True)[source]
Setup the measurement channel range (all channels by default).
exc_mode is the excitation mode (
"i"
or"v"
), exc_range is the excitation range (1 is smallest), res_range is the resistance range (1 is smallest). For range descriptions, see Lakeshore 370 programming manual.
- get_analog_output_settings(output)[source]
Get analog output settings for a given output (1 or 2).
For parameters, see
setup_analog_output()
andANALOG
command description in the Lakeshore 370 programming manual.
- setup_analog_output(output, bipolar=None, mode=None, channel=None, source=None, high_value=None, low_value=None, man_value=None)[source]
Setup analog output settings for a given output (1 or 2).
For parameters, see
ANALOG
command description in the Lakeshore 370 programming manual. Value ofNone
means keeping the current parameter value.
- set_analog_output_value(output, value, bipolar=False, enabled=True)[source]
Set manual analog output value.
A simplified version of
setup_analog_output()
.
- get_analog_output(output)[source]
Get value (in percents of the total range) at a given output (1 or 2)
- get_filter_settings(channel)[source]
Get input filter settings for a given channel (1 to 16).
For parameters, see
setup_filter()
andFILTER
command description in the Lakeshore 370 programming manual.
- setup_filter(channel, enabled=None, settle_time=None, window=None)[source]
Setup input filter settings for a given channel (1 to 16).
For parameters, see
FILTER
command description in the Lakeshore 370 programming manual. Value ofNone
means keeping the current parameter value.
- 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()
. Ifread_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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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, settinginclude=-10
queries all available variables, which is equivalent toinclude="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 digits
denoting length of the size block, thens
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'
(interprets0
or'off'
asFalse
, anything else asTrue
),'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). Ifinclude_header==True
, return the data with the header; otherwise, return only the content. Ifflush_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. Ifignore_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 theread()
/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'
(performwait_sync()
),'dev'
(performwait_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}'
witharg=[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; ifNone
, 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
.