def test_incomplete_twoD(self): a = ma.TwoD_Analysis(timestamp='20180222_135055') extracted_vals = a.measured_values[0][4] # critical part here is that nan's get appended expected_vals = np.array( [148.17970988, 140.84035328, 135.46773387, 140.18987364, np.nan]) np.testing.assert_array_almost_equal(extracted_vals, expected_vals) exp_sweep_points = np.array([ 2.40000000e-07, 2.45000000e-07, 2.50000000e-07, 2.55000000e-07, 2.60000000e-07, 2.65000000e-07, 2.70000000e-07, 2.75000000e-07, 2.80000000e-07, 2.85000000e-07, 2.90000000e-07, 2.95000000e-07, 3.00000000e-07, 3.05000000e-07, 3.10000000e-07, 3.15000000e-07, 3.20000000e-07, 3.25000000e-07, 3.30000000e-07, 3.35000000e-07, 3.40000000e-07, 3.45000000e-07, 3.50000000e-07, 3.55000000e-07, 3.60000000e-07, 3.65000000e-07, 3.70000000e-07, 3.75000000e-07, 3.80000000e-07, 3.85000000e-07, 3.90000000e-07, 3.95000000e-07, 4.00000000e-07, 4.01000000e-07, 4.51000000e-07, 5.01000000e-07, 5.51000000e-07, 6.01000000e-07, 6.51000000e-07, 7.01000000e-07, 7.51000000e-07, 8.01000000e-07, 8.51000000e-07, 9.01000000e-07, 9.51000000e-07 ]) np.testing.assert_array_almost_equal(a.sweep_points, exp_sweep_points) np.testing.assert_array_almost_equal(a.sweep_points_2D, np.arange(5.))
def extract_data(self): """ Custom data extraction for this specific experiment. """ self.timestamps = a_tools.get_timestamps_in_range( self.t_start, self.t_stop, label=self.labels) self.raw_data_dict = OrderedDict() # auto is True for the TwoD analysis as the heatmap can be useful # for debugging the data a = ma_old.TwoD_Analysis(timestamp=self.timestamps[0], auto=True, close_file=False) a.get_naming_and_values_2D() ch_amp = a.data_file[self.ch_amp_key].attrs['value'] if self.ch_range_key is None: ch_range = 2 # corresponds to a scale factor of 1 else: ch_range = a.data_file[self.ch_range_key].attrs['value'] waveform_amp = a.data_file[self.waveform_amp_key].attrs['value'] amp = ch_amp*ch_range/2*waveform_amp self.raw_data_dict['amp'] = amp self.raw_data_dict['phases'] = a.measured_values[0] self.raw_data_dict['times'] = a.sweep_points # hacky but required for data saving self.raw_data_dict['folder'] = a.folder self.raw_data_dict['timestamps'] = self.timestamps a.finish()
def extract_data(self): """ Custom data extraction for this specific experiment. """ self.timestamps = a_tools.get_timestamps_in_range(self.t_start, self.t_stop, label=self.labels) self.raw_data_dict = OrderedDict() # auto is True for the TwoD analysis as the heatmap can be useful # for debugging the data a = ma_old.TwoD_Analysis(timestamp=self.timestamps[0], auto=True, close_file=False) a.get_naming_and_values_2D() # FIXME: this is hardcoded and should be an argument in options dict amp_key = 'Snapshot/instruments/AWG8_8005/parameters/awgs_0_outputs_1_amplitude' amp = a.data_file[amp_key].attrs['value'] self.raw_data_dict['amp'] = amp self.raw_data_dict['phases'] = a.measured_values[0] self.raw_data_dict['times'] = a.sweep_points # hacky but required for data saving self.raw_data_dict['folder'] = a.folder self.raw_data_dict['timestamps'] = self.timestamps a.finish()
def measure_FluxTrack(device, q0_name, amps, fluxes, MC=None): if MC is None: MC = qc.station.components['MC'] q0 = device.qubits()[q0_name] operation_dict = device.get_operation_dict() AWG = q0.AWG FluxTrack_det = cdet.FluxTrack(qubit=q0, MC=qc.station.components['MC_nested'], AWG=AWG) MC.set_sweep_function(AWG.ch4_amp) MC.set_sweep_points(amps) MC.set_sweep_function_2D(Flux_Control) MC.set_sweep_points_2D(fluxes) MC.set_detector_function(q0.int_avg_det_rot) MC.run('FluxTrack_%s' % q0.name, mode='2D') ma.TwoD_Analysis(auto=True)
def measure_SWAPN(device, q0_name, swap_amps, alpha=1., number_of_swaps=30, MC=None): if MC is None: MC = qc.station.components['MC'] q0 = device.qubits()[q0_name] # These are the sweep points swap_vec = np.arange(number_of_swaps) * 2 cal_points = 4 lengths_cal = swap_vec[-1] + \ np.arange(1, 1+cal_points)*(swap_vec[1]-swap_vec[0]) swap_vec = np.concatenate((swap_vec, lengths_cal)) operation_dict = device.get_operation_dict() AWG = q0.AWG repSWAP = awg_swf.awg_seq_swf(fsqs.SwapN, parameter_name='nr_pulses_list', unit='#', AWG=q0.AWG, fluxing_channels=[q0.fluxing_channel()], awg_seq_func_kwargs={ 'operation_dict': operation_dict, 'q0': q0_name, 'alpha': alpha, 'distortion_dict': q0.dist_dict() }) MC.set_sweep_function(repSWAP) MC.set_sweep_points(swap_vec) MC.set_sweep_function_2D(AWG.ch4_amp) MC.set_sweep_points_2D(swap_amps) MC.set_detector_function(q0.int_avg_det_rot) MC.run('SWAPN_{}_alpha_{}'.format(q0.name, alpha), mode='2D') ma.TwoD_Analysis(auto=True)
def extract_data(self): """ Custom data extraction for this specific experiment. Overwrite this method if you wnat to """ self.timestamps = a_tools.get_timestamps_in_range( self.t_start, self.t_stop, label=self.labels) self.raw_data_dict = OrderedDict() for t in self.timestamps: a = ma_old.TwoD_Analysis( timestamp=t, auto=False, close_file=False) a.get_naming_and_values_2D() self.raw_data_dict['folder'] = a.folder self.raw_data_dict['xvals'] = a.sweep_points self.raw_data_dict['yvals'] = a.sweep_points_2D self.raw_data_dict['zvals'] = a.measured_values[self.ch_idx].T self.raw_data_dict['xlabel'] = a.parameter_names[0] self.raw_data_dict['ylabel'] = a.parameter_names[1] self.raw_data_dict['zlabel'] = a.value_names[self.ch_idx] self.raw_data_dict['xunit'] = a.parameter_units[0] self.raw_data_dict['yunit'] = a.parameter_units[1] self.raw_data_dict['zunit'] = a.value_units[self.ch_idx] self.raw_data_dict['measurementstring'] = a.measurementstring self.raw_data_dict['timestamp_string'] = a.timestamp_string a.finish() self.raw_data_dict['times'] = a.sweep_points self.raw_data_dict['timestamps'] = self.timestamps
def acquire_2D_linear_frequency_span_vs_param(file_name, start_freq=None, stop_freq=None, center_freq=None, parameter=None, sweep_vector=None, span=None, nbr_points=101, power=-20, bandwidth=100, measure='S21'): """ Acquires a single trace from the VNA. Inputs: file_name (str), name of the output file. start_freq (float), starting frequency of the trace. stop_freq (float), stoping frequency of the trace. center_freq (float), central frequency of the trace. span (float), span of the trace. nbr_points (int), Number of points within the trace. power (float), power in dBm. bandwidth (float), bandwidth in Hz. measure (str), scattering parameter to measure (ie. 'S21'). Output: NONE Beware that start/stop and center/span are just two ways of configuring the same thing. """ # set VNA sweep function if start_freq != None and stop_freq != None: swf_fct_1D = swf.ZNB_VNA_sweep(VNA_instr, start_freq=start_freq, stop_freq=stop_freq, npts=nbr_points, force_reset=True) MC_instr.set_sweep_function(swf_fct_1D) elif center_freq != None and span != None: swf_fct_1D = swf.ZNB_VNA_sweep(VNA_instr, center_freq=center_freq, span=span, npts=nbr_points, force_reset=True) MC_instr.set_sweep_function(swf_fct_1D) if parameter is not None and sweep_vector is not None: # it prepares the sweep_points, such that it does not complain. swf_fct_1D.prepare() MC_instr.set_sweep_points(swf_fct_1D.sweep_points) MC_instr.set_sweep_function_2D(parameter) MC_instr.set_sweep_points_2D(sweep_vector) else: raise ValueError('Need to define parameter and its range.') # set VNA detector function MC_instr.set_detector_function(det.ZNB_VNA_detector(VNA_instr)) # VNA settings VNA_instr.power(power) VNA_instr.average_state('off') VNA_instr.bandwidth(bandwidth) # hack to measure S parameters different from S21 str_to_write = "calc:par:meas 'trc1', '%s'" % measure print(str_to_write) VNA_instr.visa_handle.write(str_to_write) VNA_instr.timeout(600) MC_instr.run(name=file_name, mode='2D') # ma.Homodyne_Analysis(auto=True, label=file_name, fitting_model='hanger') ma.TwoD_Analysis(auto=True, label=file_name)