Beispiel #1
0
    def do_set_recording(self, val):
        if not self._recording and val:
            self._recording = val
            self._T0 = time.time()
            self._data = qt.Data(name=self._name)
            self._data.add_coordinate('time')
            self._data.add_value('level He1')
            self._data.add_value('level He2')
            self._data.add_value('temperature_lt2')
            self._data.add_value('He1 consumption')
            self._data.add_value('He2 consumption')

            if self._monitor_lt1:
                self._data.add_value('temperature_lt1_A')
                self._data.add_value('temperature_lt1_B')

            self._data.create_file()

            self._plt = qt.Plot2D(self._data,
                                  'ro',
                                  name=self._name,
                                  coorddim=0,
                                  valdim=1,
                                  clear=True)
            self._plt.add(self._data, 'bo', coorddim=0, valdim=2)
            self._plt.add(self._data, 'k-', coorddim=0, valdim=3, right=True)
            if self._monitor_lt1:
                self._plt.add(self._data,
                              'g-',
                              coorddim=0,
                              valdim=6,
                              right=True)
                self._plt.add(self._data,
                              'y+',
                              coorddim=0,
                              valdim=7,
                              right=True)
            self._plt.set_xlabel('time (hours)')
            self._plt.set_ylabel('filling level (cm)')
            self._plt.set_y2label('T (K)')

            self._plt_rates = qt.Plot2D(self._data,
                                        'ro',
                                        name=self._name + '_He_consumption',
                                        coorddim=0,
                                        valdim=4,
                                        clear=True)
            self._plt_rates.add(self._data, 'bo', coorddim=0, valdim=5)
            self._plt_rates.set_xlabel('time (hours)')
            self._plt_rates.set_ylabel('consumption (cm/h)')

            self._rate_update_interval = 1  # hours
            self._rate_times = []
            self._rate_levels1 = []
            self._rate_levels2 = []

        elif self._recording and not val:
            self._recording = val
            self._data.close_file()
def example3(x_vec=numpy.linspace(0,10,10), y_vec=numpy.linspace(0,10,50)):
    '''
    To run the function type in the terminal:
   
    measure_module.example3()
    '''

    qt.mstart()

    data = qt.Data(name='testmeasurement')
    data.add_coordinate('x')
    data.add_coordinate('y')
    data.add_value('z1')
    data.add_value('z2')
    data.add_value('z3')
    data.create_file()

    plot2d_1 = qt.Plot2D(data, name='2D_1', coorddim=1, valdim=2)

    plot2d_2 = qt.Plot2D(data, name='2D_2', coorddim=1, valdim=2, maxtraces=1)

    plot2d_3 = qt.Plot2D(data, name='2D_3', coorddim=1, valdim=2, maxtraces=1)
    plot2d_3.add_data(data, coorddim=1, valdim=3, maxtraces=1)
    plot2d_3.add_data(data, coorddim=1, valdim=4, maxtraces=1)

    plot2d_4 = qt.Plot2D(data, name='2D_4', coorddim=1, valdim=2, mintime=0.3)

    plot2d_5 = qt.Plot2D(data, name='2D_5', coorddim=1, valdim=2, autoupdate=False)

    plot3d_1 = qt.Plot3D(data, name='3D_1', style='image')

    plot3d_2 = qt.Plot3D(data, name='3D_2', style='image', coorddims=(1,0), valdim=4)

    for x in x_vec:
        for y in y_vec:

            z1 = numpy.sin(x+y)
            z2 = numpy.cos(x+y)
            z3 = numpy.sin(x+2*y)

            data.add_data_point(x, y, z1, z2, z3)

            if z1>0:
                plot2d_5.update()

            qt.msleep(0.1)
        data.new_block()

    plot2d_1.save_png()
    plot2d_1.save_gp()

    plot3d_2.save_png()
    plot3d_2.save_gp()

    data.close_file()
    qt.mend()
Beispiel #3
0
def createplots(settings):
    # The next command will actually create the dirs and files, based
    # on the information provided above. Additionally a settingsfile
    # is created containing the current settings of all the instruments.
    data.create_file()
    # Next two plot-objects are created. First argument is the data object
    # that needs to be plotted. To prevent new windows from popping up each
    # measurement a 'name' can be provided so that window can be reused.
    # If the 'name' doesn't already exists, a new window with that name
    # will be created. For 3d plots, a plotting style is set.
    if settings['plot2d'][0] and settings['input'][0] != 0:
        global plot2d1
        plot2d1 = (qt.Plot2D(data,
                             name='measure2D_%s' % (settings['inputlabel'][0]),
                             coorddim=0,
                             valdim=settings['number_of_sweeps'],
                             maxtraces=2))
    if settings['plot3d'][0] and settings['number_of_sweeps'] > 1 and settings[
            'input'][0] != 0:
        global plot3d1
        plot3d1 = (qt.Plot3D(data,
                             name='measure3D_%s' % (settings['inputlabel'][0]),
                             coorddims=(0, 1),
                             valdim=settings['number_of_sweeps'],
                             style='image'))
    if settings['plot2d'][1] and settings['input'][1] != 0:
        global plo2d2
        plot2d2 = qt.Plot2D(data,
                            name='measure2D_%s' % (settings['inputlabel'][1]),
                            coorddim=0,
                            valdim=settings['number_of_sweeps'] + 1,
                            maxtraces=2)
    if settings['plot3d'][1] and settings['number_of_sweeps'] > 1 and settings[
            'input'][1] != 0:
        global plot3d2
        plot3d2 = qt.Plot3D(data,
                            name='measure3D_%s' % (settings['inputlabel'][1]),
                            coorddim=(0, 1),
                            valdim=settings['number_of_sweeps'] + 1,
                            style='image')
    if settings['plot2d'][2] and settings['input'][2] != 0:
        global plot2d3
        plot2d3 = qt.Plot2D(data,
                            name='measure2D_%s' % (settings['inputlabel'][2]),
                            coorddim=0,
                            valdim=settings['number_of_sweeps'] + 2,
                            maxtraces=2)
    if settings['plot3d'][2] and settings['number_of_sweeps'] > 1 and settings[
            'input'][2] != 0:
        global plot3d3
        plot3d3 = qt.Plot3D(data,
                            name='measure3D_%s' % (settings['inputlabel'][2]),
                            coorddim=(0, 1),
                            valdim=settings['number_of_sweeps'] + 2,
                            style='image')
