mjolnir.parameters#
Functions
Patches a Parameter to execute side effects of its delegates. |
|
|
Patches a Parameter with a custom root_instrument. |
|
Patches a Parameter with a custom underlying_instrument. |
Classes
|
Modifies the built-in |
|
A DelegateParameter that calls its source for n_avg_callback() times and returns a tuple of (mean, std). |
|
|
|
Groups several QDAC2 current sensors into a single parameter. |
|
Abstraction of a gate pair on two sides of a membrane. |
|
|
|
A parameter that tracks elapsed time and can sleep until the set time has elapsed. |
|
A parameter part of a |
|
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:
DelegateParameterModifies the built-in
DelegateParameterto 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_rawis 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 forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod 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,MultiParameterA DelegateParameter that calls its source for n_avg_callback() times and returns a tuple of (mean, std).
- get_raw()[source]#
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- 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,MultiParameterGroups several QDAC2 current sensors into a single parameter.
- Parameters:
name (str)
params (Sequence[Parameter])
instrument (InstrumentBase | None)
kwargs (Any)
- get_raw()[source]#
get_rawis called to perform the actual data acquisition from the instrument. This method should either be overwritten to perform the desired operation or alternatively forParametera suitable method is automatically generated ifget_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide agetmethod on the parameter instance.
- class mjolnir.parameters.MembraneGateParameterContext(name, group, unit=None, label=None, output_triggers=None, internal_triggers=None, outer_trigger_channel=None, **kwargs)[source]#
Bases:
VirtualParameterContextAbstraction 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:
- 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)
max_val_age (float | None)
vals (Validator[Any] | None)
docstring (str | None)
bind_to_instrument (bool)
kwargs (Any)
- class mjolnir.parameters.TimeParameter(name, label='Elapsed time', **kwargs)[source]#
Bases:
ElapsedTimeParameterA 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.- set_raw(value)[source]#
set_rawis 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 forParametera suitable method is automatically generated ifset_cmdis supplied to the parameter constructor. The method is automatically wrapped to provide asetmethod on the parameter instance.- Parameters:
value (Any)
- Return type:
None
- class mjolnir.parameters.VirtualParameter(name, parameter_context, **kwargs)[source]#
Bases:
ParameterA 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_ContextA GroupedParameter that combines several physical parameters and generates virtual parameters from them.
It also inherits from the QDAC2’s
Arrangement_Contextto provide methods for virtual sweeps etc.- Parameters:
- property channels: ChannelList#
- abstract property contact_names: Sequence[str]#
Returns: Sequence[str]: Contact names in the same order as channel_numbers
- 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_instrumentof the parameter cannot be thehardware_instrument, howeverunderlying_instrumentcan be implemented to return thehardware_instrument.By default it returns the
root_instrumentof the parameter.
- 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.
- mjolnir.parameters.with_root_instrument(cls, root_instrument)[source]#
Patches a Parameter with a custom root_instrument.
- Parameters:
cls (type[_paramT])
root_instrument (InstrumentBase)
- Return type:
type[_paramT]
- mjolnir.parameters.with_underlying_instrument(cls, underlying_instrument)[source]#
Patches a Parameter with a custom underlying_instrument.
- Parameters:
cls (type[_paramT])
underlying_instrument (InstrumentBase)
- Return type:
type[_paramT]