pylablib.devices.Sirah package¶
Submodules¶
pylablib.devices.Sirah.Matisse module¶
-
exception
pylablib.devices.Sirah.Matisse.
GenericSirahError
[source]¶ Bases:
pylablib.core.devio.base.DeviceError
Generic Sirah error
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
exception
pylablib.devices.Sirah.Matisse.
GenericSirahBackendError
(exc)[source]¶ Bases:
pylablib.devices.Sirah.Matisse.GenericSirahError
,pylablib.core.devio.comm_backend.DeviceBackendError
Sirah backend communication error
-
args
¶
-
with_traceback
()¶ Exception.with_traceback(tb) – set self.__traceback__ to tb and return self.
-
-
class
pylablib.devices.Sirah.Matisse.
TThinetCtlParameters
(setpoint, P, I, avg)¶ Bases:
tuple
-
I
¶
-
P
¶
-
avg
¶
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
setpoint
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TPiezoetDriveParameters
(amplitude, rate, oversamp)¶ Bases:
tuple
-
amplitude
¶
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
oversamp
¶
-
rate
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TPiezoetFeedbackParameters
(P, avg, phase)¶ Bases:
tuple
-
P
¶
-
avg
¶
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
phase
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TPiezoetFeedforwardParameters
(ampl, phase)¶ Bases:
tuple
-
ampl
¶
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
phase
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TSlowpiezoCtlParameters
(setpoint, P, I, freeP)¶ Bases:
tuple
-
I
¶
-
P
¶
-
count
()¶ Return number of occurrences of value.
-
freeP
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
setpoint
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TFastpiezoCtlParameters
(setpoint, I, lockpoint)¶ Bases:
tuple
-
I
¶
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
lockpoint
¶
-
setpoint
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TRefcellWaveformParameters
(lower_limit, upper_limit, oversamp, mode)¶ Bases:
tuple
-
count
()¶ Return number of occurrences of value.
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
lower_limit
¶
-
mode
¶
-
oversamp
¶
-
upper_limit
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TScanMode
(falling, stop_lower, stop_upper)¶ Bases:
tuple
-
count
()¶ Return number of occurrences of value.
-
falling
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
stop_lower
¶
-
stop_upper
¶
-
-
class
pylablib.devices.Sirah.Matisse.
TScanParameters
(device, mode, lower_limit, upper_limit, rise_speed, fall_speed)¶ Bases:
tuple
-
count
()¶ Return number of occurrences of value.
-
device
¶
-
fall_speed
¶
-
index
()¶ Return first index of value.
Raises ValueError if the value is not present.
-
lower_limit
¶
-
mode
¶
-
rise_speed
¶
-
upper_limit
¶
-
-
class
pylablib.devices.Sirah.Matisse.
SirahMatisse
(addr)[source]¶ Bases:
pylablib.core.devio.SCPI.SCPIDevice
Sirah Matisse laser control.
Parameters: addr – device address (usually a VISA name). -
Error
¶ alias of
GenericSirahError
-
ReraiseError
¶ alias of
GenericSirahBackendError
-
bifi_get_status
()[source]¶ Get the parsed status of the birefringent filter motor.
Return tuple
(code, bits)
with, correspondingly, the general status/error code (e.g.,"idle"
,"moving_abs"
, or"position_out_of_range"
), and a set of active status bits (e.g.,"moving"
,"error"
, or"limit_sw1"
).
-
bifi_move_to
(position, wait=True, wait_timeout=30.0)[source]¶ Move the birefringent filter to the current position
-
thinet_get_status
()[source]¶ Get the parsed status of the thin etalon motor.
Return tuple
(code, bits)
with, correspondingly, the general status/error code (e.g.,"idle"
,"moving_abs"
, or"position_out_of_range"
), and a set of active status bits (e.g.,"moving"
,"error"
, or"limit_sw1"
).
-
thinet_move_to
(position, wait=True, wait_timeout=30.0)[source]¶ Move the thin etalon to the current position
-
get_thinet_error_signal
()[source]¶ Get error signal of the thin etalon lock (emulated when not available on older firmware)
-
get_thinet_ctl_params
()[source]¶ Get thin etalon lock control parameters.
Return tuple
(setpoint, P, I, avg)
.
-
set_thinet_ctl_params
(setpoint=None, P=None, I=None, avg=None)[source]¶ Set thin etalon lock control parameters.
Any parameters which are
None
remain unchanged.
-
get_piezoet_drive_params
()[source]¶ Get piezo etalon drive parameters.
Return tuple
(amplitude, rate, oversamp)
.
-
set_piezoet_drive_params
(amplitude=None, rate=None, oversamp=None)[source]¶ Set piezo etalon drive parameters.
oversamp should be between 8 and 32. rate can take values
"8k"
,"32k"
,"48k"
, or"96k"
. Any parameters which areNone
remain unchanged.
-
get_piezoet_feedback_params
()[source]¶ Get piezo etalon feedback parameters.
Return tuple
(P, avg, phase)
(phase is integer between 0 and oversampling).
-
set_piezoet_feedback_params
(P=None, avg=None, phase=None)[source]¶ Set piezo etalon feedback parameters.
Phase is integer between 0 and oversampling. Any parameters which are
None
remain unchanged.
-
get_piezoet_feedforward_params
()[source]¶ Get piezo etalon feedforward parameters.
Return tuple
(amp, phase)
(phase is integer between 0 and oversampling).
-
set_piezoet_feedforward_params
(amp=None, phase=None)[source]¶ Set piezo etalon feedforward parameters.
Phase is integer between 0 and oversampling. Any parameters which are
None
remain unchanged.
-
get_slowpiezo_ctl_params
()[source]¶ Get slow piezo lock control parameters.
Return tuple
(setpoint, P, I, freeP)
.
-
set_slowpiezo_ctl_params
(setpoint=None, P=None, I=None, freeP=None)[source]¶ Set slow piezo lock control parameters.
Any parameters which are
None
remain unchanged.
-
get_fastpiezo_ctl_params
()[source]¶ Get fast piezo lock control parameters.
Return tuple
(setpoint, I, lockpoint)
.
-
set_fastpiezo_ctl_params
(setpoint=None, I=None, lockpoint=None)[source]¶ Set fast piezo lock control parameters.
Any parameters which are
None
remain unchanged.
-
get_refcell_waveform_params
()[source]¶ Get reference cell waveform parameters.
Return tuple
(lower_limit, upper_limit, oversamp, mode)
.mode
can be"none"
,"avg"
,"min"
, or"max"
.
-
set_refcell_waveform_params
(lower_limit=None, upper_limit=None, oversamp=None, mode=None)[source]¶ Set reference cell waveform parameters.
Any parameters which are
None
remain unchanged. mode can be"none"
,"avg"
,"min"
, or"max"
. oversamp should be between 4 and 512.
-
get_scan_params
()[source]¶ Get scan parameters.
Return tuple
(device, mode, lower_limit, upper_limit, rise_speed, fall_speed)
.device
can be"none"
,"slow_piezo"
, or"ref_cell"
.mode
is a tuple(falling, stop_lower, stop_upper)
.
-
set_scan_params
(device=None, mode=None, lower_limit=None, upper_limit=None, rise_speed=None, fall_speed=None)[source]¶ Set slow piezo lock control parameters.
device can be
"none"
,"slow_piezo"
, or"ref_cell"
. mode is a tuple(falling, stop_lower, stop_upper)
. Any parameters which areNone
remain unchanged.
-
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()
. 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
.
-
pylablib.devices.Sirah.tuner module¶
-
class
pylablib.devices.Sirah.tuner.
MatisseTuner
(laser, wavemeter)[source]¶ Bases:
object
Matisse tuner.
Helps to coordinate with an external wavemeter to perform more complicated tasks: motors calibration, fine frequency tuning, and stitching scans.
Parameters: - laser – opened Matisse laser object
- wavemeter – opened wavemeter object (currently only HighFinesse wavemeters are supported)
-
get_frequency
(timeout=1.0)[source]¶ Get current frequency reading.
The only method relying on the wavemeter. Can be extended or overloaded to support different wavemeters.
-
scan_steps
(motor, start, stop, step)[source]¶ Scan the given motor (
"bifi"
or"thinet"
) in discrete steps within the given range with a given step.Return a 4-column numpy array containing motor position, internal diode power, thin etalon reflection power, and wavemeter frequency.
-
scan_centered
(motor, span, step)[source]¶ Scan the given motor (
"bifi"
or"thinet"
) in discrete steps in a given span around the current position.After the scan, return the motor to the original position.
Return a 4-column numpy array containing motor position, internal diode power, thin etalon reflection power, and wavemeter frequency.
-
scan_quick
(motor, start, stop, autodir=True)[source]¶ Do a quick continuous scan of the given motor (
"bifi"
or"thinet"
) within the given range.Compared to
scan_steps()
, which does a series of discrete defined moves, this method does a single continuous move and records values in its progress. This is quicker, but does not allow for the step size control, and results in non-uniform recorded positions. Ifautodir==False
, first initialize the motor to start and then move to stop; otherwise, initialize to whichever border is closer.Return a 4-column numpy array containing motor position, internal diode power, thin etalon reflection power, and wavemeter frequency.
-
scan_quick_centered
(motor, span)[source]¶ Do a quick continuous scan of the given motor (
"bifi"
or"thinet"
) in a given span around the current position.After the scan, return the motor to the original position.
Return a 4-column numpy array containing motor position, internal diode power, thin etalon reflection power, and wavemeter frequency.
-
scan_both_motors
(bifi_rng, te_rng, verbose=False)[source]¶ Perform a 2D grid scan changing positions of both birefringent filter and thin etalon motors.
bifi_rng and te_rng are both 3-tuples
(start, stop, step)
specifying the scan ranges. Ifverbose==True
, print a message per every birefringent filter position indicating the scan progress.Return a 5-column numpy array containing birefringent filter motor position, thin etalon motor position, internal diode power, thin etalon reflection power, and wavemeter frequency.
-
scan_both_motors_quick
(bifi_rng, te_rng, verbose=False)[source]¶ Perform a quick 2D grid scan changing positions of both birefringent filter and thin etalon motors.
For each discrete position of a birefringent filter motor perform a quick scan of the thin etalon motor. bifi_rng is a 3-tuple
(start, stop, step)
, whilete_rng
is a 2-tuple(start, stop)
specifying the scan ranges. Ifverbose==True
, print a message per every birefringent filter position indicating the scan progress.Return a 5-column numpy array containing birefringent filter motor position, thin etalon motor position, internal diode power, thin etalon reflection power, and wavemeter frequency.
-
slow_piezo_tune_to
(target)[source]¶ Fine tune the laser to the given target frequency using only slow piezo tuning
-
tune_to
(target)[source]¶ Tune the laser to the given frequency using all elements (bifi, thin etalon, piezo etalon, slow piezo)
-
stitched_scan
(full_rng, single_span, speed, overlap=0.1, freq_step=None)[source]¶ Perform a stitched laser scan.
Parameters: - full_rng – 2-tuple
(start, stop)
with the full frequency scan range. - single_span – magnitude of a single continuous scan segment given in the slow piezo scan units (between 0 and 1)
- speed – single segment scan speed
- overlap – overlap of consecutive segments, as a fraction of single_span
- freq_step – if
None
, the start of the next segment is calculated based on the end of the previous segment and overlap; otherwise, it specifies a fixed frequency step between segments.
- full_rng – 2-tuple