def mstart(runtime):
    qt.mstart()
    #filename = 'values1_test'
    data = qt.Data(name='test_file1')
    data.add_coordinate('time [s]')
    data.add_value(rigol.get_function()[1:-1] + ' e-12')
    data.create_file()
    x_vec = 0
    #runtime = 5
    plot = qt.Plot2D(data, name='test_file1', coorddim=0, valdim=1)
    print 'Measure ' + rigol.get_function()[1:-1]
    sleep(2.00)
    rigol.set_disp_off()
    tstart = time()
    while x_vec < runtime:
        x_vec = time() - tstart
        y_vec = float(rigol.value()[13:]) * 1e12
        data.add_data_point(x_vec, y_vec)
        sleep(0.01)  #wait 10 usec
        print x_vec, y_vec

    data.close_file()
    qt.mend()
    rigol.set_disp_on()
    print 'finished'
    def start(self):
        self._t0 = time.time()
        self.set_is_running(True)

        self._value = 0
        self._time = 0
        self._integral = 0
        self._prev_value = 0
        self._prev_prev_value = 0
        self._prev_time = 0

        self._dat = qt.Data(name=self._name)
        self._dat.add_coordinate('time')
        self._dat.add_value('frequency')
        self._dat.add_value('setpoint')
        self._dat.add_value('control parameter')
        self._dat.create_file()

        self._plt = qt.Plot2D(self._dat,
                              'r-',
                              name=self._name,
                              coorddim=0,
                              valdim=1,
                              maxpoints=100,
                              clear=True)
        self._plt.add(self._dat, 'b-', coorddim=0, valdim=2, maxpoints=100)

        if not (self._get_stabilizor == None):
            self._stabilizor_value = self._get_stabilizor()
        self.get_control_parameter()

        gobject.timeout_add(int(self._read_interval * 1e3), self._update)
def No_B_field():

    append = '_Vb%smV' % Vb_start + '_Vg%sV' % Vg_start  #+'_B8T'
    data = qt.Data(name=filename + append)
    tstr = strftime('%H%M%S_', data._localtime)
    data.add_coordinate('Vb (mV)')  #parameter to step
    data.add_coordinate('Vg (V)')  #parameter to sweep
    data.add_value('I (nA)')  #parameter to readout
    data.create_file(settings_file=False)

    plot2d = qt.Plot2D(data, coorddim=1, valdim=2, traceofs=0)
    plot3d = qt.Plot3D(data, coorddims=(0, 1), valdim=2)

    for Vb in Vb_vec:
        ramp(vi, 'Vb', 0, bias_step_init, bias_time)
        ramp(vi, 'Vg', 0, gate_step_init, gate_time)
        qt.msleep(300)
        ramp(vi, 'Vg', Vg_start, gate_step_init, gate_time)
        ramp(vi, 'Vb', Vb, bias_step_init, bias_time)
        qt.msleep(0.05)
        for Vg in Vg_vec:
            ramp(vi, 'Vg', Vg, gate_step, gate_time)
            qt.msleep(0.05)
            I = vm.get_readval() / IV_gain * unit
            data.add_data_point(Vb, Vg, I)

        data.new_block()
        spyview_process(data, Vg_start, Vg_stop, Vb)

    plot3d.save_png(filepath=directory + '\\' + tstr + filename + append)
    data.close_file()
def B_field():

    append = '_Vb%smV' % Vb_start + '_Vg%sV' % Vg_start + '_B%sT' % abs(
        B_stop)  #to do: for loop for B_vec

    data = qt.Data(name=filename + '_G{0:.0e}'.format(IV_gain))
    data.add_coordinate('Vg (V)')  #parameter to step
    data.add_coordinate('Vb (mV)')  #parameter to sweep
    data.add_value('I (nA)')  #parameter to readout
    data.create_file(settings_file=False)

    plot2d = qt.Plot2D(data, coorddim=1, valdim=2, traceofs=0)
    plot3d = qt.Plot3D(data, coorddims=(0, 1), valdim=2)

    for B in B_vec:
        ramp_B(B)
        for Vg in Vg_vec:
            ramp(vi, 'Vb', Vb_start, bias_step_init, bias_time)
            ramp(vi, 'Vg', Vg, gate_step, gate_time)
            qt.msleep(0.010)
            for Vb in Vb_vec:
                ramp(vi, 'Vb', Vb, bias_step, bias_time)
                qt.msleep(0.025)
                I = vm.get_readval() / IV_gain * unit
                data.add_data_point(Vg, Vb, I)
                qt.msleep(0.005)
                data.new_block()
                spyview_process(data, Vb_start, Vb_stop, Vg)

        plot3d.save_png(filepath=directory + '\\' + filename +
                        '_G{0:.0e}'.format(IV_gain))
        data.new_block()
        data.new_block()

    data.close_file()
