Esempio n. 1
0
    def _plot(self, axes_list):

        if len(self.data['plant_output']) > 0:
            time_step = 1. / self.settings['sample rate']
            axes1, axes2 = axes_list

            # plot time domain signals
            axes1.hold(False)
            signal = self.data['plant_output']
            control_value = self.data['control_output']

            t = np.linspace(0, len(signal) * time_step, len(signal))
            axes1.plot(t, signal, '-o')
            axes1.hold(True)
            axes1.plot(t, control_value, '-o')

            axes1.set_title('time signal')
            axes1.set_xlabel('time (s)')

            # only plot spectra if there is a sufficiently long signal and only refresh after 5 seconds

            if (len(signal) > 2 and
                (datetime.datetime.now() - self.last_plot).total_seconds() > 5
                ) or self.is_running is False:
                # plot freq domain signals
                axes2.hold(False)
                f, psd = power_spectral_density(signal, time_step)
                axes2.loglog(f, psd, '-o')
                axes2.hold(True)
                f, psd = power_spectral_density(control_value, time_step)
                axes2.loglog(f, psd, '-o')
                axes2.set_title('spectra')
                axes1.set_xlabel('frequency (Hz)')
                self.last_plot = datetime.datetime.now()
    def _plot(self, axes_list, data = None):
        '''
        Plots the galvo scan image
        Args:
            axes_list: list of axes objects on which to plot the keyseight spectrun on the first axes object
            data: data (dictionary that contains keys amplitudes, frequencies) if not provided use self.data
        '''
        if data is None:
            data = self.data

        dt = self.data['meta_data']['xincrement']
        data = self.data['voltage']
        time = dt*np.arange(len(data))
        axes_list[0].plot(time, data, '-')
        axes_list[0].set_xlabel('time (s)')
        axes_list[0].set_ylabel('signal (arb.)')


        F, P = power_spectral_density(data, dt)

        print(('JG adasd', data, dt))

        axes_list[1].plot(F, P, '-')
        axes_list[1].set_xlabel('freq (Hz)')
        axes_list[1].set_ylabel('signal (arb.)')

        axes_list[1].set_xscale("log")
        # JG: try to display on a log scale, this doesn't work if the psd is negative or zero (which might happen if the oscilloscope is out of range)
        if np.mean(data) > 0:
            axes_list[1].set_yscale("log")
Esempio n. 3
0
    def _plot(self, axes_list, data=None):
        '''
        Plots the galvo scan image
        Args:
            axes_list: list of axes objects on which to plot the keyseight spectrun on the first axes object
            data: data (dictionary that contains keys amplitudes, frequencies) if not provided use self.data
        '''
        if data is None:
            data = self.data

        dt = self.data['meta_data']['xincrement']
        data = self.data['voltage']
        time = dt * np.arange(len(data))
        axes_list[0].plot(time, data, '-')
        axes_list[0].set_xlabel('time (s)')
        axes_list[0].set_ylabel('signal (arb.)')

        F, P = power_spectral_density(data, dt)

        print(('JG adasd', data, dt))

        axes_list[1].plot(F, P, '-')
        axes_list[1].set_xlabel('freq (Hz)')
        axes_list[1].set_ylabel('signal (arb.)')

        axes_list[1].set_xscale("log")
        # JG: try to display on a log scale, this doesn't work if the psd is negative or zero (which might happen if the oscilloscope is out of range)
        if np.mean(data) > 0:
            axes_list[1].set_yscale("log")
    def _plot(self, axes_list, data=None):
        # COMMENT_ME

        if data is None:
            data = self.data

        if len(data['counts']) > 0:
            plot_counts(axes_list[0], data['counts'])
            freq, psd = power_spectral_density(
                data['counts'], self.settings['integration_time'])
            plot_psd(freq, psd, axes_list[1], y_scaling='log', x_scaling='log')
Esempio n. 5
0
def plot_2d_fft_rabi_vs_powers(RABI_FOLDER,
                               xlog=False,
                               ylog=False,
                               freq_range=None):
    '''

    Args:
        RABI_FOLDER: folder with the rabi data to use

    Returns:
        rabi_data: rabi contrast APD output 2 / APD output 1 versus tau
        taus: tau values in the rabi sweep
        powers: power values used in the 2D sweep, in dBm

    '''

    rabi_data = []
    taus = []
    powers = []
    freqs = []
    for f in sorted(glob.glob('{:s}/data_subscripts/*'.format(RABI_FOLDER))):
        data = Script.load_data(f)
        if 'tau' not in data or data is None:  # not a Rabi folder (e.g., find_nv instead)
            continue
        cnts = np.transpose(data['counts'])
        cnts1 = cnts[1]
        cnts0 = cnts[0]
        single_rabi_data = cnts1 / cnts0
        taus = data['tau']

        single_rabi_data -= np.mean(single_rabi_data)
        freqs, single_rabi_data = power_spectral_density(
            single_rabi_data, (taus[1] - taus[0]) * 1e-9,
            freq_range=freq_range)

        if ylog:
            single_rabi_data = np.log10(single_rabi_data)
        rabi_data.append(single_rabi_data)
        power = float(f.split('_')[-1])
        powers.append(power)

    if xlog:
        freqs += 1
        freqs = np.log10(freqs)
        print(freqs)

    rabi_data = np.array(rabi_data)[np.argsort(powers)]
    powers = np.sort(np.array(powers))
    plt.pcolormesh(freqs, powers, rabi_data)
    plt.xlabel('frequencies (Hz)')
    plt.ylabel('input power (dBm)')
