Пример #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
Пример #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
Пример #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
Пример #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
Пример #5
0
 def connect_hardware(self):
     ''' try to connect to all the relevant hardware '''
     self.powermeter = powermeter()
Пример #6
0
 def connect_hardware(self):
     ''' try to connect to all the relevant hardware '''
     self.powermeter=powermeter()
Пример #7
0
from powermeter import powermeter

Pow = powermeter() 


(ListDevices,ListIDN) = Pow.ListDevices() #Read a list of devices. The elements in ListDevices are the addresses, the elements in ListIDN are the corresponding "identities


(Msg,ID) = Pow.ConnectDevice('USB0::0x1313::0x8079::P1000322::INSTR') #Replace this string with the address of your device


(Power,PowerUnits) = Pow.ReadPower()

ID = Pow.SetZero()


(Msg,ID) = Pow.DisconnectDevice()