Esempio n. 1
0
    def Perform_Measurement(self, event):

        print("GUIController: Perform_Measurement")

        # Using that instance we then run the lights,
        # and measure the outputs
        self.measurement_handler = MeasurementHandler()
        measurement_handler.add_to_queue(
            self.light_pulse.complete_waveform,
            self.metadata
        )

        raw_data = self.measurement_handler.single_measurement()
        self.Data.updateRawData(raw_data)
        self.Data.Data = utils.bin_data(raw_data, self.metadata.binning)
        # We then plot the datas, this has to be changed if the plots want
        # to be updated on the fly.

        pub.sendMessage('update.plot')
Esempio n. 2
0
    def single_measurement(self):
        '''
        This runs a single measurements:
            1. Sets the femto gain
            2. Generatres a waveform
            3. Sends command to DAQ
            4. Does next item
        '''
        # get measurement from list
        measurement_settings = self._queue.popleft()
        print 'The measurement settings are', type(measurement_settings)
        print measurement_settings.ref_gain
        print measurement_settings.pl_gain

        # set preamp gains
        self.preamps.configure(measurement_settings)

        # gets the voltage pulse to control the waveform
        waveform_array = LightPulse(measurement_settings).create_waveform()
        # plt.figure()
        # plt.plot(waveform_array)
        # plt.show()

        # initalises the DAQ ready for a measurement
        thread = self.daq._int_thread(waveform_array, measurement_settings)

        # lets get the averaging
        averaging = measurement_settings.averaging

        # set the variables before they are created?
        thread_time = None
        measurement_data = []

        # perform a measurement
        measurement_data, thread_time = self.daq.run_thread(thread)

        # make sure the length makes sense
        data_len = measurement_data.shape[0] / self.daq.NUM_CHANNELS
        # print type(data_len), data_len
        # print
        assert (data_len.is_integer(),
                "No of points per channel={0}".format(data_len))
        data_len = int(data_len)

        # if more averages were requested
        if averaging > 1:
            for i in range(averaging - 1):
                thread_data, thread_time = self.daq.run_thread(thread)
                # stack the data
                measurement_data = np.vstack((thread_data, measurement_data))
                # average the data, weighting it towards
                # running total
                measurement_data = np.average(measurement_data,
                                              axis=0,
                                              weights=(1, i + 1))

        # convert into columns, putting the right data
        # in the right place
        measurement_data = measurement_data[:data_len *
                                            int(self.daq.NUM_CHANNELS)]
        measurement_data = measurement_data.reshape(
            (data_len, int(self.daq.NUM_CHANNELS)), order='F')

        assert measurement_data.shape[0] == thread_time.shape[
            0], 'data Length differ {0} {1}'.format(measurement_data.shape,
                                                    thread_time.shape[0])

        measurement_data = np.vstack((thread_time, measurement_data.T)).T
        measurement_data = bin_data(measurement_data,
                                    measurement_settings.binning)

        return measurement_data
Esempio n. 3
0
    def single_measurement(self):
        '''
        This runs a single measurements:
            1. Sets the femto gain
            2. Generatres a waveform
            3. Sends command to DAQ
            4. Does next item
        '''
        # get measurement from list
        measurement_settings = self._queue.popleft()
        print 'The measurement settings are', type(measurement_settings)
        print measurement_settings.ref_gain
        print measurement_settings.pl_gain

        # set preamp gains
        self.preamps.configure(measurement_settings)

        # gets the voltage pulse to control the waveform
        waveform_array = LightPulse(measurement_settings).create_waveform()
        # plt.figure()
        # plt.plot(waveform_array)
        # plt.show()

        # initalises the DAQ ready for a measurement
        thread = self.daq._int_thread(waveform_array, measurement_settings)

        # lets get the averaging
        averaging = measurement_settings.averaging

        # set the variables before they are created?
        thread_time = None
        measurement_data = []

        # perform a measurement
        measurement_data, thread_time = self.daq.run_thread(thread)

        # make sure the length makes sense
        data_len = measurement_data.shape[0] / self.daq.NUM_CHANNELS
        # print type(data_len), data_len
        # print
        assert (
            data_len.is_integer(), "No of points per channel={0}".format(
                data_len)
        )
        data_len = int(data_len)


        # if more averages were requested
        if averaging > 1:
            for i in range(averaging - 1):
                thread_data, thread_time = self.daq.run_thread(thread)
                # stack the data
                measurement_data = np.vstack((thread_data,
                                              measurement_data))
                # average the data, weighting it towards
                # running total
                measurement_data = np.average(measurement_data,
                                              axis=0,
                                              weights=(1, i + 1))

        # convert into columns, putting the right data
        # in the right place
        measurement_data = measurement_data[:data_len*int(self.daq.NUM_CHANNELS)]
        measurement_data = measurement_data.reshape(
            (data_len, int(self.daq.NUM_CHANNELS)),
            order = 'F')

        assert measurement_data.shape[0] == thread_time.shape[0], 'data Length differ {0} {1}'.format( measurement_data.shape, thread_time.shape[0])

        measurement_data = np.vstack((thread_time, measurement_data.T)).T
        measurement_data = bin_data(measurement_data,measurement_settings.binning)

        return measurement_data