示例#1
0
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
    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


start_time = timestamp()

device = lo.beamsplitter_network(json='cnot_mz.json')
simulator = lo.simulator(device, nphotons=2)
simulator.set_input_state([1, 3])
simulator.set_visibility(0.99)
dac = dac.dac()
fpga = fpga()
fpga.read()
fpga.read()
fpga.read()
fpga.read()
table = calibration_table()

heater_index = 6
#hold_table=[[0,pi/2],[2,0], [6,pi/2]]
hold_table = list(enumerate([pi, 0, 0, 0, 0, 0, 0, 0]))

# Take data
acquire_data(heater_index, hold=hold_table, N=40)

# Reload and fit
experiment_filename, theory_filename, param_filename, hold_table_filename = get_filenames(
    heater_index)
    #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

start_time=timestamp()    

device=lo.beamsplitter_network(json='cnot_mz.json')
simulator=lo.simulator(device, nphotons=2)
simulator.set_input_state([1,3])
simulator.set_visibility(0.95)
dac=dac.dac()
fpga=fpga()
fpga.read()
fpga.read()
fpga.read()
fpga.read()
table=calibration_table()

heater_index = 5
#hold_table=[[0,pi/2],[2,0], [6,pi/2]]
hold_table=list(enumerate([0,pi/2,0,0,0,0,0,pi/2]))

# Take data
acquire_data(heater_index, hold=hold_table, N=40)

# Reload and fit
#experiment_filename, theory_filename, param_filename = get_filenames(heater_index)
#experiment=np.load(experiment_filename)