Beispiel #8
0
def plot_scan(name, x, y, fit_func=None):
    dat = qt.Data(name='DM_sweep_curve_' + name)
    dat.create_file()
    dat.add_coordinate('Voltage [percentage of V max]')
    dat.add_value('Counts [Hz]')
    if fit_func != None:
        dat.add_value('Fit')
        fd = fit_func(x)

    plt = qt.Plot2D(dat,
                    'rO',
                    name='Optimization curve',
                    coorddim=0,
                    valdim=1,
                    clear=True)
    plt.add_data(dat, coorddim=0, valdim=2)

    plt.set_plottitle(dat.get_time_name())
    if fit_func != None:
        dat.add_data_point(x, y, fd)
    else:
        dat.add_data_point(x, y)

    plt.set_legend(False)

    plt.save_png(dat.get_filepath()[:-3] + '.png')
    dfp = dat.get_filepath()
    dat.close_file()
    return dfp
Beispiel #9
0
    def start(self):
        self._t0 = time.time()
        self.set_is_running(True)

        self._value = 0
        self._time = 0
        self._integral = 0
        self._prev_value = 0
        self._prev_time = 0

        self._dat = qt.Data(name=self._name)
        self._dat.add_coordinate('time')
        self._dat.add_value('frequency')
        self._dat.add_value('setpoint')
        self._dat.add_value('control parameter')
        self._dat.create_file()

        self._plt = qt.Plot2D(self._dat, 'kO', name=self._name, coorddim=0, 
                valdim=1, maxpoints=100, clear=True)
        self._plt.add(self._dat, 'b-', coorddim=0, valdim=2, maxpoints=100)
        
        # self._thread = ControlThread()
        # self._thread.instrument = qt.instruments[self._name]
        # self._thread.interval = self.get_read_interval()
        # self._thread.start()
        #
        gobject.timeout_add(int(self._read_interval*1e3), self._update)
    def run(self, autoconfig=True, setup=True):

        if autoconfig:
            self.autoconfig()
        if setup:
            self.setup()

        self.dat = qt.Data(name=self.name +
                           '_data')  #, inmem=True, infile=False )
        self.dat.add_coordinate('Voltage [V]')
        self.dat.add_coordinate('Frequency [GHz]')
        self.dat.add_value('Counts [Hz]')
        self.dat.create_file(
            filepath=os.path.splitext(self.h5data.filepath())[0] + '.dat')
        self.plt = qt.Plot2D(self.dat,
                             'r-',
                             name='laser_scan',
                             coorddim=1,
                             valdim=2,
                             clear=True)
        if self.params['plot_voltage']:
            self.plt.add_data(self.dat, coorddim=1, valdim=0, right=True)

        self.start_adwin_process(stop_processes=['counter'])
        qt.msleep(1)
        self.start_keystroke_monitor('abort', timer=False)

        prev_px_clock = 0
        aborted = False
        while self.adwin_process_running():
            self._keystroke_check('abort')
            if self.keystroke('abort') in ['q', 'Q']:
                print 'aborted.'
                aborted = True
                self.stop_keystroke_monitor('abort')
                break
            px_clock = self.adwin_var('pixel_clock')
            start = prev_px_clock + 1
            length = px_clock - prev_px_clock
            if length > 0:

                f = self.adwin_var(('laser_frequencies', start, length))
                valid_range = f > -3000
                v = self.adwin_var(('voltages', start, length))
                cs = self.adwin_var(('counts', start, length))
                c = (cs[0] + cs[1]) / (self.params['pixel_time'] * 1.e-6)
                if np.sum(valid_range) > 1:
                    self.dat.add_data_point(v[valid_range], f[valid_range],
                                            c[valid_range])
                    prev_px_clock = px_clock
            qt.msleep(0.2)

            self.plt.update()
        try:
            self.stop_keystroke_monitor('abort')
        except KeyError:
            pass  # means it's already stopped
        self.stop_adwin_process()
        return not (aborted)
Beispiel #11
0
 def _create_data_plots(self,name):
     qtdata = qt.Data(name = name)
     qtdata.add_coordinate('Degrees')
     qtdata.add_value('Counts')
     dataplot = qt.Plot2D(qtdata, 'rO', name = name, coorddim = 0, 
             valdim = 1, clear = True)
     dataplot.add(qtdata, 'b-', coorddim = 0, valdim = 2)
     return qtdata, dataplot
    def calibrate(self, steps): # calibration values in uW
        rng = arange(0,steps)
        x = zeros(steps,dtype = float)
        y = zeros(steps,dtype = float)
        
        self.apply_voltage(0)
        self._ins_pm.set_wavelength(self._wavelength*1e9)
        time.sleep(2)
        bg = self._ins_pm.get_power()

        print 'background power: %.4f uW' % (bg*1e6)

        time.sleep(2)

        V_max = self.get_V_max()
        V_min = self.get_V_min()
        
        if V_max + V_min < 0: rng=flipud(rng)
        
        for a in rng:
            x[a] = a*(V_max-V_min)/float(steps-1)+V_min
            self.apply_voltage(x[a])
            time.sleep(1)
            y[a] = self._ins_pm.get_power() - bg
            
            print 'measured power at %.2f V: %.4f uW' % \
                    (a*(V_max-V_min)/float(steps-1)+V_min, y[a]*1e6)
        
        #x= x*(V_max-V_min)/float(steps-1)+V_min 
        a, xc, k = copysign(max(y), V_max + V_min), copysign(.5, V_max + V_min), copysign(5., V_max + V_min)
        fitres = fit.fit1d(x,y, common.fit_AOM_powerdependence, 
                a, xc, k, do_print=True, do_plot=False, ret=True)
     
        fd = zeros(len(x))        
        if type(fitres) != type(False):
            p1 = fitres['params_dict']
            self.set_cal_a(p1['a'])
            self.set_cal_xc(p1['xc'])
            self.set_cal_k(p1['k'])
            fd = fitres['fitdata']
        else:
            print 'could not fit calibration curve!'
        
        dat = qt.Data(name= 'aom_calibration_'+self._name+'_'+\
                self._cur_controller)
        dat.add_coordinate('Voltage [V]')
        dat.add_value('Power [W]')
        dat.add_value('fit')
        dat.create_file()
        plt = qt.Plot2D(dat, 'rO', name='aom calibration', coorddim=0, valdim=1, 
                clear=True)
        plt.add_data(dat, coorddim=0, valdim=2)
        dat.add_data_point(x,y,fd)
        dat.close_file()
        plt.save_png(dat.get_filepath()+'png')

        self.save_cfg()
        print (self._name+' calibration finished')
