コード例 #1
0
ファイル: laser_scan.py プロジェクト: AdriaanRol/measurement
    def run_scan(self, **kw):
        stabilizing_time = kw.pop('stabilizing_time', 0.01)

        d = qt.Data(name=self.mprefix+'_'+self.name)
        d.add_coordinate('Voltage (V)')
        d.add_coordinate('Frequency (GHz)')
        d.add_coordinate('Counts [Hz]')
        d.add_coordinate('Gate Voltage(V)')

        p = qt.Plot2D(d, 'ro', title='Frq (left) vs Voltage (bottom)', plottitle=self.mprefix,
                name='Laser Scan', clear=True, coorddim=0, valdim=1, maxtraces=1)
        p.add(d, 'bo', title='Counts (right) vs Frq (top)', coorddim=1, valdim=2,
                right=True, top=True)
        p.set_x2tics(True)
        p.set_y2tics(True)
        p.set_x2label('Frequency (GHz)')
        p.set_y2label('Counts [Hz]')
        
        if self.gate_pts>1:
            p3=qt.Plot3D(d, name='Laser_Scan2D', plottitle=self.mprefix, coorddims=(1,3), valdim=2, clear=True)

        qt.mstart()
        ###### HERE THE MEASUREMENT LOOP STARTS ######
        for j,gv in enumerate(np.linspace(self.gate_start_voltage, self.gate_stop_voltage, self.gate_pts)):
            if (msvcrt.kbhit() and (msvcrt.getch() == 'c')): break  
            
            self.scan_to_voltage(self.start_voltage)
            
            if not self.use_repump_during:
                self.repump_pulse()
            
            if self.set_gate_after_repump:
                self.gate_scan_to_voltage(gv)                 
                        
            for i,v in enumerate(np.linspace(self.start_voltage, self.stop_voltage, self.pts)):
                if msvcrt.kbhit():
                    chr=msvcrt.getch()
                    if chr=='q': 
                        break
                    elif chr =='r': 
                        self.repump_pulse()
                
                self.set_laser_voltage(v)
                qt.msleep(stabilizing_time)

                cts = float(self.get_counts(self.integration_time)[self.counter_channel])/(self.integration_time*1e-3)
                frq = self.get_frequency(self.wm_channel)*self.frq_factor - self.frq_offset
                if frq < 0: 
                    continue
                d.add_data_point(v, frq, cts, gv)
                if np.mod(i,10)==0:
                    p.update()
                
            if self.set_gate_after_repump:
                self.gate_scan_to_voltage(0.)
            p.update()
            if self.plot_strain_lines:
                p.set_maxtraces(2)
                try:
                    from analysis.lib.nv import nvlevels
                    Ey_line=float(raw_input('Ey line?')) #GHz
                    Ex_line=float(raw_input('Ex line?')) #GHz
                    lx,ly=nvlevels.get_ES_ExEy_plottable(Ex_line,Ey_line,max(d.get_data()[:,2]))
                    tit=str('Frequency (GHz) lines: [%2.2f,%2.2f,%2.2f,%2.2f,%2.2f,%2.2f] ' % tuple(nvlevels.get_ES_ExEy(Ex_line,Ey_line)))
                    p.add(lx,ly,right=True, top=True, title=tit)
                except ValueError:
                    print 'Could not understand input for lines'
                    pass
            plotsavename=os.path.splitext(d.get_filepath())[0] + ('_gate_voltage_%2.3f' % gv) + '.png'
            p.set_plottitle(str(os.path.splitext(d.get_filename())[0]))
            p.save_png(filepath=plotsavename)
            d.new_block()
            if self.gate_pts>1: 
                p3.update()
            
        qt.mend()
        if self.gate_pts>1:
            p3.reset()
            qt.msleep(1)
            p3.save_png()
        np.savez(os.path.splitext(d.get_filepath())[0]+ '.npz', data=d.get_data())
        d.close_file()
