Fork PyRPL on GitHub

pyrpl.software_modules.lockbox package

Submodules

pyrpl.software_modules.lockbox.gainoptimizer module

class pyrpl.software_modules.lockbox.gainoptimizer.GainOptimizer(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.LockboxModule

a module that is used to optimize the lockbox gain by setting the gain_factor of the lockbox to the integral of
an error signal derived from the slope of the error signal rms value vs gain_factor

Setup Attributes:

  • interval:
  • amplitude:
  • unity_gain_frequency:
  • plot:
  • measurement_time: Current gain factor of the gain correction mechanism.
amplitude
interval
measurement_time

Current gain factor of the gain correction mechanism.

plot
setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
interval
amplitude
unity_gain_frequency
plot
measurement_time

Current gain factor of the gain correction mechanism.

start()[source]
start_delayed()[source]
stop()[source]
unity_gain_frequency
class pyrpl.software_modules.lockbox.gainoptimizer.GainOptimizerLoop(*args, **kwargs)[source]

Bases: pyrpl.software_modules.lockbox.LockboxPlotLoop

Setup Attributes:

amplitude

Amplitude of gain modulation for the estimation of the dependency of lock rms

current_gain_factor

Current gain factor of the gain correction mechanism.

loop(a)[source]
max_length = 10
measurement_time

Current gain factor of the gain correction mechanism.

pdh
phase
rms
setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
setup_loop()[source]

put your initialization routine here

teardown_loop()[source]

put your destruction routine here

unity_gain_frequency

Unity gain frequency for the gain integrator.

pyrpl.software_modules.lockbox.input module

class pyrpl.software_modules.lockbox.input.CalibrationData(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.LockboxModule

class to hold the calibration data of an input signal Setup Attributes:

  • min: min of the signal in V over a lockbox sweep
  • max: max of the signal in V over a lockbox sweep
  • mean: mean of the signal in V over a lockbox sweep
  • rms: rms of the signal in V over a lockbox sweep
  • _analog_offset: analog offset of the signal
  • _asg_phase: Phase of the asg when error signal is centered in calibration. Not used by all signals.
amplitude

small helper function for expected signal

get_stats_from_curve(curve)[source]

gets the mean, min, max, rms value of curve (into the corresponding self’s attributes).

max

max of the signal in V over a lockbox sweep

mean

mean of the signal in V over a lockbox sweep

min

min of the signal in V over a lockbox sweep

offset

small helper function for expected signal

peak_to_peak

small helper function for expected signal

rms

rms of the signal in V over a lockbox sweep

setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
min

min of the signal in V over a lockbox sweep

max

max of the signal in V over a lockbox sweep

mean

mean of the signal in V over a lockbox sweep

rms

rms of the signal in V over a lockbox sweep

_analog_offset

analog offset of the signal

_asg_phase

Phase of the asg when error signal is centered in calibration. Not used by all signals.

class pyrpl.software_modules.lockbox.input.InputDirect(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.input.InputSignal

Setup Attributes:

expected_signal(x)[source]
setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
input_signal

the dsp module or lockbox signal used as input signal

calibration_data
class pyrpl.software_modules.lockbox.input.InputFromOutput(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.input.InputDirect

Setup Attributes:

  • input_signal: lockbox signal used as input
calibrate(autosave=False)[source]

no need to calibrate this

expected_signal(setpoint)[source]

it is assumed that the output has the linear relationship between setpoint change in output_unit per volt from the redpitaya, which is configured in the output parameter ‘dc_gain’. We only need to convert units to get the output voltage bringing about a given setpoint difference.

input_signal

lockbox signal used as input

is_locked(loglevel=20)[source]

this is mainly used for coarse locking where significant effective deviations from the setpoint (in units of setpoint_variable) may occur. We therefore issue a warning and return True if is_locked is based on this output.

setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
input_signal

lockbox signal used as input

calibration_data
class pyrpl.software_modules.lockbox.input.InputIq(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.input.InputSignal

Base class for demodulated signals. A derived class must implement
the method expected_signal (see InputPdh in fabryperot.py for example)

Setup Attributes:

  • mod_freq:
  • mod_amp:
  • mod_phase:
  • mod_output:

Options: [‘out1’, ‘out2’] - bandwidth: - quadrature_factor:

acbandwidth
bandwidth
iq
mod_amp
mod_freq
mod_output

Options – [‘out1’, ‘out2’]

mod_phase
quadrature_factor
setup(**kwds)
setup a PDH error signal using the attribute values
input_signal

the dsp module or lockbox signal used as input signal

mod_freq
mod_amp
mod_phase
mod_output

Options: [‘out1’, ‘out2’]

bandwidth: quadrature_factor: calibration_data:
signal()[source]
class pyrpl.software_modules.lockbox.input.InputSignal(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.input.Signal

A Signal that corresponds to an inputsignal of the DSPModule inside the RedPitaya. Moreover, the signal should provide a function to convert the measured voltage into the value of the model’s physical variable in unit. The signal can be calibrated by taking a curve while scanning an output.

  • input_channel: the redpitaya dsp input representing the signal
  • min: min of the signal in V over a lockbox sweep
  • max: max of the signal in V over a lockbox sweep
  • mean: mean of the signal in V over a lockbox sweep
  • rms: rms of the signal in V over a lockbox sweep
  • acquire(): returns an experimental curve in V obtained from a sweep of

the lockbox. - calibrate(): acquires a curve and determines all constants needed by expected_signal - expected_signal(variable): to be reimplemented in concrete derived class: Returns the value of the expected signal in V, depending on the variable value. - expected_slope: returns the slope of the expected signal wrt variable at a given value of the variable. - relative_mean(self): returns the ratio between the measured mean value and the expected one. - relative_rms(self): returns the ratio between the measured rms value and the expected mean. - variable(): Estimates the model variable from the current value of the input.

Setup Attributes:

  • input_signal: the dsp module or lockbox signal used as input signal
calibrate(autosave=False)[source]

This function should be reimplemented to measure whatever property of the curve is needed by expected_signal.

expected_signal(variable)[source]

Returns the value of the expected signal in V, depending on the setpoint value “variable”.

expected_slope(variable)[source]

Returns the slope of the expected signal wrt variable at a given value of the variable. May be overwritten by a more efficient (analytical) method in a derived class.

input_signal

the dsp module or lockbox signal used as input signal

is_locked(loglevel=20)[source]

returns whether the input is locked at the current stage

plot_range = <MagicMock name='mock.linspace()' id='139827377761680'>
setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
input_signal

the dsp module or lockbox signal used as input signal

calibration_data
signal()[source]

returns the signal corresponding to this module that can be used to connect the signal to other modules. By default, this is the direct input signal.

sweep_acquire()[source]

returns an experimental curve in V obtained from a sweep of the lockbox.

class pyrpl.software_modules.lockbox.input.IqFilterProperty(default=None, doc='', ignore_errors=False, call_setup=False)[source]

Bases: pyrpl.attributes.FilterProperty

get_value(instance)[source]
set_value(instance, val)[source]
valid_frequencies(module)[source]
class pyrpl.software_modules.lockbox.input.IqQuadratureFactorProperty(min=<MagicMock name='mock.inf.__neg__()' id='139827380281936'>, max=<MagicMock name='mock.inf' id='139827380218960'>, increment=0, log_increment=False, **kwargs)[source]

Bases: pyrpl.attributes.FloatProperty

this is a direct link to quadrature_factor because we want to benefit from its validate_and_normalize function

get_value(obj)[source]
set_value(instance, value)[source]
class pyrpl.software_modules.lockbox.input.Signal(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.LockboxModule, pyrpl.modules.SignalModule

represention of a physial signal. Can be either an imput or output signal.

Setup Attributes:

  • calibration_data:
calibration_data
diagnostics(duration=1.0)[source]

example code for lock diagnostics:

Parameters:duration (duration over which to average) –
Returns:
Return type:relative rms of the signal, normalized by
get_analog_offset(duration=1.0)[source]

function to acquire the analog offset of the signal (with nothing connected). This offset is subtracted from all raw signals

max
mean
min
relative_mean

returns the ratio between the measured mean value and the expected one.

relative_rms

returns the ratio between the measured rms value and the expected mean.

rms
sampler_time

specifies the duration over which to sample a signal

setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
calibration_data
signal()[source]

derived class should define this method which yields the scope- compatible signal that can be used to monitor this signal

stats(t=None)[source]

returns a tuple containing the mean, rms, max, and min of the signal.

pyrpl.software_modules.lockbox.lockbox module

class pyrpl.software_modules.lockbox.lockbox.AutoLockIntervalProperty(min=<MagicMock name='mock.inf.__neg__()' id='139827380281936'>, max=<MagicMock name='mock.inf' id='139827380218960'>, increment=0, log_increment=False, **kwargs)[source]

Bases: pyrpl.attributes.FloatProperty

timeout for autolock timer

set_value(obj, val)[source]
class pyrpl.software_modules.lockbox.lockbox.AutoLockProperty(default=None, doc='', ignore_errors=False, call_setup=False)[source]

Bases: pyrpl.attributes.BoolProperty

true if autolock is enabled

set_value(obj, val)[source]
class pyrpl.software_modules.lockbox.lockbox.ClassnameProperty(options=[], **kwargs)[source]

Bases: pyrpl.attributes.SelectProperty

Lots of lockbox attributes need to be updated when model is changed

set_value(obj, val)[source]
class pyrpl.software_modules.lockbox.lockbox.Lockbox(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.LockboxModule

A Module that allows to perform feedback on systems that are well described by a physical model.

Setup Attributes:

  • classname:
  • default_sweep_output:

Options: [None] - auto_lock: Turns on the autolock of the module. - is_locked_threshold: Setpoint interval size to consider system in locked state - setpoint_unit: Options: [‘V’] - auto_lock_interval: - lockstatus_interval: - _auto_lock_timeout: maximum time that a locking stage is allowed to take before a lock is considered as stalled. - sequence: - inputs: - _auto_lock_loop: - outputs: - _lockstatus_loop:

asg

the asg being used for sweeps

auto_lock

Turns on the autolock of the module.

auto_lock_interval
calibrate_all(autosave=False)[source]

Calibrates successively all inputs

classname
current_stage
current_state
default_sweep_output

Options – [None]

final_stage

temporary storage of the final lock stage

get_analog_offsets(duration=1.0)[source]

Measures and saves the analog offset for all inputs.

This function is designed to measure the analog offsets of the redpitaya inputs and possibly the sensors connected to these inputs. Only call this function if you are sure about what you are doing and if all signal sources (lasers etc.) are turned off.

The parameter duration specifies the time during which to average the input offsets.

inputs
is_locked(input=None, loglevel=20)[source]

returns True if locked, else False. Also updates an internal dict that contains information about the current error signals. The state of lock is logged at loglevel

is_locked_and_final(loglevel=20)[source]
is_locked_threshold

Setpoint interval size to consider system in locked state

is_locking()[source]
lock(**kwds)[source]

Launches the full lock sequence, stage by stage until the end. optional kwds are stage attributes that are set after iteration through the sequence, e.g. a modified setpoint.

lock_until_locked(**kwargs)[source]
lockstatus_interval
outputs
params

returns a convenient dict with parameters that describe if and with which settings the lockbox was properly.

params from different Pyrpl lockboxes can be merged together without problems if the names of the config files differ

relock(test_auto_lock=False, **kwargs)[source]

locks the cavity if it is_locked is false. Returns the value of is_locked

relock_until_locked(**kwargs)[source]

blocks the command line until cavity is locked with kwargs

sequence
setpoint_unit

Options – [‘V’]

setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
classname
default_sweep_output

Options: [None]

auto_lock: Turns on the autolock of the module. is_locked_threshold: Setpoint interval size to consider system in locked state setpoint_unit:

Options: [‘V’]

auto_lock_interval: lockstatus_interval: _auto_lock_timeout: maximum time that a locking stage is allowed to take before a lock is considered as stalled. sequence: inputs: _auto_lock_loop: outputs: _lockstatus_loop:
signals

a dict of all logical signals of the lockbox

sleep_while_locked(time_to_sleep)[source]
sweep()[source]

Performs a sweep of one of the output. No output default kwds to avoid problems when use as a slot.

unlock(reset_offset=True)[source]

Unlocks all outputs.

class pyrpl.software_modules.lockbox.lockbox.LockstatusIntervalProperty(min=<MagicMock name='mock.inf.__neg__()' id='139827380281936'>, max=<MagicMock name='mock.inf' id='139827380218960'>, increment=0, log_increment=False, **kwargs)[source]

Bases: pyrpl.attributes.FloatProperty

timeout for lockstatus timer

set_value(obj, val)[source]
class pyrpl.software_modules.lockbox.lockbox.SignalLauncherLockbox(module)[source]

Bases: pyrpl.modules.SignalLauncher

A SignalLauncher for the lockbox

add_input = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
delete_widget = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
input_calibrated = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
output_created = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
output_deleted = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
output_renamed = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
remove_input = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
stage_created = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
stage_deleted = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
stage_renamed = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
state_changed = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
update_lockstatus = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
update_transfer_function = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
class pyrpl.software_modules.lockbox.lockbox.StateSelectProperty(options=[], **kwargs)[source]

Bases: pyrpl.attributes.SelectProperty

set_value(obj, val)[source]
pyrpl.software_modules.lockbox.lockbox.all_classnames()[source]

pyrpl.software_modules.lockbox.output module

class pyrpl.software_modules.lockbox.output.AdditionalFilterAttribute(default=None, doc='', ignore_errors=False, call_setup=False)[source]

Bases: pyrpl.attributes.FilterProperty

get_value(obj)[source]
set_value(obj, value)[source]
valid_frequencies(obj)[source]
class pyrpl.software_modules.lockbox.output.OutputSignal(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.input.Signal

As many output signals as desired can be added to the lockbox. Each output defines:

  • name: the name of the output.
  • dc_gain: how much the model’s variable is expected to change for 1 V on the output (in unit)
  • unit: see above, should be one of the units available in the model.
  • sweep_amplitude/offset/frequency/waveform: what properties to use when sweeping the output
  • output_channel: what physical output is used.
  • p/i: the gains to use in a loop: those values are to be understood as full loop gains (p in [1], i in [Hz])
  • additional_filter: a filter (4 cut-off frequencies) to add to the loop (in sweep and lock mode)
  • extra_module: extra module to add just before the output (usually iir).
  • extra_module_state: name of the state to use for the extra_module.
  • tf_curve: the index of the curve describing the analog transfer function behind the output.
  • tf_filter: alternatively, the analog transfer function can be specified by a filter (4 cut-off frequencies).
  • desired_unity_gain_frequency: desired value for unity gain frequency.
  • tf_type: [“flat”, “curve”, “filter”], how is the analog transfer function specified.

Setup Attributes:

  • unit:

Options: [None] - sweep_amplitude: - sweep_offset: - sweep_frequency: - sweep_waveform: Options: [‘sin’, ‘cos’, ‘ramp’, ‘halframp’, ‘square’, ‘dc’, ‘noise’] - dc_gain: - output_channel: Options: [‘out1’, ‘out2’, ‘pwm0’, ‘pwm1’] - p: - i: - additional_filter: - analog_filter_cutoff: - extra_module: Options: [‘None’, ‘iir’, ‘pid’, ‘iq’] - extra_module_state: Options: [‘None’] - desired_unity_gain_frequency: - max_voltage: positive saturation voltage - min_voltage: negative saturation voltage - assisted_design: - tf_curve: - tf_type: Options: [‘flat’, ‘filter’, ‘curve’]

additional_filter
analog_filter_cutoff
assisted_design
current_state

Options – [‘lock’, ‘unlock’, ‘sweep’]

dc_gain
desired_unity_gain_frequency
extra_module

Options – [‘None’, ‘iir’, ‘pid’, ‘iq’]

extra_module_state

Options – [‘None’]

i
is_saturated

returns: * True (if the output has saturated) * False (otherwise)

lock(input=None, setpoint=None, offset=None, gain_factor=None)[source]

Closes the lock loop, using the required p and i parameters.

max_voltage

positive saturation voltage

min_voltage

negative saturation voltage

output_channel

Options – [‘out1’, ‘out2’, ‘pwm0’, ‘pwm1’]

p
pid
setup(**kwds)
unit

Options: [None]

sweep_amplitude: sweep_offset: sweep_frequency: sweep_waveform:

Options: [‘sin’, ‘cos’, ‘ramp’, ‘halframp’, ‘square’, ‘dc’, ‘noise’]

dc_gain: output_channel:

Options: [‘out1’, ‘out2’, ‘pwm0’, ‘pwm1’]

p: i: additional_filter: analog_filter_cutoff: extra_module:

Options: [‘None’, ‘iir’, ‘pid’, ‘iq’]

extra_module_state:

Options: [‘None’]

desired_unity_gain_frequency: max_voltage: positive saturation voltage min_voltage: negative saturation voltage assisted_design: tf_curve: tf_type:

Options: [‘flat’, ‘filter’, ‘curve’]

calibration_data:
signal()[source]
sweep()[source]
sweep_amplitude
sweep_frequency
sweep_offset
sweep_waveform

Options – [‘sin’, ‘cos’, ‘ramp’, ‘halframp’, ‘square’, ‘dc’, ‘noise’]

tf_curve
tf_freqs()[source]

Frequency values to plot the transfer function. Frequency (abcissa) of the tf_curve if tf_type==”curve”, else: logspace(0, 6, 20000)

tf_type

Options – [‘flat’, ‘filter’, ‘curve’]

transfer_function(freqs)[source]

Returns the design transfer function for the output

unit

Options – [None]

unlock(reset_offset=False)[source]
class pyrpl.software_modules.lockbox.output.PiezoOutput(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.output.OutputSignal

Setup Attributes:

  • unit:

Options: [None]

setup(**kwds)
unit

Options: [None]

sweep_amplitude: sweep_offset: sweep_frequency: sweep_waveform:

Options: [‘sin’, ‘cos’, ‘ramp’, ‘halframp’, ‘square’, ‘dc’, ‘noise’]

dc_gain: output_channel:

Options: [‘out1’, ‘out2’, ‘pwm0’, ‘pwm1’]

p: i: additional_filter: analog_filter_cutoff: extra_module:

Options: [‘None’, ‘iir’, ‘pid’, ‘iq’]

extra_module_state:

Options: [‘None’]

desired_unity_gain_frequency: max_voltage: positive saturation voltage min_voltage: negative saturation voltage assisted_design: tf_curve: tf_type:

Options: [‘flat’, ‘filter’, ‘curve’]

calibration_data:
unit

Options – [None]

pyrpl.software_modules.lockbox.stage module

class pyrpl.software_modules.lockbox.stage.Stage(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.LockboxModule

A stage is a single step in the lock acquisition process

Setup Attributes:

  • input:
  • setpoint:
  • duration:
  • gain_factor:
  • function_call:
  • outputs:
duration
enable()[source]

Setup the lockbox parameters according to this stage

function_call
gain_factor
input
outputs
setpoint
setup(**kwds)
input
setpoint
duration
gain_factor
function_call
outputs
class pyrpl.software_modules.lockbox.stage.StageInputSelectProperty(options=<function all_inputs_keys>, **kwargs)[source]

Bases: pyrpl.hardware_modules.dsp.InputSelectProperty

class pyrpl.software_modules.lockbox.stage.StageOutput(parent, name=None)[source]

Bases: pyrpl.software_modules.lockbox.LockboxModule

Setup Attributes:

  • lock_on:
  • reset_offset:
  • offset:
lock_on
offset
reset_offset
setup(**kwds)
lock_on
reset_offset
offset
class pyrpl.software_modules.lockbox.stage.StageSignalLauncher(module)[source]

Bases: pyrpl.modules.SignalLauncher

stage_created = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>
stage_deleted = <MagicMock name='mock.QtCore.Signal()' id='139827380610576'>

Module contents

class pyrpl.software_modules.lockbox.LockboxLoop(parent, name='loop', interval=1.0, autostart=True, loop_function=None, setup_function=None, teardown_function=None, **kwargs)[source]

Bases: pyrpl.software_modules.loop.Loop, pyrpl.software_modules.lockbox.LockboxModule

A Loop with a property ‘lockbox’ referring to the lockbox

Setup Attributes:

setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
class pyrpl.software_modules.lockbox.LockboxModule(parent, name=None)[source]

Bases: pyrpl.modules.Module

Setup Attributes:

lockbox
setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.
class pyrpl.software_modules.lockbox.LockboxModuleDictProperty(module_cls=None, default=None, doc='', ignore_errors=False, **kwargs)[source]

Bases: pyrpl.module_attributes.ModuleDictProperty

default_module_cls

alias of LockboxModule

class pyrpl.software_modules.lockbox.LockboxPlotLoop(*args, **kwargs)[source]

Bases: pyrpl.software_modules.loop.PlotLoop, pyrpl.software_modules.lockbox.LockboxLoop

A PlotLoop with a property ‘lockbox’ referring to the lockbox

Setup Attributes:

setup(**kwds)
Sets the module up for acquisition with the current setup attribute values.