Beispiel #13
0
def full_measure2d(coordinate, value, measure_fn, measure_args):
    #set up data object and plot:
    qt.mstart()
    out = measure_fn(*measure_args)  #actual measurement
    data = qt.Data(name=measure_args[5])
    data.add_coordinate('frequency [MHz]')
    data.add_value('magnitude [dBm]')
    data.create_file()
    plot2d = qt.Plot2D(data, name='measure2D')
    data.add_data_point(out[0], out[1])
    data.close_file()
    qt.mend()
    return out
Beispiel #14
0
    def start(self):
        if not self._is_running:
            self._t0 = time.time()

            for p in self._monitor_pars:
                n = self._monitor_pars[p]['name']

                self._monitor_pars[p]['data'] = qt.Data(
                    name='{}_Par{}_{}'.format(self.name, p, n))
                self._monitor_pars[p]['data'].add_coordinate('time')
                self._monitor_pars[p]['data'].add_value('value')

                self._monitor_pars[p]['plot'] = qt.Plot2D(
                    self._monitor_pars[p]['data'],
                    name='Par{}_{}'.format(p, n),
                    coorddim=0,
                    valdim=1,
                    maxpoints=100,
                    clear=True)

            for fp in self._monitor_fpars:
                n = self._monitor_fpars[fp]['name']

                self._monitor_fpars[fp]['data'] = qt.Data(
                    name='{}_FPar{}_{}'.format(self.name, fp, n))
                self._monitor_fpars[fp]['data'].add_coordinate('time')
                self._monitor_fpars[fp]['data'].add_value('value')

                self._monitor_fpars[fp]['plot'] = qt.Plot2D(
                    self._monitor_fpars[fp]['data'],
                    name='FPar{}_{}'.format(fp, n),
                    coorddim=0,
                    valdim=1,
                    maxpoints=100,
                    clear=True)

            self._is_running = True
            gobject.timeout_add(int(self._update_interval * 1e3), self._update)
Beispiel #15
0
    def fidelities(fid_ms0, fid_ms1):
        """
        Performs the analysis for two SSROs with ms=0/1, and
        plots the total measurement fidelity (F) in dependence of the RO time.
        
        The two measurements need to fit (same nr of points, points matching)

        Parameters: The two respective npz files from the analysis of the single
        SSRO measurements.

        returns F, error of F
        """

        d_ms0 = np.load(fid_ms0)
        d_ms1 = np.load(fid_ms1)

        times = d_ms0['time']
        fid0 = d_ms0['fid']
        fid0_err = d_ms0['fid_error']
        fid1 = d_ms1['fid']
        fid1_err = d_ms1['fid_error']
        F = (fid0 + fid1)/2.
        F_err = np.sqrt(fid0_err**2 + fid1_err**2)
        F_max = max(F)
        t_max = times[F.argmax()]


        plot1 = qt.Plot2D(name='fid',clear=True)
        plot1.clear()
        plot1.add(times, F, 'or', title = 'total')
        plot1.add(times, fid1, 'og',title = 'ms = 1')
        plot1.add(times, fid0, 'og',title= 'ms = 0')
        plot1.set_plottitle("max. F=%.2f at t=%.2f us" % (F_max, t_max))
        plot1.set_xlabel('Read-out time (us)')
        plot1.set_ylabel('Fidelity')
        plot1.set_yrange(0.46,1.09)
        print "max. F=%.2f at t=%.2f us" % (F_max, t_max)
 
        f={"times"      : times,
           "t_max"      : t_max,
           "fidelity"   : F,
           "fid0"       : fid0,
           "fid1"       : fid1,
           "f_err"      : F_err,
           "fid0_err"   : fid0_err,
           "fid1_err"   : fid1_err,
           "f_max"      : F_max,
           
                }
        return  f, plot1
Beispiel #16
0
    def measure(self,name):            
    
