def do_measurement(phases, ontime=1, offtime=12): voltages = table.get_voltages(phases) dac.write_voltages(voltages) print 'warming up...' for j in range(ontime): fpga.read() counts = dict(zip(fpga.labels, fpga.read())) dac.zero() print 'cooling' for j in range(offtime): fpga.read() return counts
def do_measurement(phases, ontime=1, offtime=12): voltages=table.get_voltages(phases) dac.write_voltages(voltages) print 'warming up...' for j in range(ontime): fpga.read() counts=fpga.read() dac.zero() print 'cooling' for j in range(offtime): fpga.read() return counts
def do_experiment(voltages, ontime=2, offtime=12): dac.write_voltages(voltages) print 'warming up...', for j in range(ontime): fpga.read() counts=fpga.read() dac.zero() print 'cooling...', for j in range(offtime): fpga.read() # Get c00, c01, c10, c11 coincidences=np.array(counts[8:12]) accidentals=np.array([counts[12], counts[17], counts[16], counts[13]]) corrected_counts=coincidences-accidentals total_counts=np.sum(corrected_counts) print 'total count rate %d' % total_counts probabilities_expt=corrected_counts/float(np.sum(corrected_counts)) return probabilities_expt, total_counts
def do_experiment(voltages, ontime=2, offtime=12): dac.write_voltages(voltages) print 'warming up...', for j in range(ontime): fpga.read() counts = fpga.read() dac.zero() print 'cooling...', for j in range(offtime): fpga.read() # Get c00, c01, c10, c11 coincidences = np.array(counts[8:12]) accidentals = np.array([counts[12], counts[17], counts[16], counts[13]]) corrected_counts = coincidences - accidentals total_counts = np.sum(corrected_counts) print 'total count rate %d' % total_counts probabilities_expt = corrected_counts / float(np.sum(corrected_counts)) return probabilities_expt, total_counts
def acquire_data(heater_index, N=20, hold=[]): min_voltage, max_voltage=0, 7 parameter_space=np.linspace(min_voltage, max_voltage, N) experiment=np.zeros([N, 5]) theory=np.zeros([N, 4]) fidelity=np.zeros(N) for index_1, parameter_1 in enumerate(parameter_space): # Figure out the settings phases=np.zeros(8) for index, phase in hold: print 'hold phase %d: %.3f' % (index, phase) phases[index]=phase voltages=np.array(table.get_voltages(phases)) print 'sweep voltage %d: %.3f' % (heater_index, parameter_1) voltages[heater_index] = parameter_1 print 'final voltages', voltages.round(2) parameters=table.get_parameters(heater_index) #phase_voltage_2 for added linear dependance phases[heater_index] = fitting.phase_voltage_2(parameters, parameter_1) # Do the measurement experiment[index_1] = do_experiment(voltages) theory[index_1] = do_theory(phases, experiment[index_1][4]) fidelity[index_1]=statistical_fidelity(experiment[index_1][:4]/experiment[index_1][4], theory[index_1]/experiment[index_1][4]) print fidelity[index_1] # Plot plot_now(experiment, theory, parameter_space, fidelity, do_fit=False) # Close hardware dac.zero() # Normalize, save and return data #data=data/np.amax(data) experiment_filename, theory_filename, param_filename = get_filenames(heater_index) np.save(experiment_filename, experiment) np.save(theory_filename, theory) np.save(param_filename, parameter_space) return experiment_filename, theory_filename, param_filename
def acquire_data(heater_index, N=20, hold=[]): min_phase, max_phase = 0, 2 * np.pi parameter_space = np.linspace(min_phase, max_phase, N) experiment = np.zeros([N, 4]) theory = np.zeros([N, 4]) for index_1, parameter_1 in enumerate(parameter_space): # Figure out the settings phases = np.zeros(8) for index, phase in hold: print 'hold phase %d: %.3f' % (index, phase) phases[index] = phase print 'sweep phase %d: %.3f' % (heater_index, parameter_1) phases[heater_index] = parameter_1 print 'final phases', phases.round(2) # Do the measurement experiment[index_1], total_counts = do_experiment(phases) theory[index_1] = do_theory(phases, total_counts) # Plot plot_now(experiment, theory, parameter_space, do_fit=False) # Close hardware dac.zero() # Normalize, save and return data #data=data/np.amax(data) experiment_filename, theory_filename, param_filename, hold_table_filename = get_filenames( heater_index) file = open(hold_table_filename, "w") file.write(str(hold_table)) file.close() np.save(experiment_filename, experiment) np.save(theory_filename, theory) np.save(param_filename, parameter_space) return experiment_filename, theory_filename, param_filename
def acquire_data(heater_index, N=20, hold=[]): min_phase, max_phase=0, 2*np.pi parameter_space=np.linspace(min_phase, max_phase, N) experiment=np.zeros([N, 4]) theory=np.zeros([N, 4]) for index_1, parameter_1 in enumerate(parameter_space): # Figure out the settings phases=np.zeros(8) for index, phase in hold: print 'hold phase %d: %.3f' % (index, phase) phases[index]=phase print 'sweep phase %d: %.3f' % (heater_index, parameter_1) phases[heater_index] = parameter_1 print 'final phases', phases.round(2) # Do the measurement experiment[index_1], total_counts = do_experiment(phases) theory[index_1] = do_theory(phases, total_counts) # Plot plot_now(experiment, theory, parameter_space, do_fit=False) # Close hardware dac.zero() # Normalize, save and return data #data=data/np.amax(data) experiment_filename, theory_filename, param_filename, hold_table_filename = get_filenames(heater_index) file=open(hold_table_filename, "w") file.write(str(hold_table)) file.close() np.save(experiment_filename, experiment) np.save(theory_filename, theory) np.save(param_filename, parameter_space) return experiment_filename, theory_filename, param_filename
data_raw_coinc = [] data_raw_accid = [] fidelity_bins = [0] * bin_count fidelity_samples = 0 fidelity_sum = 0 fidelity_mean = 0 stop = False while not stop: coincidences, accidentals, fidelity, phases, raw_coinc, raw_accid = new_sample( device) data_coincidences.append(coincidences) data_accidentals.append(accidentals) data_phases.append(phases) print fidelity data_raw_coinc.append(raw_coinc) data_raw_accid.append(raw_accid) fidelity_bins[get_bin(fidelity)] += 1 minf = min(fidelity, minf) maxf = max(fidelity, maxf) fidelity_sum += fidelity fidelity_samples += 1.0 fidelity_mean = fidelity_sum / fidelity_samples draw_graph() if kbhit(): stop = getch() == 'q' dac.zero()
data_phases=[] data_raw_coinc=[] data_raw_accid=[] fidelity_bins=[0]*bin_count fidelity_samples=0 fidelity_sum=0 fidelity_mean=0 stop=False while not stop: coincidences, accidentals, fidelity, phases, raw_coinc, raw_accid = new_sample(device) data_coincidences.append(coincidences) data_accidentals.append(accidentals) data_phases.append(phases) print fidelity data_raw_coinc.append(raw_coinc) data_raw_accid.append(raw_accid) fidelity_bins[get_bin(fidelity)]+=1 minf=min(fidelity, minf) maxf=max(fidelity, maxf) fidelity_sum+=fidelity fidelity_samples+=1.0 fidelity_mean=fidelity_sum/fidelity_samples draw_graph() if kbhit(): stop = getch()=='q' dac.zero()