From 8bcd4978349c708da93a91514f736def50c015e5 Mon Sep 17 00:00:00 2001 From: Stephan Philips <s.g.j.philips@tudelft.nl> Date: Thu, 9 Jul 2020 10:28:03 +0200 Subject: [PATCH] =?UTF-8?q?=C3=BApdates?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../calibrations/calib_examples/SD_cal.py | 35 +++++++++ .../calib_examples/fit_functions.py | 0 .../calib_examples/run_example.py | 0 .../calib_examples/transition_line_detct.py | 24 ++++++ .../calib_examples/virtual_station.py | 0 .../calibrations/calibration_single.py | 29 +++++--- .../job_mgnt/calibrations/sample_layout.py | 57 -------------- core_tools/job_mgnt/calibrations/utility.py | 74 +++++++++++++++++++ 8 files changed, 153 insertions(+), 66 deletions(-) create mode 100644 core_tools/job_mgnt/calibrations/calib_examples/SD_cal.py create mode 100644 core_tools/job_mgnt/calibrations/calib_examples/fit_functions.py create mode 100644 core_tools/job_mgnt/calibrations/calib_examples/run_example.py create mode 100644 core_tools/job_mgnt/calibrations/calib_examples/transition_line_detct.py create mode 100644 core_tools/job_mgnt/calibrations/calib_examples/virtual_station.py delete mode 100644 core_tools/job_mgnt/calibrations/sample_layout.py create mode 100644 core_tools/job_mgnt/calibrations/utility.py diff --git a/core_tools/job_mgnt/calibrations/calib_examples/SD_cal.py b/core_tools/job_mgnt/calibrations/calib_examples/SD_cal.py new file mode 100644 index 00000000..76debf7f --- /dev/null +++ b/core_tools/job_mgnt/calibrations/calib_examples/SD_cal.py @@ -0,0 +1,35 @@ +from core_tools.job_mgnt.calibrations.calibration_single import calibration_generic, CalibrationError +from core_tools.job_mgnt.calibrations.utility import param_mngr + +from core_tools.GUI.keysight_videomaps.data.scan_generator_Virtual import construct_1D_scan_fast + +SD_gates = {'SD_1':'SD1_P', 'SD_2':'SD2_P', 'SD_2':'SD2_P'} + +class SD_cal(calibration_generic): + def __init__(self): + self.update_interval = 30 + self.auto_update = True + + self.getter = param_mngr('SD', unit='mV') + SL.SD + + def calibrate(self): + for param in getter: + SD_gate = SD_gates[param.name] + + # construct global cal_mgmt --> enable RF readout at dot 1 + CAL_MGRG.rf_readout(['dot_1'], enable=True) + + scan_obj = construct_1D_scan_fast(SD_gate, swing=5, n_pt=100, t_step=5, biasT_corr=10, pulse_lib, digitizer) + fit_voltage = fit_SD(scan_obj) + + if abs(fit_voltage) < 2: + SD_gate_dc = self.station.gates.getattr() + SD_gate_dc.(SD_gate_dc.get + fit_voltage) + + self.save_data(param, SD_gate_dc(), state=self.SUCCESS) + else: + self.save_data(param, state=self.FAIL) + raise CalibrationError('finding most sensitive spot of SD failed.') + + # repeat 3 times to move toward (in case there is a slight mismatch between DC/AC conversion) + self.reiterate(3) \ No newline at end of file diff --git a/core_tools/job_mgnt/calibrations/calib_examples/fit_functions.py b/core_tools/job_mgnt/calibrations/calib_examples/fit_functions.py new file mode 100644 index 00000000..e69de29b diff --git a/core_tools/job_mgnt/calibrations/calib_examples/run_example.py b/core_tools/job_mgnt/calibrations/calib_examples/run_example.py new file mode 100644 index 00000000..e69de29b diff --git a/core_tools/job_mgnt/calibrations/calib_examples/transition_line_detct.py b/core_tools/job_mgnt/calibrations/calib_examples/transition_line_detct.py new file mode 100644 index 00000000..6c65735f --- /dev/null +++ b/core_tools/job_mgnt/calibrations/calib_examples/transition_line_detct.py @@ -0,0 +1,24 @@ +from core_tools.job_mgnt.calibrations.calibration_single import calibration_generic, CalibrationError +from core_tools.job_mgnt.calibrations.utility import param_mngr + +from core_tools.GUI.keysight_videomaps.data.scan_generator_Virtual import construct_1D_scan_fast + +SD_gates = {'SD_1':'SD1_P', 'SD_2':'SD2_P', 'SD_2':'SD2_P'} + +class SD_cal(calibration_generic): + @dataclass + class SD_data: + v_peak : float + v_off : float + sigma : float + amp : float + _units = {'v_peak'='mV', 'v_off' = 'mV', 'sigma' = 'mV', 'amp' = 'mV'} + + def __init__(self): + self.update_interval = 30 + self.auto_update = True + + self.getter = param_mngr('transition_line_lock_P', unit='mV') + SL.dots + SD_data + + def calibrate(self, param): + pass diff --git a/core_tools/job_mgnt/calibrations/calib_examples/virtual_station.py b/core_tools/job_mgnt/calibrations/calib_examples/virtual_station.py new file mode 100644 index 00000000..e69de29b diff --git a/core_tools/job_mgnt/calibrations/calibration_single.py b/core_tools/job_mgnt/calibrations/calibration_single.py index ddb2e825..6f9388d5 100644 --- a/core_tools/job_mgnt/calibrations/calibration_single.py +++ b/core_tools/job_mgnt/calibrations/calibration_single.py @@ -1,5 +1,5 @@ from calibration_data import data_mgr - +import qcodes as qc class CalibrationError(Exception): pass @@ -21,17 +21,23 @@ def calibration_wrapper(cls, function): return run_function class calibration_generic(): - def __init__(self): + FAIL = 0 + SUCCES = 1 + station = qc.Station.default + + def __new__(self): self.update_interval = 0 # 0 for do not update self.auto_update = False # automatically rerun the last calibration after the update intercal exceeded self.prioritize = True # first calibration or first measurement self.dependencies = dep_mgr() - self.data_mgr = data_mgr() + self.data_mgr = data_mgr(self, 'todo') # iteration variables self._N_rep = 0 self._n = 0 + return self + def get_data(self, parameters ,set_vals = dict()): self.data_mgr.get(set_vals) @@ -40,15 +46,20 @@ class calibration_generic(): def reiterate(self, N=1): ''' - call this function in the + call this function in to reiterature the same calibration N times. ''' self._N_rep = N+1 self._n = 0 - - - -def ExampleCal(calibration_generic): +class ExampleCal(calibration_generic): def __init__(self): self.dependencies += my_cals.readout_of_dot_1 - self.dependencies += (my_cals.readout_of_dot_2, my_cals.tc_res) \ No newline at end of file + self.dependencies += (my_cals.readout_of_dot_2, my_cals.tc_res) + + self.setters = ... + self.getters = ... + +if __name__ == '__main__': + test = ExampleCal() + print(test) + print(test.update_interval) \ No newline at end of file diff --git a/core_tools/job_mgnt/calibrations/sample_layout.py b/core_tools/job_mgnt/calibrations/sample_layout.py deleted file mode 100644 index 4dbace25..00000000 --- a/core_tools/job_mgnt/calibrations/sample_layout.py +++ /dev/null @@ -1,57 +0,0 @@ -from typing import Union -import numpy as np - - -class SampleLayoutField(): - # formatter for a single field of the sample layout class - def __init__(self, std_field_name = '', input_names = tuple()): - ''' - Args: - std_field_name (str) : standard name to append before the input name - input_names (tuple<str>) : input names - ''' - self.variable_names = list() - self.std_field_name = '_' if std_field_name == '' else "_" + std_field_name + '_' - self += input_names - - def __add__(self, other): - if isinstance(other, Union[str, int, float].__args__): - return self + [other] - - if isinstance(other, Union[list, tuple, np.ndarray, range].__args__): - for var in other: - self.variable_names += [self.std_field_name + str(var)] - return self - raise ValueError('type not recognized?') - - def __radd__(self, other): - if isinstance(other, str): - return_var = tuple() - for var in self.variable_names: - return_var += (other + var,) - return return_var - - raise ValueError('type for adding not recognized. Only strings are supported') - -class MyExampleSampleLayout(): - def __init__(self): - self.qubits = SampleLayoutField('qubits') - self.qubit_pairs = SampleLayoutField() - self.res_barrier = SampleLayoutField() - self.n = SampleLayoutField() - self.SD = SampleLayoutField('SD') - - self.qubits += range(1,6) - self.qubit_pairs += (12,23,34,45) - self.res_barrier += (1,2) - self.n += range(1,6) - self.SD += range(1,3) - -if __name__ == '__main__': - # example usage of layout class - SL = MyExampleSampleLayout() - - print('FREQ' + SL.qubits) - print('J' + SL.qubit_pairs) - print('SD' + SL.SD) - print('tc_res' + SL.res_barrier) diff --git a/core_tools/job_mgnt/calibrations/utility.py b/core_tools/job_mgnt/calibrations/utility.py new file mode 100644 index 00000000..6423f0df --- /dev/null +++ b/core_tools/job_mgnt/calibrations/utility.py @@ -0,0 +1,74 @@ +from typing import Union +import numpy as np + +from qcodes import Parameter + +class param_mngr(list): + ''' + mangagment class for parameters, allows for easy extending of multiple param if needed. + ''' + def __init__(self,name, unit='a.u.'): + super().__init__() + + param = Parameter(name, label=name, unit=unit) + self.base_param = param + self.append(param) + + def __add__(self, other): + if isinstance(other, SampleLayoutField): + for i in other: + if self[0] == self.base_param: + self.pop(0) + name = self.base_param.name + i + self += [Parameter(name, label=name, unit=self.base_param.unit)] + else: + raise ValueError('please add up the type SampleLayoutField') + + return self + +class SampleLayoutField(list): + # formatter for a single field of the sample layout class + def __init__(self, std_field_name = '', input_names = list()): + ''' + Args: + std_field_name (str) : standard name to append before the input name + input_names (list<str>) : input names + ''' + super().__init__(input_names) + self.std_field_name = '_' if std_field_name == '' else "_" + std_field_name + '_' + + def __add__(self, other): + if isinstance(other, Union[str, int, float].__args__): + return self + [other] + + if isinstance(other, Union[list, tuple, np.ndarray, range].__args__): + for var in other: + self.append(self.std_field_name + str(var)) + return self + raise ValueError('type not recognized?') + + def __iadd__(self, other): + return self.__add__(other) + +class MyExampleSampleLayout(): + def __init__(self): + self.qubits = SampleLayoutField('qubits') + self.qubit_pairs = SampleLayoutField() + self.res_barrier = SampleLayoutField() + self.n = SampleLayoutField() + self.SD = SampleLayoutField('SD') + + self.qubits += range(1,6) + self.qubit_pairs += (12,23,34,45) + self.res_barrier += (1,2) + self.n += range(1,6) + self.SD += range(1,3) + +if __name__ == '__main__': + # example usage of layout class + SL = MyExampleSampleLayout() + + # use in combination with param manager to easily generate paramter object. + FREQ = param_mngr('FREQ', 'Hz') + SL.qubits + for f in FREQ: + print(f) -- GitLab