# create data object
        qt.mstart()

        self.ins_smb.set_iq('off')
        self.ins_smb.set_pulm('off')
        self.ins_smb.set_power(self.MW_power)
        self.ins_smb.set_status('on')

        qt.msleep(0.2)
        self.ins_counters.set_is_running(0)
        total_cnts = np.zeros(self.steps)
        for cur_rep in range(self.reps):
            for i,cur_f in enumerate(self.f_list):
                
                self.ins_smb.set_frequency(cur_f)
                qt.msleep(0.05)
                
                total_cnts[i]+=self.ins_adwin.measure_counts(self.int_time)[self.counter-1]
                # qt.msleep(0.01)

            p_c = qt.Plot2D(self.f_list, total_cnts, 'bO-', name='ESR', clear=True)
            if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break
            print cur_rep
        self.ins_smb.set_status('off')

        d = qt.Data(name=name)
        d.add_coordinate('frequency [GHz]')
        d.add_value('counts')
        d.create_file()

        filename=d.get_filepath()[:-4]

        d.add_data_point(self.f_list, total_cnts)
        pqm.savez(filename,freq=self.f_list,counts=total_cnts)
        d.close_file()
        #p_c = qt.Plot2D(d, 'bO-', coorddim=0, name='ESR', valdim=1, clear=True)
        p_c.save_png(filename+'.png')
        p_c.clear()
        p_c.quit()

        qt.mend()

        self.ins_counters.set_is_running(1)

        return total_cnts, self.f_list
    def start(self):
        if self.get_is_running():
            print self.get_name() + ': ALREADY RUNNING'
            return False
        self.set_is_running(True)

        self._error = 0.
        self._derivator = 0.
        self._integrator = 0.
        self._values = [0]
        self._fine_setpoint = 0
        self._read_counter = -1

        self._t0 = time.time()

        if self.get_do_save_data():
            self._dat = qt.Data(name=self._name)
            self._dat.add_coordinate('time')
            self._dat.add_value('raw frequency')
            self._dat.add_value('avg frequency')
            self._dat.add_value('setpoint')
            self._dat.add_value('control parameter')
            self._dat.create_file()
            if self.get_do_plot():
                self._plt = qt.Plot2D(self._dat,
                                      'r-',
                                      name=self._name,
                                      coorddim=0,
                                      valdim=1,
                                      maxpoints=100,
                                      clear=True)
                self._plt.add(self._dat,
                              'b-',
                              coorddim=0,
                              valdim=2,
                              maxpoints=100)
                self._plt.add(self._dat,
                              'k-',
                              coorddim=0,
                              valdim=3,
                              maxpoints=100)
        if not (self._get_stabilizor == None):
            self._stabilizor_value = self._get_stabilizor()
        self.get_control_parameter()
        self.get_control_parameter_coarse()
        gobject.timeout_add(int(self._read_interval * 1e3), self._update)
Beispiel #18
0
 def plot2d(self, coorddim=0, valdim=0, traceofs=0, **kwargs):
     if valdim == 0:
         valdim = len(self._coords)
     name = kwargs.get('name', self._name)
     try:
         del kwargs['name']
     except:
         pass
     if name in self._plots:
         self._plots[name].update()
     else:
         self._plots[name] = qt.Plot2D(self._data,
                                       name=name,
                                       coorddim=coorddim,
                                       valdim=valdim,
                                       traceofs=traceofs,
                                       **kwargs)
Beispiel #19
0
    def do_set_recording(self, val):
        if not self._recording and val:
            self._recording = val
            self._T0 = time.time()
            self._data = qt.Data(name=self.get_name())
            self._data.add_coordinate('time')
            self._data.add_value('Platform_Temperature')

            self._data.create_file()
            
            self._plt = qt.Plot2D(self._data, 'ro', name=self.get_name(), 
                    coorddim=0, valdim=1, clear=True)
            self._plt.set_xlabel('time (hours)')
            self._plt.set_ylabel('Platform Temperature (K)')
        
        elif self._recording and not val:
            self._recording = val
            self._data.close_file()
def example1(f_vec, b_vec):
    '''
    this example is exactly the same as 'basic_measure_script.py'
    but now made into a function. The main advantage is that now
    the parameters f_vec and b_vec can be provided when calling 
    the function: "measure_module.example1(vec1, vec2)", instead
    of having to change the script. 
   
    To run the function type in the terminal:
   
    fv=numpy.arange(0,10,0.01)
    bv=numpy.arange(-5,5,0.1)
    measure_module.example1(fv, bv)
    '''

    qt.mstart()

    data = qt.Data(name='testmeasurement')
    data.add_coordinate('frequency, mw src 1 [Hz]')
    data.add_coordinate('Bfield, ivvi dac 3 [mV]')
    data.add_value('Psw SQUID')
    data.create_file()

    plot2d = qt.Plot2D(data, name='measure2D')
    plot3d = qt.Plot3D(data, name='measure3D', style='image')

    for b in b_vec:
        fake_ivvi_set_dac_3(b)
        for f in f_vec:
            fake_mw_src_set_freq(f)

            result = fake_readout_psw()
            data.add_data_point(f, b, result)

            qt.msleep(0.01)
        data.new_block()

    data.close_file()
    qt.mend()
Beispiel #21
0
    def calibrate_V_off(self, steps, calrange=(-0.1,0.1)): # calibration values in uW


        if np.max(np.abs(calrange)) > np.max(np.abs((self.get_V_max(), self.get_V_min()))):
            logging.warning(self.get_name() + ' Error: extreme voltage of this channel exceeded: ')
            print 'bad calibration range', calrange
            return

        x = np.linspace(calrange[0], calrange[1], steps)
        y = np.zeros(steps,dtype = float)

        self._calib_off_voltage = True
        for i,xi in enumerate(x):
            self.apply_voltage(xi)
            time.sleep(0.5)
            y[i] = self._ins_pm.get_power()
            print 'measured power at %.2f V: %.4f uW' % \
                    (xi, y[i]*1e6)
        self._calib_off_voltage = False

        dat = qt.Data(name= 'aom_off_calibration_'+self._name+'_'+\
        self._cur_controller)
        dat.add_coordinate('Voltage [V]')
        dat.add_value('Power [W]')
        dat.create_file()
        plt = qt.Plot2D(dat, 'rO', name='aom calibration', coorddim=0, valdim=1, 
                clear=True)
        plt.add_data(dat, coorddim=0, valdim=1)
        dat.add_data_point(x,y)
        dat.close_file()
        plt.save_png(dat.get_filepath()+'png')


        self.set_V_off(x[np.argmin(y)])

        self.save_cfg()

        print 'V off voltage found %.3f.' %self.get_V_off()
        print (self._name+' calibration finished')