コード例 #2
0
    def run_scan(self, **kw):
        stabilizing_time = kw.pop("stabilizing_time", 0.01)

        d = qt.Data(name=self.mprefix + "_" + self.name)
        d.add_coordinate("Voltage (V)")
        d.add_coordinate("Frequency (GHz)")
        d.add_coordinate("Counts [Hz]")
        d.add_coordinate("Gate Voltage(V)")

        p = qt.Plot2D(
            d,
            "ro",
            title="Frq (left) vs Voltage (bottom)",
            plottitle=self.mprefix,
            name="Laser Scan",
            clear=True,
            coorddim=0,
            valdim=1,
            maxtraces=1,
        )
        p.add(d, "bo", title="Counts (right) vs Frq (top)", coorddim=1, valdim=2, right=True, top=True)
        p.set_x2tics(True)
        p.set_y2tics(True)
        p.set_x2label("Frequency (GHz)")
        p.set_y2label("Counts [Hz]")

        if self.gate_pts > 1:
            p3 = qt.Plot3D(d, name="Laser_Scan2D", plottitle=self.mprefix, coorddims=(1, 3), valdim=2, clear=True)

        qt.mstart()
        #######
        for j, gv in enumerate(np.linspace(self.gate_start_voltage, self.gate_stop_voltage, self.gate_pts)):
            if msvcrt.kbhit() and (msvcrt.getch() == "c"):
                break

            prev_v = v = self.scan_to_frequency(self.start_frequency)
            self.set_laser_power(self.laser_power)

            if not self.use_repump_during:
                self.repump_pulse()

            if self.set_gate:
                self.gate_scan_to_voltage(gv)
            i = 0
            while (v < self.max_v) and (v > self.min_v):
                i = i + 1
                if msvcrt.kbhit():
                    chr = msvcrt.getch()
                    if chr == "q":
                        break
                    elif chr == "r":
                        self.repump_pulse()
                v = prev_v - self.v_step
                prev_v = v
                self.set_laser_voltage(v)
                qt.msleep(stabilizing_time)

                cts = float(self.get_counts(self.integration_time)[self.counter_channel]) / (
                    self.integration_time * 1e-3
                )
                frq = self.get_frequency(self.wm_channel) * self.frq_factor - self.frq_offset
                if frq < 0:
                    print "WARNING: WM gives frq", frq
                    continue
                d.add_data_point(v, frq, cts, gv)
                if np.mod(i, 10) == 0:
                    p.update()
                if frq > self.stop_frequency:
                    break
            self.set_laser_power(0)
            if self.set_gate_to_zero_before_repump:
                self.gate_scan_to_voltage(0.0)
            p.update()
            if self.plot_strain_lines:
                p.set_maxtraces(2)
                try:
                    from analysis.lib.nv import nvlevels

                    Ey_line = float(raw_input("Ey line?"))  # GHz
                    Ex_line = float(raw_input("Ex line?"))  # GHz
                    lx, ly = nvlevels.get_ES_ExEy_plottable(Ex_line, Ey_line, max(d.get_data()[:, 2]))
                    tit = str(
                        "Frequency (GHz) lines: [%2.2f,%2.2f,%2.2f,%2.2f,%2.2f,%2.2f] "
                        % tuple(nvlevels.get_ES_ExEy(Ex_line, Ey_line))
                    )
                    p.add(lx, ly, right=True, top=True, title=tit)
                except ValueError:
                    print "Could not understand input for lines"
                    pass
            plotsavename = os.path.splitext(d.get_filepath())[0] + ("_gate_voltage_%2.3f" % gv) + ".png"
            p.set_plottitle(str(os.path.splitext(d.get_filename())[0]))
            p.save_png(filepath=plotsavename)
            d.new_block()
            if self.gate_pts > 1:
                p3.update()

        qt.mend()
        if self.gate_pts > 1:
            p3.reset()
            qt.msleep(1)
            p3.save_png()
        np.savez(os.path.splitext(d.get_filepath())[0] + ".npz", data=d.get_data())
        d.close_file()
