mjolnir.parameters#

Functions

with_delegates_with_side_effect(cls)

Patches a Parameter to execute side effects of its delegates.

with_root_instrument(cls, root_instrument)

Patches a Parameter with a custom root_instrument.

with_underlying_instrument(cls, ...)

Patches a Parameter with a custom underlying_instrument.

Classes

DelegateParameterWithSetSideEffect(name, ...)

Modifies the built-in DelegateParameter to allow for side effects on set events.

DelegateParameterWithUncertainty(name, ...)

A DelegateParameter that calls its source for n_avg_callback() times and returns a tuple of (mean, std).

DelegatePowerParameter(name, source, *args, ...)

LeakageCurrentsParameter(name, params[, ...])

Groups several QDAC2 current sensors into a single parameter.

MembraneGateParameterContext(name, group[, ...])

Abstraction of a gate pair on two sides of a membrane.

PowerParameter(name[, instrument, label, ...])

TimeParameter(name[, label])

A parameter that tracks elapsed time and can sleep until the set time has elapsed.

VirtualParameter(name, parameter_context, ...)

A parameter part of a VirtualParameterContext.

VirtualParameterContext(name, group[, unit, ...])

A GroupedParameter that combines several physical parameters and generates virtual parameters from them.

class mjolnir.parameters.DelegateParameterWithSetSideEffect(name, source, *args, set_side_effect=<function DelegateParameterWithSetSideEffect.<lambda>>, execute_before=False, run_side_effect_on_instantiation=False, **kwargs)[source]#

Bases: DelegateParameter

Modifies the built-in DelegateParameter to allow for side effects on set events.

If source was patched using with_delegates_with_side_effect(), instances of this class are registered as delegates thereof, meaning the set side effects are also executed if the source was set.

Parameters:
  • set_side_effect (Callable[[Self, ParamRawDataType, ParamRawDataType], Any]) – A callable that is run after every set event. Receives the parameter instance, the previous, and the set value as arguments.

  • execute_before (bool) – Run the side effect before setting the parameter or after.

  • name (str)

  • source (Parameter | None)

  • args (Any)

  • run_side_effect_on_instantiation (bool)

  • kwargs (Any)

register_with_source()[source]#

Register with source parameter.

Used with with_delegates_with_side_effect().

set_raw(value)[source]#

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

Parameters:

value (Any)

Return type:

None

class mjolnir.parameters.DelegateParameterWithUncertainty(name, source, n_avg_callback, get_context=None, **kwargs)[source]#

Bases: DelegateParameter, MultiParameter

A DelegateParameter that calls its source for n_avg_callback() times and returns a tuple of (mean, std).

Parameters:
  • name (str)

  • source (Parameter)

  • n_avg_callback (Callable[[], int])

  • kwargs (Any)

get_raw()[source]#

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

Return type:

tuple[float, float]

property n_avg: int#
class mjolnir.parameters.DelegatePowerParameter(name, source, *args, **kwargs)[source]#

Bases: _PowerMixin, DelegateParameter

Parameters:
  • name (str)

  • source (Parameter | None)

  • args (Any)

  • kwargs (Any)

class mjolnir.parameters.LeakageCurrentsParameter(name, params, instrument=None, **kwargs)[source]#

Bases: _QdacErrorMixin, MultiParameter

Groups several QDAC2 current sensors into a single parameter.

Parameters:
  • name (str)

  • params (Sequence[Parameter])

  • instrument (InstrumentBase | None)

  • kwargs (Any)

property counts: tuple[int, ...]#
get_raw()[source]#

get_raw is called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if get_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a get method on the parameter instance.

Return type:

tuple[Any, …]

property setpoints: tuple[Sequence, ...]#
property shapes: tuple[tuple[int], ...]#
class mjolnir.parameters.MembraneGateParameterContext(name, group, unit=None, label=None, output_triggers=None, internal_triggers=None, outer_trigger_channel=None, **kwargs)[source]#

Bases: VirtualParameterContext

Abstraction of a gate pair on two sides of a membrane.

Todo

Could remove one layer of nesting and have all four gates of a trap make up one logical group. Would allow for virtual gates in the canonical sense. In that case, one could probably do away with the GroupedParameterChannel hacking.

Todo

Document

Todo

triggers

Parameters:
  • name (str)

  • group (DelegateGroup)

  • unit (str | None)

  • label (str | None)

  • output_triggers (dict[str, int] | None)

  • internal_triggers (Sequence[str] | None)

  • outer_trigger_channel (int | None)

  • kwargs (Any)

bottom: DelegateGroupParameter#
property contact_names: Sequence[str]#