Beispiel #22
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')

        p = qt.Plot2D(d, 'ro', title='Frq (left) vs Voltage (bottom)', plottitle=self.mprefix,
                name='Laser Scan', clear=True, xlabel='Voltage (V)', 
                ylabel='Frequency (GHz)', coorddim=0, valdim=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')

        qt.mstart()

        if not self.use_repump_during:
            self.repump_pulse(self.repump_duration)
        
        for v in np.linspace(self.start_voltage, self.stop_voltage, self.pts):
            if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break
            
            self.set_laser_voltage(v)
            qt.msleep(stabilizing_time)

            cts = self.get_counts(self.integration_time)[self.counter_channel]
            frq = self.get_frequency(self.wm_channel)*self.frq_factor - self.frq_offset
            d.add_data_point(v, frq, cts)
            p.update()

        qt.mend()
        d.close_file()

        p.save_png()
Beispiel #23
0
def turnon(DAC_vec):
    '''
    Function to measure turn on, and subsequently pinch off
    To run:
   
    fv=numpy.arange(0,10,0.01)
    bv=numpy.arange(-5,5,0.1)
    SiQD.example1(fv, bv)
    '''
    eefje = qt.instruments.get_instruments()['Eefje']
    elKeef =qt.instruments.get_instruments()['ElKeefLy']
    qt.mstart()

	
    #Set maximum sweep rate to not blow up device
    #40 mV steps, 40 ms waittime per step
    eefje.set_parameter_rate('dac1',40,20)
    
    
    data = qt.Data(name='Turn On Device 2Y')
    data.add_coordinate('Gate voltage V_g [mV]')
    data.add_coordinate('I_{SD} [mV]')

    data.create_file()

    #plot2d = qt.Plot2D(data, name='measure2D')
    #plot3d = qt.Plot3D(data, name='measure3D', style='image')
    plot2d = qt.Plot2D(data, name='measure2D', coorddim=0, valdim=1, traceofs=10)

    for d in DAC_vec:
        eefje.set_dac1(d)
        result = elKeef.get_readlastval()
        data.add_data_point(d, result)

        qt.msleep(0.01)

    data.close_file()
    qt.mend()
def laserscan(dataname, ins_laser_scan=ins_laser_scan):

    ins_laser_scan.set_StartVoltage(start_v)
    ins_laser_scan.set_StopVoltage(stop_v)
    ins_laser_scan.set_ScanSteps(steps)
    ins_laser_scan.set_IntegrationTime(pxtime)
    ins_running = True
    step = 0

    #_before_voltages = ins_adwin.get_dac_voltages(['green_aom','newfocus_aom'])
    #FIXME NEED A CONDITION FOR WHEN THE Newfocus IS ONE THE AWG.

    if LT2:
        GreenAOM.set_power(green_before)
        qt.msleep(1)

        NewfocusAOM.set_power(red_during)
        GreenAOM.set_power(green_during)
    else:
        GreenAOM_lt1.set_power(green_before)
        qt.msleep(1)

        NewfocusAOM_lt1.set_power(red_during)
        GreenAOM_lt1.set_power(green_during)

    #make sure microwaves are off
    ins_mw.set_status('off')

    if mw:
        ins_mw.set_iq('off')
        ins_mw.set_pulm('off')
        ins_mw.set_power(mw_power)
        ins_mw.set_frequency(mw_frq)
        ins_mw.set_status('on')

    qt.mstart()
    qt.Data.set_filename_generator(data.DateTimeGenerator())
    d = qt.Data(name=dataname)
    d.add_coordinate('voltage [V]')
    d.add_value('frequency [GHz]')
    d.add_value('counts')
    d.create_file()

    p_f = qt.Plot2D(d,
                    'rO',
                    name='frequency',
                    coorddim=0,
                    valdim=1,
                    clear=True)
    p_c = qt.Plot2D(d, 'bO', name='counts', coorddim=1, valdim=2, clear=True)

    # go manually to initial position
    ins_adwin.set_dac_voltage(('newfocus_frq', start_v))
    qt.msleep(1)

    ins_laser_scan.start_scan()
    qt.msleep(1)
    timer_id = gobject.timeout_add(abort_check_time, check_for_abort)

    while (ins_running):

        ins_running = not ins_laser_scan.get_TraceFinished()

        _step = ins_laser_scan.get_CurrentStep()

        qt.msleep(0.3)

        if _step > step:
            _v = ins_laser_scan.get_voltages()[step:_step]
            _f = ins_laser_scan.get_frequencies()[step:_step] - f_offset
            _c = ins_laser_scan.get_counts()[step:_step]

            # print _v,_f,_c
            _valid_elmnts = (_f > 0)

            _v = _v[_valid_elmnts]
            _f = _f[_valid_elmnts]
            _c = _c[_valid_elmnts]

            if not (len(_v) == 0):
                if len(_v) == 1:
                    _v = _v[0]
                    _f = _f[0]
                    _c = _c[0]
                d.add_data_point(_v, _f, _c)

            step = _step
            p_f.update()
            p_c.update()

    ins_laser_scan.end_scan()
    gobject.source_remove(timer_id)
    #ins_adwin.set_dac_voltage(['green_aom',_before_voltages[0]])
    #ins_adwin.set_dac_voltage(['newfocus_aom',_before_voltages[1]])
    if mw:
        ins_mw.set_status('off')
    qt.mend()

    pfsave = p_f
    pcsave = p_c

    if do_smooth:
        basepath = d.get_filepath()[:-4]
        ds = qt.Data()
        ds.set_filename_generator(data.IncrementalGenerator(basepath))
        ds.add_coordinate('voltage [V]')
        ds.add_value('smoothed frequency [GHz]')
        ds.add_value('counts')
        ds.create_file()

        p_fs = qt.Plot2D(ds,
                         'r-',
                         name='frequency smoothed',
                         coorddim=0,
                         valdim=1,
                         clear=True)
        p_cs = qt.Plot2D(ds,
                         'b-',
                         name='counts smoothed',
                         coorddim=1,
                         valdim=2,
                         clear=True)

        ds.add_data_point(d.get_data()[:, 0], rolling_avg(d.get_data()[:, 1]),
                          d.get_data()[:, 2])

        ds.close_file()
        pfsave = p_fs
        pcsave = p_cs

    if plot_strain_lines:
        try:
            from analysis 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]))
            pcsave.add(lx, ly)
        except ValueError:
            print 'Could not understand input for lines'
            pass

    pfsave.save_png()
    pcsave.save_png()

    d.close_file()
    qt.Data.set_filename_generator(data.DateTimeGenerator())

    if LT2:
        MatisseAOM.set_power(0)
        NewfocusAOM.set_power(0)
        GreenAOM.set_power(green_before)
        ins_adwin.set_linescan_var(set_phase_locking_on=0,
                                   set_gate_good_phase=0)
    else:
        MatisseAOM_lt1.set_power(0)
        NewfocusAOM_lt1.set_power(0)
        GreenAOM_lt1.set_power(green_before)