Esempio n. 6
0
    def _update_plot(self, axes_list):
        """
        updates the galvo scan image
        Args:
            axes_list: list of axes objects on which to plot plots the esr on the first axes object
        """
        print(('axes list lenght update', len(axes_list)))

        update_fluorescence(self.data['image_data'], axes_list[0])

        last_data = self.data['point_data'][-1]
        dt = self.data['meta_data']['xincrement']
        freq, psd = power_spectral_density(last_data, dt)
        plot_psd(freq, psd, axes_list[1], y_scaling='log', x_scaling='log')
        axes_list[1].hold(False)
Esempio n. 7
0
    def _update_plot(self, axes_list):
        """
        updates the galvo scan image
        Args:
            axes_list: list of axes objects on which to plot plots the esr on the first axes object
        """
        print(('axes list lenght update', len(axes_list)))

        update_fluorescence(self.data['image_data'], axes_list[0])

        last_data = self.data['point_data'][-1]
        dt = self.data['meta_data']['xincrement']
        freq, psd = power_spectral_density(last_data, dt)
        plot_psd(freq, psd, axes_list[1], y_scaling='log', x_scaling='log')
        axes_list[1].hold(False)
Esempio n. 8
0
def plot_2d_fft_rabi_vs_powers(RABI_FOLDER, xlog=False, ylog = False, freq_range = None):
    '''

    Args:
        RABI_FOLDER: folder with the rabi data to use

    Returns:
        rabi_data: rabi contrast APD output 2 / APD output 1 versus tau
        taus: tau values in the rabi sweep
        powers: power values used in the 2D sweep, in dBm

    '''

    rabi_data = []
    taus = []
    powers = []
    freqs = []
    for f in sorted(glob.glob('{:s}/data_subscripts/*'.format(RABI_FOLDER))):
        data = Script.load_data(f)
        if 'tau' not in data or data is None: # not a Rabi folder (e.g., find_nv instead)
            continue
        cnts = np.transpose(data['counts'])
        cnts1 = cnts[1]
        cnts0 = cnts[0]
        single_rabi_data = cnts1/cnts0
        taus = data['tau']

        single_rabi_data -= np.mean(single_rabi_data)
        freqs, single_rabi_data = power_spectral_density(single_rabi_data, (taus[1]-taus[0])*1e-9, freq_range=freq_range)

        if ylog:
            single_rabi_data = np.log10(single_rabi_data)
        rabi_data.append(single_rabi_data)
        power = float(f.split('_')[-1])
        powers.append(power)

    if xlog:
        freqs += 1
        freqs = np.log10(freqs)
        print(freqs)

    rabi_data = np.array(rabi_data)[np.argsort(powers)]
    powers = np.sort(np.array(powers))
    plt.pcolormesh(freqs, powers, rabi_data)
    plt.xlabel('frequencies (Hz)')
    plt.ylabel('input power (dBm)')
Esempio n. 9
0
    def _plot(self, axes_list, data=None):
        """
        Plots the galvo scan image
        Args:
            axes_list: list of axes objects on which to plot the galvo scan on the first axes object
            data: data (dictionary that contains keys image_data, extent) if not provided use self.data
        """

        print(('axes list lenght plot', len(axes_list)))
        if data is None:
            data = self.data

        plot_fluorescence_new(data['image_data'], data['extent'], axes_list[0])

        last_data = self.data['point_data'][-1]
        dt = self.data['meta_data']['xincrement']
        freq, psd = power_spectral_density(last_data, dt)
        plot_psd(freq, psd, axes_list[1], y_scaling='log', x_scaling='log')
Esempio n. 10
0
    def _plot(self, axes_list, data=None):
        """
        Plots the galvo scan image
        Args:
            axes_list: list of axes objects on which to plot the galvo scan on the first axes object
            data: data (dictionary that contains keys image_data, extent) if not provided use self.data
        """

        print(('axes list lenght plot', len(axes_list)))
        if data is None:
            data = self.data

        plot_fluorescence_new(data['image_data'], data['extent'], axes_list[0])

        last_data = self.data['point_data'][-1]
        dt = self.data['meta_data']['xincrement']
        freq, psd = power_spectral_density(last_data, dt)
        plot_psd(freq, psd, axes_list[1], y_scaling='log', x_scaling='log')
    def _plot(self, axes_list, data=None):
        # COMMENT_ME

        if data is None:
            data = self.data

        for signal in [data['counts']]:  #, data['ai']]: ER 20190130
            if len(signal) > 0:
                plot_counts(axes_list[0], signal / np.mean(signal))
                freq, psd = power_spectral_density(
                    signal / np.mean(signal),
                    self.settings['integration_time'])
                print('freqs: ', freq)  # ER 20190129
                print('psd: ', psd)  # ER 20190129
                print('freq[-1:]: ', freq[-1:])
                # plot_psd(freq, psd, axes_list[1], y_scaling='log', x_scaling='log')
                plot_psd(freq[1:],
                         psd[1:],
                         axes_list[1],
                         y_scaling='log',
                         x_scaling='lin')  # remove dc component ER 20190129