コード例 #3
0
ファイル: laser_scan.py プロジェクト: caizikun/measurement
    def run_scan(self, **kw):
        stabilizing_time = kw.pop('stabilizing_time', 0.01)

        d = qt.Data(name=self.mprefix + '_' + self.name)
        d.add_coordinate('Voltage (V)')
        d.add_coordinate('Frequency (GHz)')
        d.add_coordinate('Counts [Hz]')
        d.add_coordinate('Gate Voltage(V)')

        p = qt.Plot2D(d,
                      'ro',
                      title='Frq (left) vs Voltage (bottom)',
                      plottitle=self.mprefix,
                      name='Laser Scan',
                      clear=True,
                      coorddim=0,
                      valdim=1,
                      maxtraces=1)
        p.add(d,
              'bo',
              title='Counts (right) vs Frq (top)',
              coorddim=1,
              valdim=2,
              right=True,
              top=True)
        p.set_x2tics(True)
        p.set_y2tics(True)
        p.set_x2label('Frequency (GHz)')
        p.set_y2label('Counts [Hz]')

        if self.gate_pts > 1:
            p3 = qt.Plot3D(d,
                           name='Laser_Scan2D',
                           plottitle=self.mprefix,
                           coorddims=(1, 3),
                           valdim=2,
                           clear=True)

        qt.mstart()
        ######
        for j, gv in enumerate(
                np.linspace(self.gate_start_voltage, self.gate_stop_voltage,
                            self.gate_pts)):
            if (msvcrt.kbhit() and (msvcrt.getch() == 'c')): break

            self.scan_to_voltage(self.start_voltage)

            if not self.use_repump_during:
                self.repump_pulse()

            if self.set_gate:
                self.gate_scan_to_voltage(gv)

            for i, v in enumerate(
                    np.linspace(self.start_voltage, self.stop_voltage,
                                self.pts)):
                if msvcrt.kbhit():
                    chr = msvcrt.getch()
                    if chr == 'q':
                        break
                    elif chr == 'r':
                        self.repump_pulse()

                self.set_laser_voltage(v)
                qt.msleep(stabilizing_time)

                cts = float(
                    self.get_counts(self.integration_time)[
                        self.counter_channel]) / (self.integration_time * 1e-3)
                frq = self.get_frequency(
                    self.wm_channel) * self.frq_factor - self.frq_offset
                if frq < 0:
                    print 'WARNING: WM gives frq', frq
                    continue
                d.add_data_point(v, frq, cts, gv)
                if np.mod(i, 10) == 0:
                    p.update()

            if self.set_gate_to_zero_before_repump:
                self.gate_scan_to_voltage(0.)
            p.update()
            if self.plot_strain_lines:
                p.set_maxtraces(2)
                try:
                    from analysis.lib.nv import nvlevels
                    Ey_line = float(raw_input('Ey line?'))  #GHz
                    Ex_line = float(raw_input('Ex line?'))  #GHz
                    lx, ly = nvlevels.get_ES_ExEy_plottable(
                        Ex_line, Ey_line, max(d.get_data()[:, 2]))
                    tit = str(
                        'Frequency (GHz) lines: [%2.2f,%2.2f,%2.2f,%2.2f,%2.2f,%2.2f] '
                        % tuple(nvlevels.get_ES_ExEy(Ex_line, Ey_line)))
                    p.add(lx, ly, right=True, top=True, title=tit)
                except ValueError:
                    print 'Could not understand input for lines'
                    pass
            plotsavename = os.path.splitext(
                d.get_filepath())[0] + ('_gate_voltage_%2.3f' % gv) + '.png'
            p.set_plottitle(str(os.path.splitext(d.get_filename())[0]))
            p.save_png(filepath=plotsavename)
            d.new_block()
            if self.gate_pts > 1:
                p3.update()

        qt.mend()
        if self.gate_pts > 1:
            p3.reset()
            qt.msleep(1)
            p3.save_png()
        np.savez(os.path.splitext(d.get_filepath())[0] + '.npz',
                 data=d.get_data())
        d.close_file()
コード例 #4
0
import os
import numpy as np
from matplotlib import pyplot as plt
from measurement.lib.tools import toolbox
from analysis.lib.nv import nvlevels

# settings
timestamp = None

Ex = 43.8
Ey = 53.17

lines = nvlevels.get_ES_ExEy(Ex,Ey)

### script
if timestamp != None:
    folder = toolbox.data_from_time(timestamp)
else:
    folder = toolbox.latest_data('LaserFrequencyScan')

# get data
fn = os.path.join(folder, os.path.split(folder)[1]+'.dat')
d = np.loadtxt(fn)

_folder, _file = os.path.split(fn)
_folder, _ = os.path.split(_folder)
_folder, _date = os.path.split(_folder)
title = _date+'/'+_file[:-4]

frq = d[:,1]
cts = d[:,2]
コード例 #5
0
if not (plot_all):
    i = int(raw_input('Plot which gate voltage?'))
    plot_laserscan(d, gate[i])

if fit_all:

    strain_range = (3.5, 12)
    min_counts = 300

    result = []
    gate_filtered = []
    exs = []
    eys = []

    for gv in gate:
        x = d[d[:, 3] == gv, 1]
        y = d[d[:, 3] == gv, 2]
        if max(y) < min_counts:
            continue
        gate_filtered.append(gv)
        (ex, ey) = nvlevels.fit_laserscan(x,
                                          y,
                                          fast=True,
                                          strain_range=strain_range)
        result.append(nvlevels.get_ES_ExEy(ex, ey, fast=True))
        exs.append(ex)
        eys.append(ey)

    arr = np.vstack((array(gate_filtered), array(eys), array(exs)))
    cb.copy_array_2d(arr)
コード例 #6
0
    if plot_all:
        plot_laserscan(d,gv)

if not(plot_all):
    i=int(raw_input('Plot which gate voltage?'))
    plot_laserscan(d,gate[i])

if fit_all:

    strain_range=(3.5,12)
    min_counts=300

    result=[]
    gate_filtered=[]
    exs=[]
    eys=[]

    for gv in gate:
        x=d[d[:,3]==gv,1]
        y=d[d[:,3]==gv,2]
        if max(y)<min_counts:
            continue
        gate_filtered.append(gv)
        (ex,ey)=nvlevels.fit_laserscan(x,y,fast=True,strain_range=strain_range)
        result.append(nvlevels.get_ES_ExEy(ex,ey,fast=True))
        exs.append(ex)
        eys.append(ey)
        
    arr=np.vstack((array(gate_filtered),array(eys),array(exs)))
    cb.copy_array_2d(arr)