#required preperation stuff (FSL)
fsl.reset()
fsl.set_start_frequency(start_frequency)
fsl.set_stop_frequency(stop_frequency)
span = stop_frequency - start_frequency
fsl.set_resolution_bandwidth(bandwidth)
fsl.set_tracking(True)
fsl.set_source_power(rf_power)
#fsl.set_averages(normalization_averages) #set the number of normalization runs
fsl.get_all()  #get all the settings and store it in the settingsfile

#time variable
x_time = 0

print 'prepare 2D plot'
plot = qt.Plot2D(data, name=filename, coorddim=0, valdim=2)  #buggy
#plot3Dx = qt.Plot3D(data, name='x3d', coorddims=(0,1), valdim=2)

print 'Measure with Rigol: ' + rigol.get_function()[1:-1]
sleep(0.01)
#rigol.set_disp_off() #ben's preference
fsl.set_trace_continuous(False)
tstart = time()

print 'Normalization:'
run_index = 0
summed_trace = 0
summed_trace = array(fsl.get_trace())  #first local_trace

while (x_time < max_runtime and run_index < norm_runs):
    x_time = time() - tstart
Beispiel #26
0
    stop_sweep = False
    for cur_rep in range(reps):

        print 'sweep %d/%d ...' % (cur_rep + 1, reps)
        for i, cur_f in enumerate(f_list):
            if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): stop_scan = True
            ins_smb.set_frequency(cur_f)

            # qt.msleep(0.05)
            total_cnts[i] += ins_adwin.measure_counts(int_time)[counter - 1]

        # if cur_rep+1 % 30 == 0:
        #     qt.instruments['GreenAOM'].set_power(green_power)
        #     qt.instruments['optimiz0r'].optimize(dims=['x','y','z','y','x'])

        p_c = qt.Plot2D(name=name, clear=True)
        p_c.add(f_list, total_cnts, 'bO', yerr=np.sqrt(total_cnts))
        p_c.add(f_list, total_cnts, 'b-')

        if stop_scan: break

    ins_smb.set_status('off')

    d = qt.Data(name=name)
    d.add_coordinate('frequency [GHz]')
    d.add_value('counts')
    d.add_value('errors')
    d.create_file()
    filename = d.get_filepath()[:-4]

    d.add_data_point(f_list, total_cnts, np.sqrt(total_cnts))
    data.new_block()
    spyview_process(data, RF_start, RF_stop, vg)
##    for f in arange(RF_stop,RF_start-RF_step,-RF_step):
##        smb.set_RF_frequency(f)
##        qt.msleep(.3)
##        x=lockin.get_X() #or Y or R
##        y=lockin.get_Y()
##        x*=-1e5
##        y*=-1e5
##        data.add_data_point(f,vg,x,y)
##    data.new_block()
##    spyview_process(data,RF_start,RF_stop,vg)

#ramp(vi,'vgate',0,sweepstep,sweeptime)

plot2dx = qt.Plot2D(data, name='xcomp', coorddim=0, valdim=2)
plot3Dx = qt.Plot3D(data, name='x3d', coorddims=(0, 1), valdim=2)
plot2dc = qt.Plot2D(data, name='dccomp', coorddim=0, valdim=4)
plot3Dc = qt.Plot3D(data, name='dc3d', coorddims=(0, 1), valdim=4)

plot2dx.save_png(filepath=data.get_dir() + '\\' + 'plot2dx.png')
plot3Dx.save_png(filepath=data.get_dir() + '\\' + 'plot3Dx.png')
plot2dc.save_png(filepath=data.get_dir() + '\\' + 'plot2dc.png')
plot3Dc.save_png(filepath=data.get_dir() + '\\' + 'plot3Dc.png')

