silq.tools package

Submodules

silq.tools.circuit_tools module

silq.tools.config module

class silq.tools.config.SubConfig(name, folder=None, parent=None, save_as_dir=None)[source]

Bases: object

Config with added functionality, used within qcodes.config.user.

The SubConfig is a modified version of the qcodes config, the root being qcodes.config.user.silq_config. It is used as the SilQ config (silq.config), attached during importing silq, and initialized during silq.initialize with the respective experiment config.

SubConfigs can be nested, and there is a SubConfig child class for subtypes (DictConfig for dicts, ListConfig for lists). These are automatically instantiated when adding a dict/list to a SubConfig.

The SubConfig contains the following main extensions over the qcodes config:

  1. Support for saving/loading the config as a JSON folder structure This simplifies editing part of the config in an editor. Each subconfig can be set to either save as a folder or as a file via the save_as_dir attribute.

  1. Handling of an environment (set by silq.environment). The environment (string) the key of a dict in silq.config (top-level). If the environment (string) is set, any call to environment:{path} will access `silq.config.{silq.environment}.{path} This allows easy switching between config settings.

  1. Emit a signal when a value changes. The signal uses blinker.signal, the signal name being config:{config_path}, where config_path is a dot-separated path to of the config. For example, setting:

    >>> silq.config.properties.key1 = val
    

    The path is equal to qcodes.config.user.silq_config.properties.key1 and emits a signal with sender config:properties.key1 and keyword argument value=val. This signal can then by picked up by other objects, in particular by parameters via its initialization kwarg config_link. This means that whenever that specific config value changes, the parameter is updated accordingly.

Parameters
  • name (str) – Config name. SilQ config root is config.

  • folder (Optional[str]) – Absolute config folder path. Automatically set for child SubConfigs in the root SubConfig.

  • parent (Optional[SubConfig]) – Parent SubConfig (None for root SubConfig).

  • save_as_dir (Optional[bool]) – Save SubConfig as dir. If False, SubConfig and all elements in it are saved as a JSON file. If True, SubConfig is saved as a folder, each dict key being a separate JSON file.

property config_path

dot.separated.path``

Type

SubConfig path, e.g. ``config

load(folder=None)[source]

Load config from folder.

The folder must either contain a {self.name}.json file, or alternatively a folder containing config files/folders. In the latter case, a dict is created, and all the files/folders in the folder will be elements of the dict. All ‘.ipynb_checkpoints’ folders will be ignored.

If save_as_dir attribute is None, it will be updated to either True or False depending if there is a subfolder or file to load from the folder, respectively.

Note that SubConfig.load returns a dict/list, which should then be added to the Subconfig object depending on the subclass. This should be implemented in the load method of subclasses.

Parameters

folder (Optional[str]) – folder to look for. If not provided, uses self.folder.

Returns

dict/list config, to be added by the load method of the subclass

refresh(config=None)[source]
save(folder=None, save_as_dir=None, dependent_value=False)[source]

Save SubConfig as JSON files in folder structure.

Calling this method iteratively calls the same method on each of its elements. The folder structure is determined by the save_as_dir attribute.

Parameters
  • folder (Optional[str]) – Folder in which to save SubConfig. If None, uses self.folder. Automatically passed for child SubConfigs.

  • save_as_dir (Optional[bool]) – Save SubConfig as folder, in which each element is a key. If None, uses self.save_as_dir. Automatically set to None for all child SubConfigs.

serialize(dependent_value=False)[source]
class silq.tools.config.DictConfig(name, folder=None, parent=None, config=None, save_as_dir=None)[source]

Bases: silq.tools.config.SubConfig, qcodes.config.config.DotDict, qcodes.utils.helpers.SignalEmitter

SubConfig for dictionaries, extension of qcodes.config.

This is a SubConfig child class for dictionaries.

The DictConfig is a DotDict, meaning that its elements can be accessed as attributes. For example, the following lines are identical:

>>> dict_config['item1']['item2']
>>> dict_config.item1.item2
Parameters
  • name (str) – Config name. SilQ config root is config.

  • folder (Optional[str]) – Absolute config folder path. Automatically set for child SubConfigs in the root SubConfig.

  • parent (Optional[SubConfig]) – Parent SubConfig (None for root SubConfig).

  • config (Optional[dict]) – Pre-existing config to load into new DictConfig.

  • save_as_dir (Optional[bool]) – Save SubConfig as dir. If False, SubConfig and all elements in it are saved as a JSON file. If True, SubConfig is saved as a folder, each dict key being a separate JSON file.

exclude_from_dict = ['name', 'folder', 'parent', 'initializing', 'signal', '_signal_chain', '_signal_modifiers', '_mirrored_config_attrs', '_inherited_configs', 'save_as_dir', 'config_path', 'sender', 'multiple_senders']
get(key, default=None)[source]

Override dictionary get, because it does not call __getitem__.

Parameters
  • key (str) – key to get

  • default (Optional[Any]) – default value if key not found. None by default

Returns

value of key if in dictionary, else default value.

items() → a set-like object providing a view on D's items[source]
load(folder=None, update=True)[source]

Load SubConfig from folder.

Parameters

folder (Optional[str]) – Folder from which to load SubConfig.

serialize(dependent_value=True)

Convert DictConfig including all its children to a dictionary.

signal = <blinker.base.Signal object>
to_dict(dependent_value=True)[source]

Convert DictConfig including all its children to a dictionary.

values() → an object providing a view on D's values[source]
class silq.tools.config.ListConfig(name, folder=None, parent=None, config=None, **kwargs)[source]

Bases: silq.tools.config.SubConfig, list

SubConfig for lists, extension of qcodes.config.

This is a SubConfig child class for lists.

Parameters
  • name – Config name. SilQ config root is config.

  • folder – Absolute config folder path. Automatically set for child SubConfigs in the root SubConfig.

  • parent – Parent SubConfig (None for root SubConfig).

  • config – Pre-existing config to load into new ListConfig.

  • save_as_dir – Save SubConfig as dir. If False, SubConfig and all elements in it are saved as a JSON file. If True, SubConfig is saved as a folder, each dict key being a separate JSON file.

load(folder=None, update=True)[source]

Load SubConfig from folder.

Parameters
  • folder (Optional[str]) – Folder from which to load SubConfig.

  • update – update current config

serialize(dependent_value=True)

Convert Listconfig including all children into a list

to_list(dependent_value=True)[source]

Convert Listconfig including all children into a list

silq.tools.config.update_dict(d, u)[source]

Update dictionary recursively.

this ensures that subdicts are also converted This is a modified version of the update function in qcodes config

silq.tools.data_tools module

silq.tools.data_tools.create_data_set(name, base_folder, subfolder=None, formatter=None)[source]

Create empty DataSet within main data folder.

Uses new_data, and handles location formatting.

Parameters
  • name (str) – DataSet name, used as DataSet folder name.

  • base_folder (str) – Base folder for DataSet. Should be a pre-existing DataSet folder. If None, a new folder is created in main data folder.

  • subfolder (Optional[str]) – Adds subfolder within base_folder for DataSet. Should not be used without explicitly setting base_folder.

  • formatter (Optional[Formatter]) – Formatter to use for data storage (e.g. GNUPlotFormat).

Returns

New empty DataSet.

silq.tools.data_tools.get_data_folder(*path, newest_date=None)[source]

Get first data folder in main data folder satisfying conditions.

Parameters
  • *path – Filter for data folder. First arg can be an absolute path, in which case data folder is searched in that path. If a list of strings, each element corresponds to a subfolder in main data folder, whose folder name must contain the given string. Arg can be dataset index, in which case it must start with #, and be followed by digits. leading zeroes are not necessary. If not provided, first data folder in main data path is used.

  • newest_date (Optional[str]) – Latest date for dataset. If specified, the first dataset earlier than this date is searched.

Returns

Relative path to found dataset

Raises

IterationError – No dataset found.

silq.tools.detect_peaks module

silq.tools.detect_peaks.calculate_gradient(Z, filter=False)[source]

Computes the theta matrix for a 2-dimensional charge stability diagram.

The theta matrix indicates the direction of the 2-dimensional gradient.

# TODO Please elaborate code. At this moment all these arrays don’t make # sense. Either say why the values are chosen, or refer to a # website/paper where they were obtained from. # -> The wikipedia page for sobel operator explains most of this funtion https://en.wikipedia.org/wiki/Sobel_operator # TODO Could modifying these values improve the code? # -> Yes, fine-tuning these values could definitely improve performance. This can be done later. # TODO From what I gather, we’re applying a kernel, so perhaps it makes sense # to have kernel_size as a keyword argument. # -> This is a good point, i want to add that later. # TODO what does filter do excactly? What type of filtering is applied? # -> SY and SX are differentiating kernels, all others are binomial window filters. :type Z: ndarray :param Z: 2-dimensional charge stability diagram matrix. :type filter: bool :param filter: Enables filtering during the calculations.

Returns

Magnitude of gradient theta: 2-dimensional theta matrix.

Return type

magnitude

silq.tools.detect_peaks.calculate_theta_deviation(theta, theta_mode)[source]
Return type

ndarray

silq.tools.detect_peaks.calculate_transition_gradient(theta, filter=True)[source]

Compute the transition gradient matrix from a given theta matrix.

# TODO minor explanation of what a transition gradient is

Parameters

theta (ndarray) – 2-dimensional theta matrix of a charge stability diagram.

Return type

ndarray

Returns

2-dimensional transition gradient matrix.

x-axis is start position, y-axis is gradient.

silq.tools.detect_peaks.delete_transition(theta, location, gradient)[source]

Removes a transition from a theta matrix. In order to find transitions, they are identified one at a time. The most prominent transition is identified first, then removed from the theta matrix so that the second most prominent transition can be found.

Transitions can be identitified by their theta matrix being significantly different to the most common theta value. Thus, by replacing a transition with the most common value, it is essentially being removed.

Parameters
  • theta (ndarray) – 2-dimensional theta matrix of a charge stability diagram.

  • location (int) – Base index of the charge transfer event in Z

  • gradient (float) – Gradient of the charge transfer event in Z

Returns

modified 2-dimensional theta matrix, with the specified transition removed.

Return type

theta

silq.tools.detect_peaks.find_matrix_mode(M, bins=100)[source]

Determines the mode of a matrix (most-often occurring element).

# TODO check if this description is accurate

-> Yes it is.

Mode is found by first generating a histogram of matrix values, and then returning the center value of the bin with the highest count. Values are grouped because floating numbers are only approximately equal.

Parameters

M (ndarray) – n-dimensional matrix. Ideally a 2-dimensional theta matrix.

Returns

most common element of M after grouping via a histogram.

Return type

mode

silq.tools.detect_peaks.find_transitions(z, x=None, y=None, true_units=False, charge_transfer=False, plot='Off')[source]

Locate transitions within a 2-dimensional charge stability diagram

Parameters
  • z (ndarray) – 2-dimensional charge stability diagram matrix.

  • x (Optional[ndarray]) – 1-dimensional voltage vector for the x-axis of Z

  • y (Optional[ndarray]) – 1-dimensional voltage vector for the y-axis of Z

  • min_gradient – Minimum gradient to count as a transition

  • true_units (bool) –

    if True:

    Where applicable, return all values in proper units. i.e. voltage and current.

    if False:

    Return values in calculation specific form. i.e. index and ratios.

  • charge_transfer (bool) – Enables calculation of voltage and current shift information about transitions. This is required to calculate dV, dI, dI_x, dI_y

  • plot (str) –

    • ‘Off’ = No plots

    • ’Simple’ = Plot of DC data and transition data next to it

    • ’Complex’ = All of simple, plus the transition_gradient and theta plots for each transition.

Returns: a list of dictionaries, one entry for each transition found: # TODO (Serwan) simplify this part if true_units == True:

location (float): Voltage at the base of the transition. gradient (float): Gradient of the transition. in y_Voltage/x_Voltage intensity (float): Value between 0 and 1, indicating the strength of the transition dV (float): The shift of coulomb peaks from a charge transfer event. dV = dVtop = ∆q/Ctop dI (array): An array of current change from before to after a transition.

Returns -1 if error.

dI_x (array): An array of x-voltages corresponding to the points in dI. dI_y (array): An array of y-voltages corresponding to the points in dI.

if true_units == False):

location (int): Index at the base of the transition. gradient (float): Gradient of the transition. in y-index/x-index intensity (float): Value between 0 and 1, indicating the strength of the transition dV (int): The shift of coulomb peaks from a charge transfer event in terms of index in X.

dV*(y[1]-y[0]) = dVtop = ∆q/Ctop

dI (array): An array of current change from before to after a transition.

Returns -1 if error.

dI_x (array): An array of x-indices corresponding to the points in dI. dI_y (array): An array of y-indices corresponding to the points in dI.

Return type

List[dict]

silq.tools.detect_peaks.get_charge_transfer_information(Z, location, gradient, theta_mode)[source]

Calculate information about a particular charge transfer event.

Firstly, calculates how much the coulomb peaks shift at a charge transfer event. It does this by taking two slices either side of the transition, then comparing the shift.

Secondly, the algorithm locates points where the current difference could be conducive as a tuning point. It does this by again taking two slices either side of the transition and comparing the current difference.

Parameters
  • Z (ndarray) – 2-dimensional charge stability diagram matrix.

  • location (int) – Base index of the charge transfer event in Z

  • gradient (float) – Gradient of the charge transfer event in Z

  • theta_mode (float) – Mode of theta (most common theta value)

Returns

The shift of coulomb peaks from a charge transfer event.
Given as a shift of index in Z. When properly scaled:

dV = dVtop = delta_q/Ctop

dI: An array of current change from before to after a transition. dI_x: An array of x-indices corresponding to the points in dI. dI_y: An array of y-indices corresponding to the points in dI.

Return type

dV

silq.tools.detect_peaks.max_index(M)[source]

Returns the index of the maximum element in M.

Parameters

M (ndarray) – n-dimensional matrix. Ideally a 2-dimensional theta matrix, 2-dimensional charge stability diagram, or 2-dimensional transition gradient matrix.

Return type

Tuple[int, int]

Returns

Array with x and y index of maximum element. For a transition gradient matrix, I[0] is dx, and I[1] is x1.

silq.tools.detect_peaks.plot_transition_gradient(transition_gradient, theta_deviation)[source]
silq.tools.detect_peaks.plot_transitions(x, y, Z, transitions)[source]

silq.tools.general_tools module

silq.tools.general_tools.execfile(filename, globals=None, locals=None)[source]

Execute code in .py file, adding new variables to globals/locals.

Parameters
  • globals (Optional[dict]) – Global variables dictionary. If not specified, uses globals in first frame.

  • locals (Optional[dict]) – Local variables dictionary. If not specified, uses locals in first frame.

silq.tools.general_tools.is_between(val, min_val=None, max_val=None, tolerance=1e-13)[source]

Check if value is between min and max, taking machine precision into account

silq.tools.general_tools.get_truth(test_val, target_val, relation='==')[source]

Tests if the test_val satisfies the relation to target_val.

Parameters
  • test_val (Any) – lhs of relation with target_val.

  • target_val (Any) – rhs of relation with test_val

  • relation (str) – relation between test_val and target_val. Default is ‘==’ Can be: ‘>’, ‘<’, ‘>=’, ‘<=’, ‘==’

Return type

bool

Returns

True if relation holds

silq.tools.general_tools.get_memory_usage()[source]

return the memory usage in MB

class silq.tools.general_tools.SettingsClass(ignore_if_set=[], **kwargs)[source]

Bases: object

Class used to temporarily override attributes. This can be done through obj.single_settings() and obj.temporary_settings(). Any settings specified here will override the actual values of the object until settings are cleared

Settings can be cleared in two ways: Using the decorator @clear_single_settings on a method, which will delete the single_settings. Using obj.clear_settings(), which will clear both the single settings and temporary settings.

Furthermore, attribute_names can be added to ignore_if_set. If the object’s value of that attribute is not equal to None, [], or (), it cannot be overridden through single or temporary settings.

Note that for all attributes, they must be set in the object before they can be overridden by single/temporary settings

clear_settings()[source]

Clears temporary and single settings

settings(**kwargs)[source]

Sets up the meta properties of a measurement parameter

single_settings(**kwargs)[source]

Sets up the meta properties of a measurement parameter

temporary_settings(append=True, **kwargs)[source]

Sets up the meta properties of a measurement parameter

class silq.tools.general_tools.UpdateDotDict(update_function=None, **kwargs)[source]

Bases: qcodes.config.config.DotDict

DotDict that can evaluate function upon being updated.

Parameters
  • update_function – Function that is called every time a value changes.

  • **kwargs – Unused kwargs.

exclude_from_dict = ['update_function', 'exclude_from_dict']
silq.tools.general_tools.attribute_from_config(item, config)[source]

Check if attribute exists is an item in the config

Parameters
  • item (str) – key in config to check

  • config (dict) – config to check

Returns

Value in config. If dict-like, will be converted to dict.

Raises

AttributeError – item not found.

silq.tools.general_tools.clear_single_settings(f)[source]

SettingsClass wrapper to clear single_settings after running function.

Parameters

f – function after which to clear single_settings attribute.

silq.tools.general_tools.JSONEncoder(obj, ignore_attrs=[], ignore_vals=[])[source]

Encode object as dict for JSON encoding.

Parameters
  • ignore_attrs (List[str]) – Attributes that should not be included.

  • ignore_vals (List[str]) – Vals to be ignored.

Returns

dict representation of object.

Notes

# If one of its attributes is an object containing method _JSONEncoder,

the method is called to get its JSON representation.

# Lists are encoded using JSONListEncoder, which has an additional

check for the method _JSONEncoder.

Todo

Ensure parameters etc. are encoded using their snapshot.

silq.tools.general_tools.JSONListEncoder(l)[source]
silq.tools.general_tools.run_code(label, **kwargs)[source]

Creates cell to run code from global variable code_labels

Code labels is a dictionary in which each key has a corresponding value that is a string representation of executable code. Note that the module variable code_labels must be set to equal the global variable code_labels.

Parameters
  • label – label referring to code in dict code_labels

  • **kwargs – Optional kwargs that are replaced in code i.e. for a given kwarg {var}=5, a line matching: “{var} = {val}” will be replaced to “{var} = 5” (Note whitespaces)

Returns

Creates cell at bottom of notebook and executes it

Note

This function is not used anymore, though it should still work

silq.tools.general_tools.get_exponent(val)[source]

Get decimal exponent

Example

>>> get_exponent(0.032)
-2
Parameters

val (float) – Val of which to get exponent

Returns

Exponent

silq.tools.general_tools.get_first_digit(val)[source]

Get first nonzero digit.

Example

>>> get_first_digit(0.032)
3
Parameters

val (float) – Val for which to get first nonzero digit

Returns

First nonero digit.

class silq.tools.general_tools.ParallelTimedRotatingFileHandler(filename, when='h', interval=1, backupCount=0, encoding=None, delay=False, utc=False, postfix='.log')[source]

Bases: logging.handlers.TimedRotatingFileHandler

Logging handler that creates a new log file every day.

Files are stored with .log suffix, and dates are included in filename from the beginning. Also allows multiple processes to access same log.

Note

calculateFileName(currenttime)[source]
doRollover()[source]

do a rollover; in this case, a date/time stamp is appended to the filename when the rollover happens. However, you want the file to be named for the start of the interval, not the current time. If there is a backup count, then we have to get a list of matching filenames, sort them and remove the one with the oldest suffix.

getFilesToDelete(newFileName)[source]

Determine the files to delete when rolling over.

More specific than the earlier method, which just used glob.glob().

silq.tools.general_tools.convert_setpoints(*args)[source]

Convert setpoints to tuples, supporting multidimensional setpoints.

Temporary solution to make setpoints work (see issue #627). Currently, setpoints need to be tuples (arrays etc. give issues). Further, the second setpoint array needs to be 2D etc.

Parameters

*args – 1D setpoint arrays. each successive setpoints array gains an extra dimension

Returns

Setpoint arrays converted to tuples.

class silq.tools.general_tools.Singleton[source]

Bases: type

Meta-class for classes that can only have a single instance.

If a second instance is created, it will instead return the already-existing instance.

class silq.tools.general_tools.property_ignore_setter(func, doc=None)[source]

Bases: object

Decorator similar to @property that ignores setter

The setter shouldn’t be defined, and any setting of attribute is ignored.

silq.tools.general_tools.freq_to_str(frequency, fmt='{:.15g}')[source]

Formats frequency, using right magnitude.

Note

This will be superseded later on when all attributes are converted to parameters.

silq.tools.notebook_tools module

silq.tools.notebook_tools.create_cell(text, location='below', execute=False, select=True)[source]

Create code cell in Jupyter Notebook and optionally execute.

Parameters
  • text (str) – Python code to place in cell.

  • location (str) – Cell location. Can be either below currently active cell, or bottom of notebook.

  • execute (bool) – Execute cell.

  • select (bool) – Make new cell active cell

silq.tools.parameter_tools module

class silq.tools.parameter_tools.SweepDependentValues(parameter, step=None, step_percentage=None, num=None, window=None, center_val=None, min_val=None, max_val=None, reverse=False, fix=True)[source]

Bases: qcodes.instrument.sweep_values.SweepValues

Sweep Parameter values with args that depend on current value.

This class is used in Parameter.sweep to extend the functionality to allow choosing values that depend on the parameter’s current value.

Not all arguments need to be specified. Instead, a subset can be chosen.

Parameters
  • parameter (Parameter) – Parameter used for sweeping.

  • step (Optional[float]) – Parameter value step size

  • step_percentage (Optional[float]) – Percentage for step size. If this value is used, silq.config.parameters.{parameter.name}.steps should be a list with two elements, the first corresponding to step_percentage=0, the second to step_percentage=100, with values in between being the logarithmic equivalent.

  • num (Optional[int]) – Number of points.

  • window (Optional[float]) – Range of values around center value.

  • center_val (Optional[float]) – Center value, by default parameter’s current value.

  • min_val (Optional[float]) – Minimum value.

  • max_val (Optional[float]) – Maximum value.

  • reverse (bool) – Reverse order of values.

  • fix (bool) – Fix values, if True, the center value is recorded and not updated every iteration.

calculate_step(min_step, max_step, percentage, round_vals=True)[source]
create_vals()[source]
determine_step(parameter)[source]
silq.tools.parameter_tools.create_set_vals(num_parameters=None, step=None, step_percentage=None, points=None, window=None, set_parameters=None, silent=True, center_val=None, min_val=None, max_val=None, reverse=False)[source]

silq.tools.plot_tools module

class silq.tools.plot_tools.PlotAction(plot, timeout=None, enable_key=None)[source]

Bases: object

Interactive key/button action for MatPlot

A PlotAction can be attached to an InteractivePlot, adding some sort of interactivity, e.g. change parameter value when pressing a key button.

Parameters
  • plot (MatPlot) – Plot object

  • timeout (Optional[int]) – Seconds before plot action is deactivated. Only relevant if the enable_key differs from the actual key/button actions.

  • enable_key (Optional[str]) – String to enable plot action.

  • enabled (bool) – Plot action is enabled.

button_press(event)[source]

Handle Matplotlib button press action.

enable_key = None
property enabled
handle_code(code, copy=False, execute=False, new_cell=True)[source]

Handle code, either executing it or copying it to clipbard

Parameters
  • code (str) – Python code to handle.

  • copy (bool) – Copy to clipboard.

  • execute (bool) – Execute code, only relevant if new_cell is True.

  • new_cell (bool) – Create new cell below current one and add code.

key_press(event)[source]

Handle Matplotlib key press.

This enables PlotAction if key press is enable_key

class silq.tools.plot_tools.SetGates(plot, timeout=None, enable_key=None)[source]

Bases: silq.tools.plot_tools.PlotAction

Set gates when button pressed in MatPlot, enabled with alt + g.

Only works for 2D plots.

Parameters
  • plot (MatPlot) – Plot object

  • timeout (Optional[int]) – Seconds before plot action is deactivated. Only relevant if the enable_key differs from the actual key/button actions.

  • enable_key (Optional[str]) – String to enable plot action.

  • enabled (bool) – Plot action is enabled.

button_press(event)[source]

Handle Matplotlib button press action.

enable_key = 'alt+g'
class silq.tools.plot_tools.MeasureSingle(plot, timeout=None, enable_key=None)[source]

Bases: silq.tools.plot_tools.PlotAction

Measure parameter at clicked gate vales, enabled with alt + s

Upon button click, a new cell below current one is created, in which gates are set to clicked values, and a qc.Measure is performed for measure_param.

Only works for 2D plots.

Parameters
  • plot (MatPlot) – Plot object

  • timeout (Optional[int]) – Seconds before plot action is deactivated. Only relevant if the enable_key differs from the actual key/button actions.

  • enable_key (Optional[str]) – String to enable plot action.

  • enabled (bool) – Plot action is enabled.

button_press(event)[source]

Handle Matplotlib button press action.

enable_key = 'alt+s'
class silq.tools.plot_tools.MoveGates(plot, timeout=None, enable_key=None)[source]

Bases: silq.tools.plot_tools.PlotAction

Increase/decrease gates when pressing alt + {arrow}, enabled with alt+m.

Alt + up/down moves the y-gate. Alt + left/right moves the x-gate. Alt + +/- increases/decreases step size.

Parameters
  • plot (MatPlot) – Plot object

  • timeout (Optional[int]) – Seconds before plot action is deactivated. Only relevant if the enable_key differs from the actual key/button actions.

  • enable_key (Optional[str]) – String to enable plot action.

  • enabled (bool) – Plot action is enabled.

  • delta (float) – Step size.

button_press(event)[source]

Handle Matplotlib button press action.

delta = 0.001
enable_key = 'alt+m'
key_press(event)[source]

Handle Matplotlib key press.

This enables PlotAction if key press is enable_key

class silq.tools.plot_tools.SwitchPlotIdx(plot, timeout=None, enable_key=None)[source]

Bases: silq.tools.plot_tools.PlotAction

Change plot index when pressing alt+{arrow}, used with SliderPlot.

Alt + left/right changes first plot index. Alt + up/down changes second plot index (if two sliders).

Parameters
  • plot (MatPlot) – Plot object

  • timeout (Optional[int]) – Seconds before plot action is deactivated. Only relevant if the enable_key differs from the actual key/button actions.

  • enable_key (Optional[str]) – String to enable plot action.

  • enabled (bool) – Plot action is enabled.

key_press(event)[source]

Handle Matplotlib key press.

This enables PlotAction if key press is enable_key

class silq.tools.plot_tools.InteractivePlot(*args, actions=(), timeout=600, **kwargs)[source]

Bases: qcodes.plots.qcmatplotlib.MatPlot

Base class for MatPlot plots adding interactivity.

The QCoDeS MatPlot, which uses matplotlib, can be interactive, and respond to key/button presses. This subclass of MatPlot enables such interactivity by adding PlotAction to the plot. Each PlotAction can respond to specific key presses or button clicks.

Parameters
  • *args – args passed to MatPlot.

  • actions (List[PlotAction]) – PlotAction list to use for plot.

  • timeout (int) – Timeout for any action to be disabled.

  • **kwargs – kwargs passed to MatPlot.

connect_event(event, action)[source]

Attach PlotAction to a specific event.

Parameters
  • event (str) – matplotlib event (e.g. key_press_event, button_press_event)

  • action (PlotAction) – PlotAction to attach

handle_button_press(event)[source]

Handle button press event, forwarding to relevant PlotAction.

The relative PlotActions are those that are already enabled.

handle_key_press(event)[source]

Handle key press event, forwarding to relevant PlotAction

The relevant PlotActions are those that are either enabled, or whose enable_key match the key press event.

load_data_array(data_array)[source]

Retrieve properties of a DataArray, such as set arrays and labels.

Parameters

data_array (DataArray) – DataArray to extract

Returns

set_arrays (List[DataArray]): List of set arrays. labels: Labels of set arrays gates: Gates of set arrays, None if not in Station.

Return type

Dict[str, Any]

property timeout
class silq.tools.plot_tools.SliderPlot(data_array, ndim=2, **kwargs)[source]

Bases: silq.tools.plot_tools.InteractivePlot

Slide through 1D/2D images of a DataArray with more dimensions.

Parameters
  • data_array – Multidimensional DataArray to display.

  • ndim – Plotting dimension (1 or 2)

  • **kwargs – Additional kwargs to InteractivePlot and MatPlot.

property plot_kwargs
update()[source]

Update the data in this plot, using the updaters given with MatPlot.add() or in the included DataSets, then include this in the plot.

This is a wrapper routine that the update widget calls, inside this we call self.update() which should be subclassed

update_slider(idx, value=None)[source]
class silq.tools.plot_tools.CalibrationPlot(data_set, **kwargs)[source]

Bases: silq.tools.plot_tools.InteractivePlot

Interactive plot for 2D calibrations, move gates and measure at points.

The 2D calibration scan must contain a Parameter that returns the contrast. Pressing alt + m adds a dot on the colorplot, which can be moved by holding alt and pressing an arrow key. the contrast can then be measured at the dot by pressing alt + s.

Parameters
  • data_set (DataSet) – Calibration 2D scan data set.

  • **kwargs – Additional kwargs to InteractivePlot and MatPlot.

  • samples_measure (int) – Samples to use when measuring at a single point.

measure_parameter = 'adiabatic_ESR'
samples_measure = 200
class silq.tools.plot_tools.DCPlot(data_set, **kwargs)[source]

Bases: silq.tools.plot_tools.InteractivePlot

Interactive plot for a 2D DC scan, For easy moving gates on 2D plot.

Parameters
class silq.tools.plot_tools.ScanningPlot(parameter, interval=0.01, auto_start=False, **kwargs)[source]

Bases: silq.tools.plot_tools.InteractivePlot

Base class for interactive plots to repeatedly measure and refresh plot.

Parameters
  • parameter (_BaseParameter) – Parameter to measure and plot.

  • interval (float) – Measuring and updating interval.

  • auto_start (bool) – Start refreshing once initialized. If False, refreshing can be started by calling ScanningPlot.start.

  • **kwargs – Additional kwargs to InteractivePlot and Matplot.

property interval
scan(initialize=False, stop=False)[source]

Perform single meeasurement and update plot.

Repeatedly called by timer.

Parameters
  • initialize – True if this method is called during initialization.

  • stop – Stop instruments after acquisition.

start(setup=True, start=True)[source]

Start measuring and refreshing plot

Parameters
stop(*args)[source]

Stop measuring and refreshing plot.

Timer is stopped.

Parameters

*args – Unused args passed if method is called as a callback

property update_interval
class silq.tools.plot_tools.TracePlot(parameter, **kwargs)[source]

Bases: silq.tools.plot_tools.ScanningPlot

Interactive plot that repeatedly measures pulse sequence and plots trace

Parameters
update_plot(initialize=False)[source]

Update plot with new trace

Parameters

initialize (bool) – Method called during initialization.

class silq.tools.plot_tools.DCSweepPlot(parameter, gate_mapping=None, **kwargs)[source]

Bases: silq.tools.plot_tools.ScanningPlot

Refreshing 2D DC plot using DCSweepParameter for fast 2D DC scanning.

Parameters
gate_mapping = {}
point_color = 'r'
update_plot(initialize=False)[source]

Update plot with new 2D DC scan.

Parameters

initialize – Method called during initialization.

silq.tools.pulse_tools module

silq.tools.pulse_tools.pulse_to_waveform_sequence(max_points, frequency, sampling_rate, frequency_threshold, total_duration=None, final_delay_threshold=None, min_points=1, sample_points_multiple=1, point_offsets=[-1, 0, 1, 2], filters=[], plot=False)[source]

This method can be used when generating a periodic signal with an AWG device. Given a frequency and duration of the desired signal, a general AWG can produce that signal by repeating one waveform (waveform_1) for a number of times (cycles) and ending with a second waveform (waveform_2). This is a practical way of generating periodic signals that are long in duration without using a lot of the available RAM of the AWG.

Because of the finite sampling rate and restrictions on amount of sample points (which must generally be a multiple of a certain number), there will be an error in the period of the generated signal. This error goes down with the number of periods (n) that one cycle of the repeated waveform contains.

This function calculates the minimum number n for which the error threshold is satisfied. Therefore minimizing the total amount of sample points that need to be stored by the AWG.

Parameters
  • duration – duration of the signal in seconds

  • frequency (float) – frequency of the signal in Hz

  • sampling_rate (float) – the sampling rate of the waveform

  • threshold – threshold in relative period error

  • n_min – minimum number of signal periods that the waveform must contain

  • n_max – maximum number of signal periods that a waveform can contain

  • sample_points_multiple (int) – the number of samples must be a multiple of

Returns

‘optimum’: Dict of optimal settings

’error’: Relative frequency error of optimal settings ‘final_delay’: Remaining duration of pulse after waveform repetitions.

Cannot be negative.

’periods’: Periods within waveform (using modified frequency) ‘repetitions’: Repetitions of waveform to (almost) reach end of pulse ‘duration’: Duration of main waveform ‘points’: Number of waveform points ‘idx’: index of optimal result. first index corresponds to period

index of periods between min_periods and max_periods. Second index is the point offset index.

’modified_frequency’: Frequency close to target frequency whose

period perfectly fits in the number of points

’filtered_results’: Array of settings that satisfy filters ‘repetitions_multiple’: Repetition array for all settings ‘final_delays’: Array of final_delays for all settings ‘errors’: Array of relative frequency errors for all settings ‘periods_range’: Range of periods that have been considered

If the minimum number of periods (set by min_points) exceeds the maximum number of periods (set by max_points), None is returned

Return type

Dict containing

silq.tools.trace_tools module

Module contents