pylablib.devices.Sirah package
Submodules
pylablib.devices.Sirah.Matisse module
- class pylablib.devices.Sirah.Matisse.TThinetCtlParameters(setpoint, P, I, avg)
Bases:
tuple
- I
- P
- avg
- setpoint
- class pylablib.devices.Sirah.Matisse.TPiezoetDriveParameters(amplitude, rate, oversamp)
Bases:
tuple
- amplitude
- oversamp
- rate
- class pylablib.devices.Sirah.Matisse.TPiezoetFeedbackParameters(P, avg, phase)
Bases:
tuple
- P
- avg
- phase
- class pylablib.devices.Sirah.Matisse.TPiezoetFeedforwardParameters(ampl, phase)
Bases:
tuple
- ampl
- phase
- class pylablib.devices.Sirah.Matisse.TSlowpiezoCtlParameters(setpoint, P, I, freeP)
Bases:
tuple
- I
- P
- freeP
- setpoint
- class pylablib.devices.Sirah.Matisse.TFastpiezoCtlParameters(setpoint, I, lockpoint)
Bases:
tuple
- I
- lockpoint
- setpoint
- class pylablib.devices.Sirah.Matisse.TRefcellWaveformParameters(lower_limit, upper_limit, oversamp, mode)
Bases:
tuple
- lower_limit
- mode
- oversamp
- upper_limit
- class pylablib.devices.Sirah.Matisse.TScanMode(falling, stop_lower, stop_upper)
Bases:
tuple
- falling
- stop_lower
- stop_upper
- class pylablib.devices.Sirah.Matisse.TScanParameters(device, mode, lower_limit, upper_limit, rise_speed, fall_speed)
Bases:
tuple
- device
- fall_speed
- lower_limit
- mode
- rise_speed
- upper_limit
- class pylablib.devices.Sirah.Matisse.SirahMatisse(addr)[source]
Bases:
SCPIDevice
Sirah Matisse laser control.
- Parameters:
addr – device address (usually a VISA name).
- Error
alias of
GenericSirahError
- ReraiseError
alias of
GenericSirahBackendError
- ask(*args, **kwargs)[source]
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.
- 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
DeviceBackendError
- apply_settings(settings)
Apply the settings.
settings is a dict
{name: value}
of the available device settings. Non-applicable settings are ignored.
- 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.base module
- exception pylablib.devices.Sirah.base.GenericSirahError[source]
Bases:
DeviceError
Generic Sirah 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.Sirah.base.GenericSirahBackendError(exc)[source]
Bases:
GenericSirahError
,DeviceBackendError
Sirah 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.Sirah.tuner module
- exception pylablib.devices.Sirah.tuner.FrequencyReadSirahError(timeout=None)[source]
Bases:
GenericSirahError
Sirah error indicating an error while trying to read frequency value
- 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.Sirah.tuner.MatisseTuner(laser, wavemeter, calibration=None, ref_cell=True)[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)
calibration – either a calibration dictionary, or a path to the calibration dictionary file
- set_tune_units(units='int')[source]
Set default units for fine tuning and sweeping (fine sweep or stitched scan).
Can be either
"int"
(internal units between 0 and 1) or"freq"
(frequency units; requires calibration).
- apply_calibration(calibration)[source]
Apply the given calibration.
calibration is either a calibration dictionary, or a path to the calibration dictionary file. Contains information about the relation between bifi motor and wavelength, thin etalon motor span, slow piezo tuning rate (frequency to internal units) and its maximal sweep rate, ref cell tuning rate (frequency to internal units) and its maximal sweep rate.
- 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.
- get_last_read_frequency(max_delay=1.0)[source]
Get the last valid read frequency, or
None
if none has been acquired yet
- set_frequency_average_time(avg_time=0)[source]
Set averaging time for frequency measurements (reduces measured frequency jitter)
- 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.
- calibrate(motors=True, slow_piezo=True, slow_piezo_speeds=None, ref_cell=True, ref_cell_speeds=None, verbose=True, bifi_range=None, thinet_range=None, return_scans=True)[source]
Calibrate the laser and return the calibration results.
If
motors==True
, perform motors calibration (bifi range and wavelengths, thin etalon range). Ifslow_piezo==True
, perform slow piezo calibration (ratio between internal tuning units and frequency shift). Ifslow_piezo_speeds
is notNone
, it defines a list of slow piezo tuning speeds to use for the calibration (in case it depends on the speed). Ifref_cell==True
, perform ref cell calibration (ratio between internal tuning units and frequency shift). Ifref_cell_speeds
is notNone
, it defines a list of ref cell tuning speeds to use for the calibration (in case it depends on the speed). If bifi_range is specified, it is a tuple(start, stop, step)
defining the tested bifi positions (default is between 100000 and 400000 with a step of 400). If thinet_range is specified, it is a tuple(start, stop)
defining the tested thin etalon position range. IFverbose==True
, print the progress updates during scan. Ifreturn_scans==True
, return a tuple(calibration, scans)
, wherescans
is a tuple(motor_scan, slow_piezo_scan, ref_cell)
containing detail scan result tables; otherwise, return just the calibration dictionary.
- set_fine_lock(device='slow_piezo')[source]
Set fine lock (slow and fast piezo) parameters for the given device (
"low_piezo"
or"ref_cell"
)
- fine_tune_to_gen(target, device='slow_piezo', method='auto', tolerance=None)[source]
Same as
fine_tune_to()
, but made as a generator which yields occasionally.Can be used to run this scan in parallel with some other task, or to be able to interrupt it in the middle.
- fine_tune_to(target, device='slow_piezo', method='auto', tolerance=None)[source]
Fine tune the laser to the given target frequency using only fine tuning.
device specifies the device used for fine tuning: either
"slow_piezo"
, or"ref_cell"
. method can be"step"
for step-based binary search method, or"cal"
for slope-based method using the fine tuning calibration (frequency detuning per element position shift). (generally faster, but requires a known calibration). Ifmethod=="auto"
, use"cal"
when the calibration is available and"step"
otherwise. tolerance gives the final frequency tolerance for the"cal"
tuning method; ifNone
, use the standard value (50MHz by default).
- tune_to_gen(target, level='full', fine_device='slow_piezo', tolerance=None, local_level='none')[source]
Same as
tune_to()
, but made as a generator which yields occasionally.Can be used to run this scan in parallel with some other task, or to be able to interrupt it in the middle.
- tune_to(target, level='full', fine_device='slow_piezo', tolerance=None, local_level='none')[source]
Tune the laser to the given frequency (in Hz) using multiple elements (bifi, thin etalon, piezo etalon, slow piezo / ref cell).
level can be
"bifi"
(only tune the bifi motor),"thinet"
(tune bifi motor and thin etalon), or"full"
(full tuning using all elements). fine_device specifies the device used for fine tuning: either"slow_piezo"
, or"ref_cell"
. tolerance gives the final fine tuning frequency tolerance; ifNone
, use the standard value (50MHz by default). local_level defines the level on which to start adjustment; can be"fine"
(start with the slow piezo or the ref cell, if the laser is within their tuning range),"thinet"
(start with the thin etalon), or"none"
(start with the bifi; default). If using just the finer control does not work, progressively move to the coarser ones.
- fine_sweep_start(span, up_speed, down_speed=None, device='slow_piezo', kind='cont_up', current_pos=0.5)[source]
Start a fine sweep using the slow piezo or the ref cell.
span is a sweep span, up_speed and down_speed are the corresponding speeds (if down_speed is
None
, use the same as up_speed), device is the scan device ("slow_piezo"
or"ref_cell"
), kind is the sweep kind ("cont_up"
,"cont_down"
,"single_up"
, or"single_down"
), and current_pos is the relative position of the current position withing the sweep range (0 means that it’s the lowest position of the sweep, 1 means it’s the highest, 0.5 means that it’s in the center).
- fine_sweep_stop(return_to_start=True, start_point=None)[source]
Stop currently running fast sweep.
If
return_to_start==True
, return to the original start tuning position after the sweeps is stopped; otherwise, stay at the current position.
- scan_coarse_gen(bifi_rng, te_rng)[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.Yields a tuple
((bifi_idx, bifi_npos), (te_idx, te_npos))
, wherebifi_idx
andte_idx
are the indices of the current birefringent filter and thin etalon motor positions, andbifi_npos
andte_npos
are the corresponding total numbers of positions.
- stitched_scan_gen(full_rng, single_span, speed, device='slow_piezo', overlap=0.1, freq_step=None)[source]
Same as
stitched_scan()
, but made as a generator which yields occasionally.Can be used to run this scan in parallel with some other task, or to be able to interrupt it in the middle. Yields
True
whenever the main scanning region is passing, andFalse
during the stitching intervals.
- stitched_scan(full_rng, single_span, speed, device='slow_piezo', 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
device – the scan device (
"slow_piezo"
or"ref_cell"
)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.