def runDevices(qubits, wave_AWG, wave_readout): qContext = qubitContext() # qas = qContext.get_servers_group('qa') qa = qContext.get_server('qa', 'qa_1') # send data packet to multiply devices qa.send_waveform(waveform=wave_readout) hds = qContext.get_servers_group('hd') qubits_port = qContext.getPorts(qubits) awg_waves = AWG_wave_dict(qubits_port, wave_AWG) for (dev_name, awg_index), wave in awg_waves.items(): hd = hds[dev_name] hd.send_waveform(waveform=wave, awg_index=awg_index) hd.awg_open(awgs_index=[awg_index]) qa.awg_open() # download experimental data _data = qa.get_data() if qa.source == 7: # single channels return _data else: # double channels ks = range(int(len(_data) / 2)) def get_doubleChannel(k): return _data[2 * k] + 1j * _data[2 * k + 1] data_doubleChannel = list(map(get_doubleChannel, ks)) return data_doubleChannel
def stop_device(): """ close all device; """ qContext = qubitContext() zurich_devices = qContext.get_servers_group(type='zurich').values() for server in zurich_devices: server.awg_close() uwave_source = qContext.get_server(type='microwave_source', name=None) uwave_source.stop_all() return
def connect_ZI(reset=False, user='******'): if reset: clear_singletonMany(zurichHelper.zurich_qa) clear_singletonMany(zurichHelper.zurich_hd) user_input = input(f"Enter user (default: {user})") or user sample = update_session(user=user_input) do_bringup = input("Skip Bringup? (enter 0 for skip, default 1)") or 1 if do_bringup != '0': qctx = qubitContext() qctx.refresh() return sample
def set_microwaveSource(freqList, powerList): """set frequency and power for microwaveSource devices """ qContext = qubitContext() server = qContext.get_server(type='microwave_source', name=None) IPdict = qContext.IPdict_microwave for i, key in enumerate(IPdict): server.select_device(IPdict[key]) server.output(True) server.frequency(freqList[i]['MHz']) server.amplitude(powerList[i]['dBm']) return
def RunAllExperiment(function, iterable, dataset, collect=True, raw=False, noisy=False): """ Define an abstract loop to iterate a funtion for iterable Example: prepare parameters: scanning axes, dependences and other parameters start experiment with special sequences according to the parameters Args: function: give special sequences, parameters iterable: iterated over to produce values that are fed to function as parameters. dataset: zilabrad.pyle.datasaver.Dataset, object for data saving collect: if True, collect the result into an array and return it; else, return an empty list raw: discard swept_paras if raw == True """ def run(paras): # pass in all_paras to the function all_paras = [Unit2SI(a) for a in paras[0]] swept_paras = [Unit2num(a) for a in paras[1]] # 'None' is just the old devices arg which is not used now result = function(None, all_paras) if raw: result_raws = np.asarray(result) return result_raws.T else: result = np.hstack([swept_paras, result]) return result def wrapped(): for paras in iterable: result = run(paras) if noisy is True: print(str(np.round(result, 3))) yield result gc_var = gc.collect() print(f"garbage collect {gc_var}") qContext = qubitContext() results = dataset.capture(wrapped()) resultArray = np.asarray(list(results)) if collect: return resultArray
def setupDevices(qubits): q_ref = qubits[0] # only run once in the whole experimental loop qContext = qubitContext() # qas = qContext.get_servers_group('qa') qa = qContext.get_server('qa', 'qa_1') if 'isNewExpStart' not in q_ref: print('isNewExpStart, setupDevices') qContext.refresh() setup_wiring(qContext) # int: sample number for one sweep point qa.set_result_samples(q_ref['stats']) # only related with wiring and devices, delay between QA # signal output and demodulation qa.set_readout_delay(q_ref['readout_delay']) # set qa pulse length in AWGs, and set same length for demodulate. qa.set_pulse_length(q_ref['readout_len']) # delay between zurich HD and QA qa.set_adc_trig_delay(q_ref['bias_start']['s'] + q_ref['experiment_length']) # set demodulate frequency for qubits if you need readout the qubit f_read = [] for qb in qubits: if qb.get('do_readout'): # in _q.keys(): f_read += [qb.demod_freq] if len(f_read) == 0: raise Exception('Must set one readout frequency at least') qa.set_qubit_frequency(f_read) q_ref['isNewExpStart'] = False # actually it can be arbitrary value else: # delay between zurich HD and QA # for example: in T1 measurement qa.set_adc_trig_delay(q_ref['bias_start']['s'] + q_ref['experiment_length']) return
def runQubits(qubits, exp_devices=None): """ generally for running multiqubits Args: qubits (list): a list of dictionary """ qContext = qubitContext() wave_readout = makeSequence_readout(qubits, FS=qContext.ADC_FS) wave_AWG = makeSequence_AWG(qubits, FS=qContext.DAC_FS) q_ref = qubits[0] # Now it is only two microwave sources, more should be covered # in the future set_microwaveSource( freqList=[q_ref['readout_mw_fc'], q_ref['xy_mw_fc']], powerList=[q_ref['readout_mw_power'], q_ref['xy_mw_power']]) setupDevices(qubits) data = runDevices(qubits, wave_AWG, wave_readout) return data
def correct_zero(sample): sample, qubits, Qubits = loadQubits(sample, write_access=True) qc = qubitContext() corr = qc.zero_correction for qubit in qubits: corr.correct_xy(qubit)