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
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
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
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
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) experiment = np.load(experiment_filename) theory = np.load(theory_filename) parameter_space = np.load(param_filename) plot_now(experiment, theory, parameter_space, do_fit=True)
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) #theory=np.load(theory_filename) #parameter_space=np.load(param_filename)