Esempio n. 1
0
def acquire_data(heater_indeces, N=20, DEBUG=False):
    min_phase, max_phase = 0, 2 * np.pi
    scan = np.linspace(min_phase, max_phase, N)
    parameter_space = np.meshgrid(scan, scan)
    data = np.zeros([N, N])

    # connect hardware
    d = dac.dac()
    table = calibration_table()
    meter = powermeter()

    for index_1, parameter_1 in enumerate(scan):
        for index_2, parameter_2 in enumerate(scan):
            print index_1, index_2

            if DEBUG:
                data[index_1, index_2] = (1 - index_1 * .03) * fit_func(
                    [0.2, 0.4, 1, 0], [parameter_1, parameter_2])
            else:
                # Figure out the settings
                voltages = np.zeros(8)
                first_heater, second_heater = heater_indeces
                voltages[first_heater] = table.get_voltage_from_phase(
                    first_heater, parameter_1)
                voltages[second_heater] = table.get_voltage_from_phase(
                    second_heater, parameter_2)
                print voltages.round(3)

                # Do the measurement
                d.write_voltages(voltages)
                for q in range(10):
                    meter.read()
                intensities = np.zeros(6)
                for q in range(6):
                    intensities += np.array(meter.read())
                # cool
                d.zero()
                for q in range(10):
                    meter.read()
                data[index_1, index_2] = intensities[0]

    # Close hardware
    d.zero()
    meter.kill()

    # Normalize, save and return data
    data = data / np.amax(data)
    data_filename, param_filename = get_filenames(heater_indeces)
    np.save(data_filename, data)
    np.save(param_filename, parameter_space)
    return data_filename, param_filename
Esempio n. 2
0
def acquire_data(heater_index, N=20, DEBUG=False, hold=[]):
    min_phase, max_phase = 0, 2 * np.pi
    parameter_space = np.linspace(min_phase, max_phase, N)
    data = np.zeros([N])

    # connect hardware
    d = dac.dac()
    table = calibration_table()
    meter = powermeter()

    for index_1, parameter_1 in enumerate(parameter_space):
        print index_1

        if DEBUG:
            data[index_1] = 0
        else:
            # Figure out the settings
            voltages = np.zeros(8)
            voltages[heater_index] = table.get_voltage_from_phase(
                heater_index, parameter_1)

            # Hold some phases constant during the scan
            for index, phase in hold:
                voltages[index] = table.get_voltage_from_phase(index, phase)

            print voltages.round(3)

            # Do the measurement
            d.write_voltages(voltages)
            for q in range(10):
                meter.read()
            intensities = np.zeros(6)
            for q in range(6):
                intensities += np.array(meter.read())
            # cool
            d.zero()
            for q in range(10):
                meter.read()
            data[index_1] = intensities[0]

    # Close hardware
    d.zero()
    meter.kill()

    # Normalize, save and return data
    data = data / np.amax(data)
    data_filename, param_filename = get_filenames(heater_index)
    np.save(data_filename, data)
    np.save(param_filename, parameter_space)
    return data_filename, param_filename
Esempio n. 3
0
def acquire_data(heater_index, N=20, DEBUG=False, hold=[]):
    min_phase, max_phase=0, 2*np.pi
    parameter_space=np.linspace(min_phase, max_phase, N)
    data=np.zeros([N])
    
    # connect hardware
    d=dac.dac()
    table=calibration_table()
    meter=powermeter()
        
    for index_1, parameter_1 in enumerate(parameter_space):
        print index_1
        
        if DEBUG:
            data[index_1] = 0
        else:
            # Figure out the settings
            voltages=np.zeros(8)
            voltages[heater_index]=table.get_voltage_from_phase(heater_index, parameter_1)

            # Hold some phases constant during the scan
            for index, phase in hold:
                voltages[index]=table.get_voltage_from_phase(index, phase)
                
            print voltages.round(3)
            
            # Do the measurement
            d.write_voltages(voltages)
            for q in range(10):
                meter.read()
            intensities=np.zeros(6)
            for q in range(6):
                intensities+=np.array(meter.read())
            # cool
            d.zero()
            for q in range(10):
                meter.read()
            data[index_1] = intensities[0]

    # Close hardware
    d.zero()
    meter.kill()
    
    # Normalize, save and return data
    data=data/np.amax(data)
    data_filename, param_filename = get_filenames(heater_index)
    np.save(data_filename, data)
    np.save(param_filename, parameter_space)
    return data_filename, param_filename
Esempio n. 4
0
def acquire_data(heater_indeces, N=20, DEBUG=False):
    min_phase, max_phase=0, 2*np.pi
    scan=np.linspace(min_phase, max_phase, N)
    parameter_space=np.meshgrid(scan, scan)    
    data=np.zeros([N,N])
    
    # connect hardware
    d=dac.dac()
    table=calibration_table()
    meter=powermeter()
        
    for index_1, parameter_1 in enumerate(scan):
        for index_2, parameter_2 in enumerate(scan):
            print index_1, index_2
            
            if DEBUG:
                data[index_1, index_2] = (1-index_1*.03)*fit_func([0.2,0.4,1,0], [parameter_1, parameter_2])
            else:
                # Figure out the settings
                voltages=np.zeros(8)
                first_heater, second_heater=heater_indeces
                voltages[first_heater]=table.get_voltage_from_phase(first_heater, parameter_1)
                voltages[second_heater]=table.get_voltage_from_phase(second_heater, parameter_2)
                print voltages.round(3)
                
                # Do the measurement
                d.write_voltages(voltages)
                for q in range(10):
                    meter.read()
                intensities=np.zeros(6)
                for q in range(6):
                    intensities+=np.array(meter.read())
                # cool
                d.zero()
                for q in range(10):
                    meter.read()
                data[index_1, index_2] = intensities[0]

    # Close hardware
    d.zero()
    meter.kill()
    
    # Normalize, save and return data
    data=data/np.amax(data)
    data_filename, param_filename = get_filenames(heater_indeces)
    np.save(data_filename, data)
    np.save(param_filename, parameter_space)
    return data_filename, param_filename
    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


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
    
    # 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

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
Esempio n. 7
0
import numpy as np
from qy.hardware.heaters import dac, calibration_table
from time import sleep
from numpy import pi
from powermeter import powermeter
from matplotlib import pyplot as plt

d = dac.dac()
d.zero()
print 'zeroed the heaters'
import numpy as np
from qy.hardware.heaters import dac, calibration_table
from msvcrt import kbhit, getch
import sys

d = dac.dac()
table = calibration_table()

# use 3*np.pi/2

args = sys.argv[1:]
assert (len(sys.argv) - 1) % 2 == 0
voltages = np.zeros(8)
for i in range(0, len(args), 2):
    index = int(args[i])
    phase = float(args[i + 1]) * np.pi
    voltage = table.get_voltage_from_phase(index, phase)
    voltages[index] = voltage
    print "heater %d set to %.4f" % (index, phase)

d.write_voltages(voltages)

print "press q to stop"
stop = False
while not stop:
    if kbhit():
        stop = getch() == "q"

d.zero()