#reset voltages
if returntozero:
    ramp(vi, 'vgate', 0, sweepstep, sweeptime)
    ramp(vi, 'vbias', 0, sweepstep, sweeptime)

vi.get_vgate()
Beispiel #28
0
import numpy as np
import qt

x = np.arange(-10, 10, 0.2)
y = np.sinc(x)
yerr = 0.1 * np.random.rand(len(x))

d = qt.Data()
d.add_coordinate('x')
d.add_coordinate('y')
d.add_coordinate('yerr')
d.create_file()
d.add_data_point(x, y, yerr)

p = qt.Plot2D()
p.add_data(d, coorddim=0, valdim=1, yerrdim=2)

# or:
qt.plot(x, y, yerr=yerr, name='test2')
Beispiel #29
0
def optimize_single_pin(pin_nr):
    #measurement parameters
    pin_nr = pin_nr
    name = 'The111No2_enlarged_SIL2_sweep_single_pin_nr_' + str(pin_nr)
    steps = 11
    cur_F = (okotech_dm.get_voltage(pin_nr) / 2.)**2

    F_min = cur_F - .2
    F_max = cur_F + .2

    #v_min=0
    #v_max=2
    counter = 1  #number of counter
    int_time = 400  # in ms

    current_aom = qt.instruments['GreenAOM']
    current_mos = qt.instruments['master_of_space']
    current_adwin = qt.instruments['adwin']
    DM = qt.instruments['okotech_dm']
    prev_value = DM.get_voltages()[pin_nr - 1]

    if F_min < 0:
        F_min = 0
    if F_max > 1:
        F_max = 1
    F = linspace(F_min, F_max, steps)

    y_NV = zeros(steps, dtype=float)

    br = False
    for i, force in enumerate(F):
        if (msvcrt.kbhit() and (msvcrt.getch() == 'q')):
            br = True
            break
        voltage = 2 * np.sqrt(force)
        DM.set_voltage_single_pin(pin_nr, voltage)
        time.sleep(0.1)

        y_NV[i] = current_adwin.measure_counts(int_time)[counter -
                                                         1] / (int_time * 1e-3)

        #print 'step %s, counts %s'%(i,y_NV[i])

    x_axis = F

    dat = qt.Data(name='DM_sweep_curve_' + name)
    dat.create_file()
    dat.add_coordinate('Displacement [a.u.]')
    dat.add_value('Counts [Hz]')
    plt = qt.Plot2D(dat,
                    'rO',
                    name='Saturation curve',
                    coorddim=0,
                    valdim=1,
                    clear=True)
    plt.add_data(dat, coorddim=0, valdim=2)

    plt.set_plottitle(dat.get_time_name())
    dat.add_data_point(x_axis, y_NV)
    plt.set_legend(False)

    plt.save_png(dat.get_filepath() + 'png')
    dat.close_file()

    highest_cntrate_idx = tb.nearest_idx(y_NV, y_NV.max())
    opt_V = 2 * np.sqrt(F[highest_cntrate_idx])
    DM.set_voltage_single_pin(pin_nr, opt_V)
    counters.set_is_running(True)
Beispiel #30
0
    def run(self, name, **kw):
        central_freq = 2.88
        start_f = central_freq + 0.10  #1.85#2.878 - 0.08 #   2.853 #2.85 #  #in GHz
        stop_f = central_freq - 0.10  #1.95#2.878 + 0.08 #   2.864 #2.905 #   #in GHz
        steps = 101
        mw_power = kw.pop('mw_power', -18)  #in dBm, never above -10
        green_power = kw.pop('green_power', 90e-6)  #20e-6
        int_time = 150  #in ms
        reps = 2
        f_list = np.linspace(start_f * 1e9, stop_f * 1e9, steps)
        ins_smb = qt.instruments['SMB100']
        ins_adwin = qt.instruments['adwin']
        ins_counters = qt.instruments['counters']
        counter = 1
        MW_power = mw_power
        ins_counters.set_is_running(0)
        qt.mstart()
        ins_smb.set_power(MW_power)

        # create data object

        ins_smb.set_iq('off')
        ins_smb.set_pulm('off')

        ins_smb.set_status('on')

        qt.msleep(0.2)
        #ins_counters.set_is_running(0)
        total_cnts = np.zeros(steps)
        #qt.instruments['GreenAOM'].set_power(green_power)
        stop_scan = False
        for cur_rep in range(reps):

            print 'sweep %d/%d ...' % (cur_rep + 1, reps)
            # optimiz0r.optimize(dims=['x','y','z'],int_time=50)
            for i, cur_f in enumerate(f_list):
                if (msvcrt.kbhit() and (msvcrt.getch() == 'q')):
                    stop_scan = True
                ins_smb.set_frequency(cur_f)

                qt.msleep(0.02)
                total_cnts[i] += ins_adwin.measure_counts(int_time)[counter -
                                                                    1]

                qt.msleep(0.01)

            p_c = qt.Plot2D(f_list, total_cnts, 'bO-', name='ESR', clear=True)

            if stop_scan: break

        ins_smb.set_status('off')

        d = qt.Data(name=name)
        d.add_coordinate('frequency [GHz]')
        d.add_value('counts')
        d.create_file()
        filename = d.get_filepath()[:-4]

        d.add_data_point(f_list, total_cnts)
        d.close_file()
        p_c = qt.Plot2D(d, 'bO-', coorddim=0, name='ESR', valdim=1, clear=True)
        p_c.save_png(filename + '.png')

        success = self.analyse_data(filename + '.dat')

        qt.mend()

        ins_counters.set_is_running(1)
        return success