qtt package
Quantum Technology Toolbox
The QTT package contains functionality for the tuning and calibration of spin-qubits. The package is divided into subpackages:
Measurements: functionality to perform measurements on devices
Algorithms: functionality to analyse measurements
Simulation: contains simulations of quantum dot systems
Tools: misc tools
Gui: Several gui element for visualization of data
Instrument drivers: contains QCoDeS drivers for various instruments
For more information see https://github.com/qutech-delft/qtt
- qtt.abort_measurements(value=None)
Return True if the currently running measurement should be aborted
- qtt.check_version(version, module=<module 'qcodes' from '/home/docs/checkouts/readthedocs.org/user_builds/qtt/envs/latest/lib/python3.8/site-packages/qcodes/__init__.py'>, optional=False, install_message=None)[source]
Check whether a module has the correct version
- qtt.liveValue(var='qtt_live_value1')
Return live control value retrieved from redis server and convert to string
- qtt.liveValueSet(value, var='qtt_live_value1')
Set live control value on redis server
Subpackages
- qtt.algorithms package
- Submodules
- qtt.algorithms.allxy module
- qtt.algorithms.anticrossing module
- qtt.algorithms.awg_to_plunger module
- qtt.algorithms.bias_triangles module
- qtt.algorithms.chargesensor module
- qtt.algorithms.coulomb module
analyseCoulombPeaks()analyseCoulombPeaksArray()analysePeaks()coulombPeaks()filterOverlappingPeaks()filterPeaks()findBestSlope()findSensingDotPosition()fitCoulombPeaks()fitPeaks()gauss()peakFindBottom()peakOverlap()peakScores()peakdataOrientation()plotPeaks()sort_peaks()sort_peaks_inplace()
- qtt.algorithms.fitting module
- qtt.algorithms.functions module
Fermi()FermiLinear()cost_exp_decay()cost_gauss_ramsey()double_gaussian()estimate_dominant_frequency()estimate_parameters_damped_sine_wave()exp_function()fit_double_gaussian()fit_exp_decay()fit_gauss_ramsey()fit_gaussian()gauss_ramsey()gaussian()linear_function()logistic()plot_gauss_ramsey_fit()raised_cosine()raised_cosine_frequency_domain()sine()
- qtt.algorithms.gatesweep module
- qtt.algorithms.generic module
boxcar_filter()detect_blobs_binary()disk()extent2fullextent()findCoulombDirection()flowField()getValuePixel()issorted()localMaxima()makeCoulombFilter()nonmaxsuppts()rescaleImage()showCoulombDirection()showFlowField()signedabsX()signedmin()smoothImage()subpixelmax()weightedCentroid()
- qtt.algorithms.images module
- qtt.algorithms.markov_chain module
ChoiceGeneratorContinuousTimeMarkovModelContinuousTimeMarkovModel.generate_sequence()ContinuousTimeMarkovModel.generate_sequences()ContinuousTimeMarkovModel.number_of_states()ContinuousTimeMarkovModel.stationary_distribution()ContinuousTimeMarkovModel.stationary_distribution_direct()ContinuousTimeMarkovModel.stationary_distribution_discrete()ContinuousTimeMarkovModel.transition_matrix()ContinuousTimeMarkovModel.update_model()
generate_traces()
- qtt.algorithms.misc module
- qtt.algorithms.ohmic module
- qtt.algorithms.onedot module
- qtt.algorithms.pat_fitting module
- qtt.algorithms.random_telegraph_signal module
- qtt.algorithms.tunneling module
- qtt.gui package
- Submodules
- qtt.gui.dataviewer module
DataViewerDataViewer.clipboard_callback()DataViewer.combobox_callback()DataViewer.fill_item()DataViewer.find_datafiles()DataViewer.get_data_info()DataViewer.get_plot_parameter()DataViewer.load_data()DataViewer.load_info()DataViewer.log_callback()DataViewer.ppt_callback()DataViewer.reset_combo_items()DataViewer.select_directory()DataViewer.selected_data_file()DataViewer.set_data_directory()DataViewer.show_help()DataViewer.toggle_data_directory()DataViewer.update_logs()DataViewer.update_meta_tabs()DataViewer.update_plot()
- qtt.gui.live_plotting module
LivePlotControlMeasurementControlMockCallback_2dRdaControlgetLivePlotWindow()livePlotlivePlot.datafunctionlivePlot.sweepInstrumentlivePlot.sweepparamslivePlot.sweeprangeslivePlot.verboselivePlot.show_controlslivePlot.alphalivePlot.close()livePlot.crosshair()livePlot.enable_averaging()livePlot.enable_averaging_slot()livePlot.sigMouseClickedlivePlot.startreadout()livePlot.stopreadout()livePlot.update()livePlot.updatebg()
rda_tsetupMeasurementWindows()start_measurement_control()
- qtt.gui.loggingGUI module
- qtt.gui.parameterviewer module
ParameterViewerParameterViewer.close()ParameterViewer.initialize_viewer()ParameterViewer.is_running()ParameterViewer.setParamSingleStep()ParameterViewer.setSingleStep()ParameterViewer.set_column_sizehints()ParameterViewer.set_parameter_properties()ParameterViewer.set_window_name()ParameterViewer.stop()ParameterViewer.update_field_signalParameterViewer.updatecallback()ParameterViewer.updatedata()
QCodesTimercreateParameterWidget()createParameterWidgetRemote()isfloat()
- qtt.instrument_drivers package
- Subpackages
- Submodules
- qtt.instrument_drivers.BlueforsMonitor module
- qtt.instrument_drivers.DistributedInstrument module
- qtt.instrument_drivers.FPGA_ave module
- qtt.instrument_drivers.ILM200 module
- qtt.instrument_drivers.TimeStamp module
- qtt.instrument_drivers.gates module
VirtualDACVirtualDAC.nameVirtualDAC.instrumentsVirtualDAC.gate_mapVirtualDAC.rc_timesVirtualDAC.add_instruments()VirtualDAC.allvalues()VirtualDAC.allvalues_string()VirtualDAC.gate_mapVirtualDAC.get_all()VirtualDAC.get_boundaries()VirtualDAC.get_idn()VirtualDAC.get_instrument_parameter()VirtualDAC.instrumentsVirtualDAC.resetgates()VirtualDAC.resettodataset()VirtualDAC.restore_at_exit()VirtualDAC.restrict_boundaries()VirtualDAC.set_boundaries()VirtualDAC.set_overshoot()VirtualDAC.visualize()
virtual_IVVI
- qtt.instrument_drivers.simulation_instruments module
- qtt.instrument_drivers.virtual_gates module
VirtualGatesVirtualGates.nameVirtualGates.gates_instrVirtualGates.allvalues()VirtualGates.convert_map_to_matrix()VirtualGates.convert_matrix_to_map()VirtualGates.from_dictionary()VirtualGates.get_crosscap_map()VirtualGates.get_crosscap_map_inv()VirtualGates.get_crosscap_matrix()VirtualGates.get_crosscap_matrix_inv()VirtualGates.multi_set()VirtualGates.normalize_matrix()VirtualGates.pgates()VirtualGates.plot_matrix()VirtualGates.print_inverse_matrix()VirtualGates.print_map()VirtualGates.print_matrix()VirtualGates.ratio()VirtualGates.resetgates()VirtualGates.set_crosscap_map()VirtualGates.set_crosscap_map_inv()VirtualGates.set_crosscap_matrix()VirtualGates.set_distances()VirtualGates.setgates()VirtualGates.to_dictionary()VirtualGates.vgates()
create_virtual_matrix_dict()extend_virtual_gates()set_distance_matrix()update_cc_matrix()
- qtt.instrument_drivers.virtual_instruments module
- qtt.measurements package
- Subpackages
- Submodules
- qtt.measurements.scans module
acquire_segments()awgGate()ceilN()checkReversal()createScanJob()create_vectorscan()enforce_boundaries()fastScan()fixReversal()floorN()getDefaultParameter()get_instrument()get_instrument_parameter()get_measurement_params()get_minstrument_channels()get_param()get_param_name()get_sampling_frequency()get_uhfli_scope_records()instrumentName()lin_comb_typemakeDataset_sweep()makeDataset_sweep_2D()makeScanjob()measure_raw_segment_m4i()measure_segment_scope_reader()measure_segment_uhfli()measuresegment()measuresegment_m4i()parse_minstrument()plotData()process_1d_sawtooth()process_2d_sawtooth()sample_data_tscan1D()scan1Dfast()scan2D()scan2Dfast()scan2Dturbo()scanjob_tselect_digitizer_memsize()select_m4i_memsize()single_shot_readout()waitTime()
- qtt.measurements.videomode module
VideoModeVideoMode.stationVideoMode.videomode_processorVideoMode.NaverageVideoMode.addPPT()VideoMode.all_instances()VideoMode.close()VideoMode.crosshair()VideoMode.destruct()VideoMode.enable_averaging_slot()VideoMode.get_dataset()VideoMode.get_instance()VideoMode.initialize()VideoMode.is_running()VideoMode.run()VideoMode.set_videomode_name()VideoMode.single()VideoMode.startreadout()VideoMode.stop()VideoMode.stop_all_instances()VideoMode.stop_videomode()VideoMode.stopreadout()VideoMode.updatebg()VideoMode.videomode_class_index
add_sawtooth_videomode_processor()
- qtt.measurements.videomode_processor module
DummyVideoModeProcessorVideoModeProcessorVideoModeProcessor.acquisition_device_type()VideoModeProcessor.create_dataset()VideoModeProcessor.default_processing()VideoModeProcessor.extend_videomode_name()VideoModeProcessor.initialize()VideoModeProcessor.measure()VideoModeProcessor.plot_title()VideoModeProcessor.ppt_notes()VideoModeProcessor.process()VideoModeProcessor.scan_dimension()VideoModeProcessor.stop()
VideomodeSawtoothMeasurementVideomodeSawtoothMeasurement.create_dataset()VideomodeSawtoothMeasurement.extend_videomode_name()VideomodeSawtoothMeasurement.initialize()VideomodeSawtoothMeasurement.measure()VideomodeSawtoothMeasurement.parse_instrument()VideomodeSawtoothMeasurement.plot_title()VideomodeSawtoothMeasurement.ppt_notes()VideomodeSawtoothMeasurement.process()VideomodeSawtoothMeasurement.scan_dimension()VideomodeSawtoothMeasurement.set_properties()VideomodeSawtoothMeasurement.set_scan_parameters()VideomodeSawtoothMeasurement.stop()VideomodeSawtoothMeasurement.update_position()
- qtt.qiskit package
- qtt.simulation package
- Submodules
- qtt.simulation.classicaldotsystem module
- qtt.simulation.dotsystem module
BaseDotSystemBaseDotSystem.number_of_basis_statesBaseDotSystem.HBaseDotSystem.energiesBaseDotSystem.statesBaseDotSystem.stateprobsBaseDotSystem.stateoccsBaseDotSystem.nstatesBaseDotSystem.calculate_ground_state()BaseDotSystem.findtransitions()BaseDotSystem.makebasis()BaseDotSystem.orderstatesbyE()BaseDotSystem.orderstatesbyN()BaseDotSystem.showstates()
DotSystemDotSystem.calculate_energies()DotSystem.calculate_ground_state()DotSystem.chemical_potential_matrix()DotSystem.chemical_potential_name()DotSystem.findcurrentoccupancy()DotSystem.get_chemical_potential()DotSystem.get_on_site_charging()DotSystem.getall()DotSystem.initSparse()DotSystem.inter_site_charging_matrix()DotSystem.inter_site_charging_name()DotSystem.makeH()DotSystem.makeHsparse()DotSystem.make_variables()DotSystem.makeparamvalues1D()DotSystem.makeparamvalues2D()DotSystem.on_site_charging_matrix()DotSystem.on_site_charging_name()DotSystem.resetMu()DotSystem.set_chemical_potential()DotSystem.set_on_site_charging()DotSystem.setall()DotSystem.showMmatrix()DotSystem.showvars()DotSystem.simulate_honeycomb()DotSystem.simulatehoneycomb()DotSystem.simulatehoneycomb_original()DotSystem.solveH()DotSystem.tunneling_matrix()DotSystem.tunneling_name()DotSystem.visualize()
DoubleDotFourDotGateTransformOneDotTripleDotTwoXTwoisdiagonal()showGraph()static_var()tprint()
- qtt.simulation.virtual_dot_array module
- qtt.utilities package
- Submodules
- qtt.utilities.debug module
- qtt.utilities.imagetools module
- qtt.utilities.json_serializer module
- qtt.utilities.optimization module
AverageDecreaseTerminationOptimizerCallbackOptimizerCallback.clear()OptimizerCallback.dataOptimizerCallback.data_callback()OptimizerCallback.lmfit_callback()OptimizerCallback.number_of_evaluations()OptimizerCallback.optimization_time()OptimizerCallback.parametersOptimizerCallback.plot()OptimizerCallback.qiskit_callback()OptimizerCallback.scipy_callback()
- qtt.utilities.tools module
addPPT_dataset()addPPTslide()cfigure()checkPickle()clickGatevals()code_version()connect_slot()create_figure_ppt_callback()cutoffFilter()deprecated()diffImage()diffImageSmooth()flatten()fourierHighPass()freezeclass()get_git_versions()get_module_versions()get_python_version()in_ipynb()is_spyder_environment()logging_context()measure_timemonitorSizes()negfloat()pythonVersion()rdeprecated()resampleImage()reshape_metadata()scanTime()set_ppt_slide_background()setupMeasurementWindows()showImage()slopeClick()smoothFourierFilter()static_var()stripDataset()updatePlotTitle()update_dictionary()
- qtt.utilities.visualization module
Submodules
qtt.data module
Utilities to work with data and datasets
- qtt.data.add_comment(txt, dataset=None, verbose=0)[source]
Add a comment to a DataSet
- Parameters:
comment (str) – comment to be added to the DataSet metadata
dataset (None or DataSet) – DataSet to add the comments to
- qtt.data.compare_dataset_metadata(dataset1, dataset2, metakey='allgatevalues', verbose=1)[source]
Compare metadata from two different datasets.
Outputs the differences in metadata from dataset1 to dataset2. For now, only comparisons for the key ‘allgatevalues’ has been implemented.
- Parameters:
dataset1 (DataSet) – first dataset to compare
dataset2 (DataSet) – second dataset to compare
metakey (str) – key in the DataSet metadata to compare
- qtt.data.dataset1Ddata(alldata)[source]
Parse a dataset into the x and y scan values
- Returns:
x (array) y (array)
- qtt.data.dataset1Dmetadata(alldata, arrayname=None, verbose=0)[source]
Extract metadata from a 1D scan
- Returns:
x1,x2 g0 (string): step gate vstep (array): step values istep (float) arrayname (string): identifier of the main array
- Return type:
extent (list)
- qtt.data.dataset2Dmetadata(alldata, arrayname=None, verbose=0)[source]
Extract metadata from a 2D scan
- Returns:
x1,x2,y1,y2 g0 (str): step gate (array_id) g1 (str): sweep gate (array_id) vstep (array): step values vsweep (array): sweep values arrayname (string): identifier of the main array
- Return type:
extent (list)
- qtt.data.dataset2image(dataset, arrayname=None, unitsperpixel=None, mode='pixel')[source]
Extract image from a dataset
- Parameters:
- Returns:
im (numpy array) tr (image_transform object)
- qtt.data.dataset2image2(dataset, arrayname=None)[source]
Extract image from dataset
- Parameters:
dataset (DataSet) – measured data
- Returns:
raw image impixel (array): image in pixel coordinates tr (image_transform object): transformation object
- Return type:
imraw (array)
See also: dataset2image
- qtt.data.datasetCentre(ds, ndim=None)[source]
Return centre position for dataset :param ds: :type ds: DataSet
- Returns:
centre position
- Return type:
cc (list of floats)
- qtt.data.dataset_labels(alldata: DataSet | DataArray, tag: int | str | None = None, add_unit: bool = False)[source]
Return label for axis of dataset
- Parameters:
alldata – dataset or dataarray
tag – can be ‘x’, ‘y’ or ‘z’ or the index of the axis. For DataArrays there is only a single axis.
add_unit – If True then add units
- Returns:
String with label for the axis
- qtt.data.dataset_to_dictionary(data_set: DataSet, include_data: bool = True, include_metadata: bool = True) Dict[str, Any][source]
Convert DataSet to dictionary.
- Parameters:
data_set – The data to convert.
include_data – If True then include the ndarray field.
include_metadata – If True then include the metadata.
- Returns:
Dictionary containing the serialized data.
- qtt.data.default_setpoint_array(dataset, measured_name='measured')[source]
Return the default setpoint array for a dataset
- qtt.data.determine_parameter_unit(parameter)[source]
Determine unit associated with a parameter
- Parameters:
parameter (Any) – the parameter to get the unit from
- Returns:
The unit associated with the parameter when the parameter is a qcodes parameter, otherwise None
- qtt.data.dictionary_to_dataset(data_dictionary: dict) DataSet[source]
Convert dictionary to DataSet.
- Parameters:
data_dictionary – data to convert
- Returns:
DataSet with converted data.
- qtt.data.diffDataset(alldata, diff_dir='y', sigma=2, fig=None, meas_arr_name='measured')[source]
Differentiate a dataset and plot the result.
- qtt.data.drawCrosshair(ds, ax=None, ndim=None, **kwargs)[source]
Draw a crosshair on the centre of the dataset
- Parameters:
ds (DataSet) –
ax (None or matplotlib axis handle) –
ndim (None or int) – dimension of dataset
kwargs – Arguments passed to the plotting command
- qtt.data.experimentFile(outputdir: str = '', tag=None, dstr=None, bname=None)[source]
Format experiment data file for later analysis
- qtt.data.getDateString(t=None, full=False)[source]
Return date string
- Parameters:
t – datetime.datetime time
- qtt.data.get_dataset(dataset_handle)[source]
Get a dataset from a results dictionary, a string or a dataset.
- class qtt.data.image_transform(dataset=None, arrayname=None, mode='pixel', unitsperpixel=None, verbose=0)[source]
Bases:
object- matplotlib_image_extent()[source]
Return matplotlib style image extent
- Returns:
- x1, x2, y1, y2
the y1 value is bottom left
- Return type:
extentImage (4 floats)
- pixel2scan(pt)[source]
Convert pixels coordinates to scan coordinates (mV) :param pt: points in pixel coordinates (x,y) :type pt: array
- Returns:
ptx (array)
- Return type:
point in scan coordinates (sweep, step)
- scan2pixel(pt)[source]
Convert scan coordinates to pixel coordinates :param pt: points in scan coordinates :type pt: array :param Returns: ptpixel (ndaray): points in pixel coordinates
- qtt.data.load_dataset(location, io=None, verbose=0)[source]
Load a dataset from storage
An attempt is made to automatically detect the formatter. Supported are currently qcodes GNUPlotFormat, qcodes HDF5Format and json format.
- Parameters:
location (str) – either the relative or full location
io (None or qcodes.data.io.DiskIO) –
- Returns:
dataset (DataSet or None)
- qtt.data.load_example_dataset(filename: str, verbose: int = 0) DataSet | None[source]
Return an example dataset from qtt
- Parameters:
filename – Name of the dataset
verbose – Verbosity level
- Returns:
Example dataset or None of no dataset can be found
- qtt.data.makeDataSet1D(p, yname='measured', y=None, location=None, loc_record=None, return_names=False)[source]
Make DataSet with one or multiple 1D arrays and one setpoint array.
- Parameters:
p (qcodes.SweepFixedValues) – the setpoint array of data
yname (str or list of str or Parameter or list of Parameter) – when type is str or list of str : the name of measured array(s) when type is parameter or list of parameter: the measured Parameters
y (array or list of array or None) – optional (measured) data to fill the DataSet
location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.
loc_record (dict or None) – If location is a callable, this will be passed to it as record.
return_names (bool) – if True return array names in output
- Raises:
See _make_data_set for the ValueError and TypeError exceptions that can be raised –
See _check_parameter for the TypeError exceptions that can be raised –
- Returns:
- Depending on parameter return_names
True: The resulting dataset and a tuple with the names of the added arrays (setpoint and measurements). False: The resulting dataset.
- qtt.data.makeDataSet1Dplain(xname, x, yname, y=None, xunit=None, yunit=None, location=None, loc_record=None)[source]
Make DataSet with one 1D array and one setpoint array
- Parameters:
xname (string) – the name of the setpoint array
x (array or ndarray or list) – the setpoint data
yname (str or qcodes.Parameter or list) – the name of the measured array
y (array or ndarray or list) – the measured data
xunit (str or None) – optional, the unit of the values stored in x array.
yunit (str or None) – optional, the unit of the values stored in y array.
location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.
loc_record (dict or None) – If location is a callable, this will be passed to it as record.
- Raises:
See _make_data_set for the ValueError and TypeError exceptions that can be raised –
- Returns:
The resulting dataset.
- qtt.data.makeDataSet2D(p1, p2, measure_names='measured', location=None, loc_record=None, preset_data=None, return_names=False)[source]
Make DataSet with one or multiple 2D array and two setpoint arrays.
If the preset_data is used for multiple 2D arrays, then the order of measure_names should match the order of preset_data.
- Parameters:
p1 (qcodes.SweepFixedValues) – first setpoint array of data
p2 (qcodes.SweepFixedValues) – second setpoint array of data
location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.
loc_record (dict or None) – If location is a callable, this will be passed to it as record.
preset_data (array or ndarray or list or None) – optional array to fill the DataSet
return_names (bool) – if True return array names in output
- Raises:
See _make_data_set for the ValueError and TypeError exceptions that can be raised –
See _check_parameter for the TypeError exceptions that can be raised –
- Returns:
True: The resulting dataset and a tuple with the names of the added arrays (setpoint and measurements). False: The resulting dataset.
- Return type:
Depending on parameter return_names
- qtt.data.makeDataSet2Dplain(xname, x, yname, y, zname='measured', z=None, xunit=None, yunit=None, zunit=None, location=None, loc_record=None)[source]
Make DataSet with one 2D array and two setpoint arrays
- Parameters:
xname (string) – the name of the setpoint x array.
x (array or ndarray or list) – the x setpoint data.
yname (string) – the name of the setpoint y array.
y (array or ndarray or list) – the y setpoint data.
zname (str or list of str) – the name of the measured array.
z (array or list or None) – optional the measured data.
xunit (str or None) – optional, the unit of the values stored in x.
yunit (str or None) – optional, the unit of the values stored in y.
zunit (str or None) – optional, the unit of the measured data.
location (str, callable, bool or None) – If you provide a string, it must be an unused location in the io manager. Can also be: - a callable location provider with one required parameter (the io manager), and one optional (record dict), which returns a location string when called. - False - denotes an only-in-memory temporary DataSet.
loc_record (dict or None) – If location is a callable, this will be passed to it as record.
- Raises:
See _make_data_set for the ValueError and TypeError exceptions that can be raised –
- Returns:
The resulting dataset.
- qtt.data.plot_dataset(dataset: DataSet, parameter_names: list | None = None, fig: int | None = 1) None[source]
Plot a dataset to matplotlib figure window
- Parameters:
dataset – DataSet to be plotted
parameter_names – List of arrays to be plotted
fig – Specification if Matplotlib figure window
- qtt.data.show2D(dd, impixel=None, im=None, fig=101, verbose=1, dy=None, sigma=None, colorbar=False, title=None, midx=2, units=None)[source]
Show result of a 2D scan
- Parameters:
dd (DataSet) –
impixel (array or None) –
im (array or None) –
qtt.dataset_processing module
- qtt.dataset_processing.average_dataset(dataset: DataSet, axis: str | int = 'vertical') DataSet[source]
Calculate the mean signal of a 2D dataset over the specified axis
- Parameters:
dataset – DataSet to be processed
axis – Specification of the axis
- Returns:
Dataset with averaged signal
- qtt.dataset_processing.average_multirow_dataset(dataset: DataSet, number_of_repetitions: int, new_values=None, parameter_name: str = 'signal', output_parameter_name: str = 'signal') DataSet[source]
Calculate the averaged signal from a 2D dataset with repeated rows
- Parameters:
dataset – Dataset containing the data to be averaged
number_of_repetitions – Number of rows over which to average
new_values – Optional new values for the averaged axis
parameter_name – Name of data array to process
output_parameter_name – Name of output array
- Returns:
Averaged dataset
- qtt.dataset_processing.process_dataarray(dataset: DataSet, input_array_name: str, output_array_name: str | None, processing_function: Callable, label: str | None = None, unit: str | None = None) DataSet[source]
Apply a function to a DataArray in a DataSet
- Parameters:
dataset – Input dataset containing the data array
input_array_name – Name of the data array to be processed
output_array_nane – Name of the output array or None to operate in place
processing_function – Method to apply to the data array
label – Label for the output array
unit – Unit for the output array
- qtt.dataset_processing.resample_dataset(dataset: DataSet, sample_rate: Tuple[int], copy_metadata: bool = False, output_parameter_name: str | None = None) DataSet[source]
Given a dataset resample the measurement array
- Parameters:
dataset – Dataset to be slice
sample_rate – Tuple with for each axis the sample rate. Must be a postive integer
copy_metadata – If True then copy the metadata of the input dataset
output_parameter_name – Name of the output array
- Returns:
Dataset with sliced data
- qtt.dataset_processing.slice_dataset(dataset: DataSet, window: Sequence[float], axis: int = 0, verbose: int = 0, copy_metadata: bool = False, output_parameter_name=None) DataSet[source]
Given a dataset and a window for the horizontal axis return the dataset with selected window
- Parameters:
dataset – Dataset to be slice
window – Specification of the window to be selected
axis – Axis used for slicing
verbose – Verbosity level
copy_metadata – If True then copy the metadata of the input dataset
output_parameter_name – Name of the output array
- Returns:
Dataset with sliced data
qtt.exceptions module
- exception qtt.exceptions.CalibrationException[source]
Bases:
ExceptionException thrown for a bad calibration
- exception qtt.exceptions.MissingOptionalPackageWarning[source]
Bases:
UserWarning,ValueErrorAn optional package is missing
- exception qtt.exceptions.PackageVersionWarning[source]
Bases:
UserWarningA package has the incorrect version
qtt.pgeometry module
pgeometry
A collection of usefull functions.
For additional options also see numpy and matplotlib.
- platform:
Unix, Windows
- Additions:
Copyright 2012-2016 TNO
- Original code:
Copyright 2011 Pieter Eendebak <pieter.eendebak@gmail.com>
@author: eendebakpt
- qtt.pgeometry.T2opencv(T: ndarray) Tuple[ndarray, ndarray][source]
Convert transformation to OpenCV rvec, tvec pair
Example
>>> rvec, tvec = T2opencv(np.eye(4))
- qtt.pgeometry.addfigurecopy(fig=None)[source]
Add callback to figure window
By pressing the ‘c’ key figure is copied to the clipboard
- qtt.pgeometry.angleDiff(x, y)[source]
Return difference between two angles in radians modulo 2* pi
>>> d=angleDiff( 0.01, np.pi+0.02) >>> d=angleDiff( 0.01, 2*np.pi+0.02) >>> d=angleDiff(np.array([0,0,0]), np.array([2,3,4]))
- qtt.pgeometry.angleDiffOri(x, y)[source]
Return difference between two angles in radians modulo pi
>>> d=angleDiff( 0.01, np.pi+0.02) >>> d=angleDiff( 0.01, 2*np.pi+0.02)
- qtt.pgeometry.auto_canny(image: ndarray, sigma: float = 0.33) ndarray[source]
Canny edge detection with automatic parameter detection
>>> imc=auto_canny(np.zeros( (200,300)).astype(np.uint8))
- Parameters:
image (array) – input image
- Returns:
edged – detected edges
- Return type:
array
- qtt.pgeometry.blur_measure(im, verbose=0)[source]
Calculate bluriness for an image
- Parameters:
im (array) – input image
- qtt.pgeometry.breakLoop(wk=None, dt=0.001, verbose=0)[source]
Break a loop using OpenCV image feedback
- qtt.pgeometry.cfigure(*args, **kwargs)[source]
Create Matplotlib figure with copy to clipboard functionality
By pressing the ‘c’ key figure is copied to the clipboard
- qtt.pgeometry.checkmodule(module_name, verbose=1)[source]
Return location of module based on module name
- Parameters:
module_name (str) – name of module to inspect
- Returns
obj: module specification
- qtt.pgeometry.choose(n, k)[source]
Binomial coefficients Return the n!/((n-k)!k!)
- Parameters:
Integer (k --) –
Integer –
- Returns:
The bionomial coefficient n choose k
Example
>>> choose(6,2) 15
- qtt.pgeometry.circular_mean(weights, angles)[source]
Calculate circular mean of a set of 2D vectors
- qtt.pgeometry.decomposeProjectiveTransformation(H, verbose=0)[source]
Decompose projective transformation H is decomposed as H = Hs*Ha*Hp with
- Hs = [sR t]
[0 1]
- Ha = [K 0]
[0 1]
- Hp = [I 0]
[v’ eta]
If H is 3-dimensional, then R = [ cos(phi) -sin(phi); sin(phi) cos(phi)];
For more information see “Multiple View Geometry”, paragraph 1.4.6.
>>> Ha, Hs, Hp, rest = decomposeProjectiveTransformation( np.eye(3) )
- qtt.pgeometry.detect_local_minima(arr, thr=None)[source]
Takes an array and detects the troughs using the local maximum filter. Returns a boolean mask of the troughs (i.e. 1 when the pixel’s value is the neighborhood maximum, 0 otherwise)
- Parameters:
arr (array) – input array
- qtt.pgeometry.dir2R(d, a=None)[source]
Convert direction to rotation matrix
Note: numerically not stable near singular points!
- Parameters:
d (numpy array of size 3) – direction to rotation to a
a (numpy array of size 3) – target direction
- Returns:
matrix R such that R*a = d
- Return type:
R (3x3 numpy array)
Example:
>>> d = np.array([0, 1, 0]); a = np.array([0, -1, 0]) >>> R = dir2R(d, a)
Pieter Eendebak <pieter.eendebak@tno.nl>
- qtt.pgeometry.directionMean(vec)[source]
Calculate the mean of a set of directions
The initial direction is determined using the oriented direction. Then a non-linear optimization is done.
- Parameters:
vec – List of directions
- Returns
Angle of mean of directions
>>> vv=np.array( [[1,0],[1,0.1], [-1,.1]]) >>> a=directionMean(vv)
- qtt.pgeometry.enlargelims(factor=1.05)[source]
Enlarge the limits of a plot
Example
>>> enlargelims(1.1)
- qtt.pgeometry.euler2RBE(theta)[source]
Convert Euler angles to rotation matrix
Example
>>> np.set_printoptions(precision=4, suppress=True) >>> euler2RBE( [0,0,np.pi/2] ) array([[ 0., -1., 0.], [ 1., 0., 0.], [-0., 0., 1.]])
- qtt.pgeometry.findImageHandle(fig, verbose=0, otype=<class 'matplotlib.image.AxesImage'>)[source]
Search for specific type of object in Matplotlib figure
- qtt.pgeometry.findfilesR(p, patt, show_progress=False)[source]
Get a list of files (recursive)
- Parameters:
p (string) – directory
patt (string) – pattern to match
show_progress (bool) –
- Returns:
lst (list of str)
- qtt.pgeometry.fitPlane(X: ndarray) ndarray[source]
Determine plane going through a set of points
- Parameters:
X (array) – aray of size Nxk. Points in affine coordinates
- Returns:
fitted plane in homogeneous coordinates
- Return type:
array
Example
>>> X=np.array([[1,0,0 ], [0,1,0], [1,1,0], [2,2,0]]) >>> t=fitPlane(X)
- class qtt.pgeometry.fps_t(nn: int = 40)[source]
Bases:
object- addtime(t: float | None = None, x: float = 0)[source]
Add a timestamp to the object
- Parameters:
t – Timestamp. If None, use time.perf_counter
x – Optional value to store with the timestamp
- qtt.pgeometry.freezeclass(cls)[source]
Decorator to freeze a class
This means that no attributes can be added to the class after instantiation.
- qtt.pgeometry.gaborFilter(ksize, sigma, theta, Lambda=1, psi=0, gamma=1, cut=None)[source]
Create a Gabor filter of specified size
- Parameters:
ksize (integer) – kernel size in pixels
sigma (float) – parameters of Gabor function
theta (float) – parameters of Gabor function
Lambda (float) – parameters of Gabor function
psi (float) – parameters of Gabor function
cut (boolean) – if True cut off the angular component after specified distance (in radians)
- Returns:
g – constructed kernel
- Return type:
array
Example
>>> g = gaborFilter(ksize=15, sigma=2,theta=2,Lambda=1, gamma=1)
- qtt.pgeometry.ginput(n=1, drawmode='', **kwargs)[source]
Select points from figure
Press middle mouse button to stop selection
- Parameters:
select (n - number of points to) –
points (drawmode - style to plot selected) –
kwargs – arguments passed to plot function
- qtt.pgeometry.histogram(x, nbins=30, fig=1)[source]
Return histogram of data
>>> _=histogram(np.random.rand(1,100))
- qtt.pgeometry.hom(x: ndarray) ndarray[source]
Create affine to homogeneous coordinates
- Parameters:
x (kxN array) – affine coordinates
- Returns:
homogeneous coordinates
- Return type:
h ( (k+1xN) array)
- qtt.pgeometry.intersect2lines(l1, l2)[source]
Calculate intersection between 2 lines
- Parameters:
l1 (array) – first line in homogeneous format
l2 (array) – first line in homogeneous format
- Returns:
intersection in homogeneous format. To convert to affine coordinates use dehom
- Return type:
array
- qtt.pgeometry.list_objects(objectype=None, objectclassname='__123', verbose=1)[source]
List all objects in memory of a specific type or with a specific class name
- qtt.pgeometry.logistic(x, x0=0, alpha=1)[source]
Simple logistic function
- Parameters:
x (float or array) –
>>> t=np.arange(0,600,1.) >>> _ = plt.plot(t, logistic(t, 300, alpha=1./100),'.b')
- qtt.pgeometry.minAlg_5p4(A: ndarray) ndarray[source]
Algebraic minimization function
Function computes the vector x that minimizes ||Ax|| subject to the condition ||x||=1. Implementation of Hartley and Zisserman A5.4 on p593 (2nd Ed)
Usage: [x,V] = minAlg_5p4(A) :param A: The constraint matrix, ||Ax|| to be minimized :type A: numpy array
- Returns:
- x - The vector that minimizes ||Ax|| subject to the
condition ||x||=1
- qtt.pgeometry.mkdirc(d: str)[source]
Similar to mkdir, but no warnings if the directory already exists
- qtt.pgeometry.monitorSizes(verbose: int = 0) List[List[int]][source]
Return monitor sizes
- Parameters:
verbose – Verbosity level
- Returns:
List with for each screen a list x, y, width, height
- qtt.pgeometry.mpl2clipboard(event=None, verbose: int = 0, fig: int | Figure | None = None)[source]
Copy current Matplotlib figure to clipboard
- Parameters:
event – Unused argument
verbose – Verbosity level
fig – Figure handle. If None, select the current figure
- qtt.pgeometry.opencv_draw_points(bgr, imgpts, drawlabel=True, radius=3, color=(255, 0, 0), thickness=-1, copyimage=True)[source]
Draw points on image with opencv
- Parameters:
bgr (numpy array) – image to draw points into
impts (array) – locations of points to plot
- qtt.pgeometry.orthogonal_proj(zfront, zback)[source]
see http://stackoverflow.com/questions/23840756/how-to-disable-perspective-in-mplot3d
- qtt.pgeometry.otsu(im, fig=None)[source]
Calculate threshold on data using Otsu’s method
- Parameters:
im (array) – data to be processed
fig (number, optional) – If set to a number show results in a histogram
- Returns:
thr – The threshold value
- Return type:
Examples
>>> thr = otsu(np.random.rand( 2000), fig=100)
- qtt.pgeometry.pcolormesh_centre(x, y, im, *args, **kwargs)[source]
Wrapper for pcolormesh to plot pixel centres at data points
- qtt.pgeometry.pg_rotx(phi: float) ndarray[source]
Create rotation around the x-axis with specified angle
- qtt.pgeometry.pg_scaling(scale: float | ndarray, cc: ndarray | None = None) ndarray[source]
Create scale transformation with specified centre
- Parameters:
scale – Scaling vector
cc – Centre for the scale transformation. If None, then take the origin
- Returns:
Scale transformation
Example
>>> pg_scaling( [1.,2]) array([[ 1., 0., 0.], [ 0., 2., 0.], [ 0., 0., 1.]])
- qtt.pgeometry.pg_transl2H(tr)[source]
Convert translation to homogeneous transform matrix
>>> pg_transl2H( [1,2]) array([[ 1., 0., 1.], [ 0., 1., 2.], [ 0., 0., 1.]])
- qtt.pgeometry.plot2Dline(line, *args, **kwargs)[source]
Plot a 2D line in a matplotlib figure
- Parameters:
line (3x1 array) – line to plot
>>> plot2Dline([-1,1,0], 'b')
- class qtt.pgeometry.plotCallback(func=None, xdata=None, ydata=None, scale=[1, 1], verbose=0)[source]
Bases:
object
- qtt.pgeometry.plotCostFunction(fun, x0, fig=None, marker='.', scale=1, c=None)[source]
Plot a cost function on specified data points
Example with variation of Booth’s function:
>>> fun = lambda x: 2*(x[0]+2*x[1]-7)**2 + (2*x[0]+x[1]-5)**2 >>> plotCostFunction(fun, np.array([1,3]), fig=100, marker='-')
- qtt.pgeometry.plotLabels(xx, *args, **kwargs)[source]
Plot labels next to points
- Parameters:
xx (2xN array) – points to plot
*kwargs – arguments past to plotting function
Example: >>> xx=np.random.rand(2, 10) >>> fig=plt.figure(10); plt.clf() >>> _ = plotPoints(xx, ‘.b’); _ = plotLabels(xx)
- qtt.pgeometry.plotPoints(xx, *args, **kwargs)[source]
Plot 2D or 3D points
- Parameters:
xx (array) – array of points to plot
*args – arguments passed to the plot function of matplotlib
**kwargs – arguments passed to the plot function of matplotlib
Example: >>> plotPoints(np.random.rand(2,10), ‘.-b’)
- qtt.pgeometry.plotPoints3D(xx, *args, **kwargs)[source]
Plot 3D points
- Parameters:
xx (3xN array) – the 3D data points
Example
>> ax=plotPoints3D(np.random.rand(3, 1) ,’.r’, markersize=10, fig=12)
- qtt.pgeometry.point_in_polygon(pt, pp)[source]
Return True if point is in polygon
- Parameters:
pt (1x2 array) – point
pp (Nx2 array) – polygon
- Returns:
1.0 if point is inside 1.0, otherwise -1.0
- Return type:
r (float)
- qtt.pgeometry.points_in_polygon(pts, pp)[source]
Return all points contained in a polygon
- Parameters:
pt (Nx2 array) – points
pp (Nxk array) – polygon
- Returns:
rr (bool array)
- qtt.pgeometry.polyarea(p: List[List[float]] | ndarray) float[source]
Return signed area of polygon
- Parameters:
p (Nx2 numpy array or list of vertices) – vertices of polygon
- Returns:
area – area of polygon
- Return type:
>>> polyarea( [ [0,0], [1,0], [1,1], [0,2]] ) 1.5
- qtt.pgeometry.polyintersect(x1: ndarray, x2: ndarray) ndarray[source]
Calculate intersection of two polygons
- Parameters:
x1 – First polygon. Shape is (N, 2) with N the number of vertices
x2 – Second polygon
- Returns:
Intersection of both polygons
- Raises:
ValueError if the intersection consists of multiple polygons –
>>> x1=np.array([(0, 0), (1, 1), (1, 0)] ) >>> x2=np.array([(1, 0), (1.5, 1.5), (.5, 0.5)]) >>> x=polyintersect(x1, x2) >>> _=plt.figure(10); plt.clf() >>> plotPoints(x1.T, '.:r' ) >>> plotPoints(x2.T, '.:b' ) >>> plotPoints(x.T, '.-g' , linewidth=2)
- qtt.pgeometry.projectiveTransformation(H: ndarray, x: ndarray) ndarray[source]
Apply a projective transformation to a kxN array
>>> y = projectiveTransformation( np.eye(3), np.random.rand( 2, 10 ))
- qtt.pgeometry.robustCost(x: ndarray, thr: float | str | None, method: str = 'L1') ndarray | List[str][source]
Robust cost function
- Parameters:
x – data to be transformed
thr – threshold. If None then the input x is returned unmodified. If ‘auto’ then use automatic detection (at 95th percentile)
method – method to be used. use ‘show’ to show the options
- Returns:
Cost for each element in the input array
Example
>>> robustCost([2, 3, 4], thr=2.5) array([ 2. , 2.5, 2.5]) >>> robustCost(2, thr=1) 1 >>> methods=robustCost(np.arange(-5,5,.2), thr=2, method='show')
- qtt.pgeometry.rot2D(phi: float) ndarray[source]
Return 2x2 rotation matrix from angle
- Parameters:
phi (float) – Angle in radians
- Returns:
R – The 2x2 rotation matrix
- Return type:
array
Examples
>>> R = rot2D(np.pi)
- qtt.pgeometry.save(pkl_file, *args)[source]
Save objects to file
- Parameters:
pkl_file (string) – filename
*args (anything) – Python objects to save
- qtt.pgeometry.scaleImage(image: ndarray, display_min: float | None = None, display_max: float | None = None) ndarray[source]
Scale any image into uint8 range
- Parameters:
image – input image
display_min – value to map to min output range
display_max – value to map to max output range
- Returns:
The scaled image
Example
>>> im=scaleImage(255*np.random.rand( 30,40), 40, 100)
Code modified from: https://stackoverflow.com/questions/14464449/using-numpy-to-efficiently-convert-16-bit-image-data-to-8-bit-for-display-with?noredirect=1&lq=1
- qtt.pgeometry.setFontSizes(labelsize=20, fsize=17, titlesize=None, ax=None)[source]
Update font sizes for a matplotlib plot
- qtt.pgeometry.setWindowRectangle(x: int | Sequence[int], y: int | None = None, w: int | None = None, h: int | None = None, fig: int | None = None, mngr=None)[source]
Position the current Matplotlib figure at the specified position
- Parameters:
x – position in format (x,y,w,h)
y – y position, width, height
w – y position, width, height
h – y position, width, height
fig (None or int) – specification of figure window. Use None for the current active window
Usage: setWindowRectangle([x, y, w, h]) or setWindowRectangle(x, y, w, h)
- qtt.pgeometry.setregion(im, subim, pos, mask=None, clip=False)[source]
Set region in Numpy image
- Parameters:
im (Numpy array) – image to fill region in
subim (Numpy array) – subimage
pos (array) – position to place image
array) (mask (None or) –
(bool) (clip) –
- qtt.pgeometry.signedmin(val, w)[source]
Signed minimum value function
>>> signedmin(-3, 5) -3 >>> signedmin(-10, 5) -5
- qtt.pgeometry.signedsqrt(val)[source]
Signed square root function
>>> signedsqrt([-4.,4,0]) array([-2., 2., 0.]) >>> signedmin(-10, 5) -5
- qtt.pgeometry.smoothstep(x, x0=0, alpha=1)[source]
Smooth step function
>>> t=np.arange(0,600,1.) >>> _ = plt.plot(t, smoothstep(t, 300, alpha=1./100),'.b')
- qtt.pgeometry.static_var(varname: str, value: Any)[source]
Helper function to create a static variable on a method
- Parameters:
varname – Variable to create
value – Initial value to set
- qtt.pgeometry.tilefigs(lst, geometry=[2, 2], ww=None, raisewindows=False, tofront=False, verbose=0, monitorindex=None)[source]
Tile figure windows on a specified area
- Parameters:
lst (list) – list of figure handles or integers
geometry (2x1 array) – layout of windows
int) (monitorindex (None or) –
list) (ww (None or) –
- qtt.pgeometry.tprint(string: str, dt: float = 1, output: bool = False, tag: str = 'default') bool | None[source]
Print progress of a loop every dt seconds
- Parameters:
string – text to print
dt – delta time in seconds
output – if True return whether output was printed or not
tag – optional tag for time
- Returns:
Output (bool) or None
qtt.structures module
Contains code for various structures
- class qtt.structures.CombiParameter(name, params, label=None, unit='a.u.', **kwargs)[source]
Bases:
ParameterCreate a parameter which is a combination of multiple other parameters, which are always set to the same value.
The get function returns the mean of the individual parameters.
- 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.
- 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.
- class qtt.structures.MultiParameter(name, params, label=None, unit=None, **kwargs)[source]
Bases:
ParameterCreate a parameter which is a combination of multiple other parameters.
- 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.
- set_raw(values)[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.
- class qtt.structures.VectorParameter(name, comb_map, **kwargs)[source]
Bases:
ParameterCreate parameter which controls linear combinations.
- class qtt.structures.onedot_t(gates, name=None, data=None, station=None, transport_instrument=None)[source]
Bases:
dictClass representing a single quantum dot
- class qtt.structures.sensingdot_t(gate_names, gate_values=None, station=None, index=None, minstrument=None, virt_gates=None)[source]
Bases:
object- autoTune(scanjob=None, fig=200, outputdir=None, step=-2.0, max_wait_time=1.0, scanrange=300, add_slopes=False)[source]
Automatically determine optimal value of plunger
- detuning_scan(stepsize=2, nsteps=5, verbose=1, fig=None)[source]
Optimize the sensing dot by making multiple plunger scans for different detunings
- fastTune(Naverage=90, sweeprange=79, period=0.001, location=None, fig=201, sleeptime=2, delete=True, add_slopes=False, invert=False, verbose=1)[source]
Fast tuning of the sensing dot plunger.
If the sensing dot object is initialized with a virtual gates object the virtual plunger will be used for the sweep.