mjolnir.helpers#

This module defines some helper functions.

Functions

calculate_ramp_time_with_filter(slew_rate, ...)

Calculate the time for a linear ramp with an analogue RC filter to settle at thresh.

calculate_rise_time(RC[, thresh])

Computes the rise time of a single-stage RC filter.

camel_to_snake(name)

Convert a CamelCase name to snake_case.

find_param_source(param)

Return the root source of a parameter.

find_parameters(instrument, *params_to_exclude)

Recursively find all parameters on instrument except params_to_exclude, those of class param_classes_to_exclude, or those whose physical instrument is in underlying_instruments_to_exclude, up to a nesting level of max_nesting_level.

find_parameters_with_nesting_level_below(...)

Find all parameters in instrument and submodules at most nesting_level deep.

load_station(filename[, use_monitor, ...])

Load the station specified in filename, which should be a file living in mjolnir/config.

make_dc_constant_V_blocking(channel[, thresh])

Modify the dc_constant_V parameter of a QDAC-II channel to block until the voltage has settled at thresh of its designated value.

make_dc_constant_V_nonblocking(channel)

Revert make_dc_constant_V_blocking().

mean_and_standard_error(data[, axis, alpha])

Compute the mean and standard error on the mean.

rise_time_dependent_post_delay(self, _, val, ...)

Side effect for bob_filter_RC parameter of QDAC-II channels.

save_to_hdf5(run_id, savepath, *params_to_skip)

Extract run_id from the database and save to hdf5.

setup_logging(levels)

Set up logging (only for calibration module currently).

start_monitor(station, *params_to_exclude[, ...])

Start a monitor on parameters of instruments on station.

timed(func)

Adds timing to func and reports it to stdout.

update_qdac2_line_label(channel, gate_type, side)

Give QDAC2 channels more meaningful labels.

mjolnir.helpers.calculate_ramp_time_with_filter(slew_rate, voltage_swing, RC, thresh)[source]#

Calculate the time for a linear ramp with an analogue RC filter to settle at thresh.

The settling time can be obtained by inverse Laplace-transform of the transfer function

\[C(s) = \frac{1}{s\tau + 1}\times\frac{k}{s^2}\]

where \(\tau=RC\) and \(k\) is the slope of the ramp.

Parameters:
  • slew_rate (float) – Slope of the ramp.

  • voltage_swing (float) – Range of the ramp.

  • RC (float) – Time constant of the filter.

  • thresh (float) – Settling threshold that should be achieved.

Return type:

float

mjolnir.helpers.calculate_rise_time(RC, thresh=0.9)[source]#

Computes the rise time of a single-stage RC filter.

Parameters:

RC (float)

Return type:

float

mjolnir.helpers.camel_to_snake(name)[source]#

Convert a CamelCase name to snake_case.

Parameters:

name (str)

Return type:

str

mjolnir.helpers.find_param_source(param)[source]#

Return the root source of a parameter.

Parameters:

param (ParameterBase)

Return type:

ParameterBase

mjolnir.helpers.find_parameters(instrument, *params_to_exclude, instruments_to_exclude=(), underlying_instruments_to_exclude=(), param_classes_to_exclude=(), only_gettable=False, max_nesting_level=0)[source]#

Recursively find all parameters on instrument except params_to_exclude, those of class param_classes_to_exclude, or those whose physical instrument is in underlying_instruments_to_exclude, up to a nesting level of max_nesting_level.

Parameters:
Return type:

Iterator[Parameter]

mjolnir.helpers.find_parameters_with_nesting_level_below(instrument, nesting_level)[source]#

Find all parameters in instrument and submodules at most nesting_level deep.

Parameters:
Return type:

Iterator[Parameter]

mjolnir.helpers.load_station(filename, use_monitor=False, update_snapshot=False)[source]#

Load the station specified in filename, which should be a file living in mjolnir/config.

Parameters:
Return type:

Station

mjolnir.helpers.make_dc_constant_V_blocking(channel, thresh=0.99)[source]#

Modify the dc_constant_V parameter of a QDAC-II channel to block until the voltage has settled at thresh of its designated value.

Parameters:
mjolnir.helpers.make_dc_constant_V_nonblocking(channel)[source]#

Revert make_dc_constant_V_blocking().

Parameters:

channel (QDac2Channel)

mjolnir.helpers.mean_and_standard_error(data, axis=0, alpha=0.05)[source]#

Compute the mean and standard error on the mean.

References

https://en.wikipedia.org/wiki/Student%27s_t-distribution#Confidence_intervals

Parameters:
  • data (numpy.typing.ArrayLike)

  • axis (int)

  • alpha (float)

Return type:

tuple[float, float]

mjolnir.helpers.rise_time_dependent_post_delay(self, _, val, channel, thresh)[source]#

Side effect for bob_filter_RC parameter of QDAC-II channels.

Waits at least as long as a step impulse takes to settle at thresh.

Use together with py:functools.partial().

Todo

Unused as of now.

Parameters:
Return type:

None

mjolnir.helpers.save_to_hdf5(run_id, savepath, *params_to_skip, method='dataset', compress=False)[source]#

Extract run_id from the database and save to hdf5.

Parameters:
  • run_id (int) – Captured run id.

  • savepath (PathLike) – File where the dataset should be saved.

  • *params_to_skip – Names of dataset parameters to skip exporting.

  • method (Literal['dataset', 'dataarray']) – Export to an xarray Dataset or DataArray.

  • compress (bool) – Use level 5 gzip compression.

mjolnir.helpers.setup_logging(levels)[source]#

Set up logging (only for calibration module currently).

Since qcodes controls the root logger, we need to make sure loggers are independent of it.

Parameters:

levels (dict[str, int])

mjolnir.helpers.start_monitor(station, *params_to_exclude, instruments_to_exclude=(), underlying_instruments_to_exclude=(), param_classes_to_exclude=(), max_nesting_level=0, update=False, url='localhost', port=3000, show=False, **monitor_kwargs)[source]#

Start a monitor on parameters of instruments on station.

Parameters:
  • station (Station) – The qcodes station hosting the instruments.

  • *params_to_exclude (ParameterBase) – Parameters to exclude from the monitor.

  • underlying_instruments_to_exclude (Sequence[InstrumentBase]) – Exclude parameters bound to these underlying instruments.

  • instruments_to_exclude (Sequence[InstrumentBase]) – Exclude parameters bound to these instruments.

  • param_classes_to_exclude (tuple[type[Parameter], ...] | type[Parameter]) – Exclude parameters of these types.

  • max_nesting_level (int) – Include parameters of up to this many children.

  • update (bool) – Update parameter values.

  • url (str) – The url of the server.

  • port (int) – The port under which to reach the server.

  • show (bool) – Open a new webbrowser tab with the monitor.

  • **monitor_kwargs – Keyword arguments passed to the Monitor constructor.

Returns:

  • server – The web server running the monitor.

  • monitor – The Monitor instance.

Return type:

tuple[ThreadedWebserver, Monitor]

mjolnir.helpers.timed(func)[source]#

Adds timing to func and reports it to stdout.

Parameters:

func (Callable[[~_P], _T])

Return type:

Callable[[~_P], _T]

mjolnir.helpers.update_qdac2_line_label(channel, gate_type, side)[source]#

Give QDAC2 channels more meaningful labels.