pylablib.devices.PicoTech package
Submodules
pylablib.devices.PicoTech.base module
- exception pylablib.devices.PicoTech.base.PicoTechError[source]
Bases:
DeviceErrorGeneric PicoTechnology device 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.PicoTech.base.PicoTechBackendError(exc)[source]
Bases:
PicoTechError,DeviceBackendErrorGeneric PicoTechnology 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.
pylablib.devices.PicoTech.vna_scpi module
- class pylablib.devices.PicoTech.vna_scpi.PicoVNA(addr='localhost')[source]
Bases:
SCPIDevicePicoVNA vector network analyzer.
- Parameters:
addr – device address; usually an IP address or an address and a port (by default, use local PC and the default port 5025)
- Error
alias of
PicoTechError
- ReraiseError
alias of
PicoTechBackendError
- get_frequency_values()[source]
Get frequency values for the currently acquired trace based on the current frequency range and number of points
- read_single_trace(src='S11', typ='LOGMAG', mem=None, timeout=None)[source]
Read single trace at the given source and a given type. The trace is only read and returned once the sweep is finished.
- Parameters:
src – S parameters source (e.g.,
"S11"or"S21")typ – trace type (e.g.,
"REAL"or"LOGMAG")mem – if not
None, read data from the memory at the given indextimeout – specifies a different timeout; useful for waiting for longer sweeps
- read_S_parameters(param=('S11', 'S12', 'S21', 'S22'), add_frequency=False, mem=None, timeout=None)[source]
Get the S parameters trace for the given channel.
param can be either a single string specifying the parameters (e.g.,
"S12"), or a tuple or list of strings. add_frequency specifies whether the frequency axis should be added to the result. The other parameters are the same as inread_single_trace().If
add_frequency==False, return a single 1D complex array for the single channel, or a multi-column complex array for several channels. Ifadd_frequency==True, return a multi-column array, where the first column is the frequency, and the rest are the parameters.
- 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=-10queries 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=-10queries 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=-10queries 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
DataFormatdescription 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 digitsdenoting length of the size block, thensdigits 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'(interprets0or'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_selectorattribute.wait_sync – if
True, append the sync command (specified as._wait_sync_commattribute,"*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_syncattribute (Falseby 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.