Returns: Sequence[str]: Contact names in the same order as channel_numbers

top: DelegateGroupParameter#
class mjolnir.parameters.PowerParameter(name, instrument=None, label=None, unit=None, get_cmd=None, set_cmd=False, initial_value=None, max_val_age=None, vals=None, docstring=None, initial_cache_value=None, bind_to_instrument=True, **kwargs)[source]#

Bases: _PowerMixin, Parameter

Parameters:
  • name (str)

  • instrument (InstrumentBase | None)

  • label (str | None)

  • unit (str | None)

  • get_cmd (str | Callable[..., Any] | Literal[False] | None)

  • set_cmd (str | Callable[..., Any] | Literal[False] | None)

  • initial_value (float | str | None)

  • max_val_age (float | None)

  • vals (Validator[Any] | None)

  • docstring (str | None)

  • initial_cache_value (float | str | None)

  • bind_to_instrument (bool)

  • kwargs (Any)

class mjolnir.parameters.TimeParameter(name, label='Elapsed time', **kwargs)[source]#

Bases: ElapsedTimeParameter

A parameter that tracks elapsed time and can sleep until the set time has elapsed.

Setting to, e.g., 10 will sleep until the time since instantiation or the last call to reset_clock() is 10 seconds.

Parameters:
  • name (str)

  • label (str)

  • kwargs (Any)

set_raw(value)[source]#

set_raw is called to perform the actual setting of a parameter on the instrument. This method should either be overwritten to perform the desired operation or alternatively for Parameter a suitable method is automatically generated if set_cmd is supplied to the parameter constructor. The method is automatically wrapped to provide a set method on the parameter instance.

Parameters:

value (Any)

Return type:

None

class mjolnir.parameters.VirtualParameter(name, parameter_context, **kwargs)[source]#

Bases: Parameter

A parameter part of a VirtualParameterContext.

Parameters:
  • name (str)

  • parameter_context (_VirtualParameterContextT)

  • kwargs (Any)

property parameter_context: _VirtualParameterContextT#
class mjolnir.parameters.VirtualParameterContext(name, group, unit=None, label=None, output_triggers=None, internal_triggers=None, outer_trigger_channel=None, **kwargs)[source]#

Bases: _QdacErrorMixin, GroupedParameter, Arrangement_Context

A GroupedParameter that combines several physical parameters and generates virtual parameters from them.

It also inherits from the QDAC2’s Arrangement_Context to provide methods for virtual sweeps etc.

Parameters:
  • name (str)

  • group (DelegateGroup)

  • unit (str | None)

  • label (str | None)

  • output_triggers (dict[str, int] | None)

  • internal_triggers (Sequence[str] | None)

  • outer_trigger_channel (int | None)

  • kwargs (Any)

property channels: ChannelList#
abstract property contact_names: Sequence[str]#

Returns: Sequence[str]: Contact names in the same order as channel_numbers

property current_parameters: tuple[Parameter, ...]#
property root_instrument: InstrumentBase#

Return the fundamental instrument that this parameter belongs too. E.g if the parameter is bound to a channel this will return the fundamental instrument that that channel belongs to. Use instrument() to get the channel.

property underlying_instrument: InstrumentBase#

Returns an instance of the underlying hardware instrument that this parameter communicates with, per this parameter’s implementation.

This is useful in the case where a parameter does not belongs to an instrument instance that represents a real hardware instrument but actually uses a real hardware instrument in its implementation (e.g. via calls to one or more parameters of that real hardware instrument). This is also useful when a parameter does belong to an instrument instance but that instance does not represent the real hardware instrument that the parameter interacts with: hence root_instrument of the parameter cannot be the hardware_instrument, however underlying_instrument can be implemented to return the hardware_instrument.

By default it returns the root_instrument of the parameter.

virtual_voltage(contact)[source]#

Virtual voltage applied to contact.

Parameters:

contact (str)

Return type:

float

mjolnir.parameters.with_delegates_with_side_effect(cls)[source]#

Patches a Parameter to execute side effects of its delegates.

Only works with Parameters whose set_raw method may be overridden.

Todo

Unused as of now.

Parameters:

cls (type[Parameter])

Return type:

type[Parameter]

mjolnir.parameters.with_root_instrument(cls, root_instrument)[source]#

Patches a Parameter with a custom root_instrument.

Parameters:
Return type:

type[_paramT]

mjolnir.parameters.with_underlying_instrument(cls, underlying_instrument)[source]#

Patches a Parameter with a custom underlying_instrument.

Parameters:
Return type:

type[_paramT]