Ejemplo n.º 1
0
def main():

    if not debug_mode:
        initialize_hh()

    generate_sequence()

    repetitions = par_reps
    hh_measurement_time = int(1e3 * 60 * par_meas_time)  #ms

    qt.mstart()

    cr_stats = qt.Data(name='Statistics_cr_checks')
    cr_stats.add_coordinate('repetition nr')
    cr_stats.add_value('lt1_cr_below threshold')
    cr_stats.add_value('lt1_cr_checks')
    cr_stats.add_value('lt2_cr_below_threshold')
    cr_stats.add_value('lt2_cr_checks')
    cr_stats.add_value('tpqi_starts')
    cr_stats.add_value('lt1_repump_cts')
    cr_stats.add_value('lt2_repump_cts')
    cr_stats.add_value('lt1_triggers_received')
    cr_stats.add_value('lt2_triggers_sent')
    cr_stats.add_value('lt1_oks_sent')
    cr_stats.add_value('lt2_oks_received')
    cr_stats.create_file()

    histogram_summed = zeros((par_range_sync, par_range_g2))
    hist_roi_summed = zeros(par_range_g2)

    for idx in arange(repetitions):

        if msvcrt.kbhit():
            kb_char = msvcrt.getch()
            if kb_char == "q": break

        print 'Starting measurement cycle', idx, 'current time:', time.strftime(
            '%H:%M', time.localtime())
        [histogram, hist_ch0, hist_ch1, hist_ch1_long,
         hist_roi] = measurement_cycle(hh_measurement_time)

        print_save_cr_check_info(cr_stats, idx)

        if not debug_mode:
            histogram_summed += histogram
            hist_roi_summed += hist_roi
        print 'Finished measurement cycle', idx, 'start saving'

        data = qt.Data(name='interference' + "_" + str(idx))
        data.add_coordinate('dt')
        data.add_coordinate('sync')
        data.add_value('counts')
        save_and_plot_data(data, histogram, histogram_summed, hist_ch0,
                           hist_ch1, hist_ch1_long, hist_roi, hist_roi_summed)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

    cr_stats.close_file()
    qt.mend()
    end_measuring()
Ejemplo n.º 2
0
    def get_trace(self, mode='lin'):
        '''
        Send trigger to device, wait for aquiring the data,
        and read back the data from the device.
        '''
        qt.mstart()

        startfreq = self.get_start_freq(query=False)
        stopfreq = self.get_stop_freq(query=False)
        numpoints = self.get_numpoints(query=False)

        if mode == 'lin':
            freqs = numpy.linspace(startfreq, stopfreq, numpoints)
        elif mode == 'log':
            freqs = numpy.logspace(numpy.log10(startfreq),
                                   numpy.log10(stopfreq), numpoints)
        else:
            print 'mode needs to be either "lin" or "log"!'
            return False

        sweep_time = self.get_sweep_time(query=False)

        print 'sending trigger to network analyzer, and wait to finish'
        print 'estimated waiting time: %.2f s' % sweep_time
        self.send_trigger()
        qt.msleep(sweep_time)

        print 'readout network analyzer'
        reply = self.read()
        reply = numpy.array(reply)

        qt.mend()

        return (freqs, reply)
Ejemplo n.º 3
0
    def measure_1d_lowpass(
        self, x_vec, coordname, set_param_func, iterations=1, comment=None, dirname=None, plotLive=True
    ):
        """
            acquire _averages traces per value in x_vec and store the time-averaged result

            x_vec - vector of values to pass to set_param_func at the start of each iteration
            coordname - friendly name of the parameter contained in x_vec
            set_param_func - parameter values are passed to this function at the start of each iteration
            comment - comment line in the data file
            dirname - data is saved in directories named <time>_spec_<dirname>
            plotLive - plot data during measurement
        """
        qt.mstart()

        if dirname == None:
            dirname = coordname
        data = qt.Data(name="spec_lp_%s" % dirname)
        if comment:
            data.add_comment(comment)
        data.add_coordinate(coordname)
        data.add_value("ch0")
        if self._numchannels == 2:
            data.add_value("ch1")
        if iterations > 1:
            data.add_coordinate("iteration")
        data.create_file()

        plot_ch0 = qt.Plot2D(data, name="waveform_ch0", coorddim=0, valdim=1, maxtraces=2)
        if self._numchannels == 2:
            plot_ch1 = qt.Plot2D(data, name="waveform_ch1", coorddim=0, valdim=2, maxtraces=2)

        set_param_func(x_vec[0])

        # measurement loop
        for i in range(iterations):
            data.new_block()
            for x in x_vec:
                set_param_func(x)
                # sleep(td)
                qt.msleep()  # better done during measurement (waiting for trigger)

                dat_x = [x]
                dat_mean = numpy.mean(self.acquire(), axis=0)
                dat = numpy.append(dat_x, dat_mean, axis=0)
                if iterations > 1:
                    dat = numpy.append(dat, [i], axis=0)
                data.add_data_point(*dat)

                plot_ch0.update()
                if self._numchannels == 2:
                    plot_ch1.update()

            plot_ch0.update()
            plot_ch0.save_png()
            plot_ch0.save_gp()
            if self._numchannels == 2:
                plot_ch1.update()
                plot_ch1.save_png()
                plot_ch1.save_gp()
Ejemplo n.º 4
0
def scan_coup(fr, span=200e6, step=np.pi / 100, thetaspan=2 * np.pi):
    '''
    Scans the coupling over 360 degrees and finds the best angle for which the depth is maximum, which can then be given as the initial simplex of the Nelder-Mead algorithm.
        fr:center frequency
        span: span of the VNA
        step: minimum step size in angle during the scan 
        thetaspan:range of theta values over which to scan the couplings.  
    '''
    qt.mstart()
    vna.set_span(span)
    set_vna(fr)
    # tnm.move_absolute(0)
    # tnm.wait()
    current_position = tnm.get_position()
    # print "zero set",current_position
    depths = []
    positions = np.arange(current_position, current_position + thetaspan, step)
    for i in range(int(thetaspan / step) + 1):
        dep = tone_depth(fr, rbw=1e6)['depth (dB)']
        if dep < -25: break
        depths.append(dep)
        tnm.move_relative(step)
        tnm.wait()
        print tnm.get_position()
    qt.mend()
Ejemplo n.º 5
0
    def measure_2D_AWG(self):
        '''
        x_vec is sequence in AWG
        '''

        if self.y_set_obj == None:
            print 'axes parameters not properly set...aborting'
            return

        qt.mstart()
        qt.msleep(
        )  #if stop button was pressed by now, abort without creating data files

        self.mode = 3  #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG
        self._prepare_measurement_file()

        if self.show_progress_bar:
            p = Progress_Bar(len(self.y_vec), name=self.dirname)
        try:
            # measurement loop
            for it in range(len(self.y_vec)):
                qt.msleep(
                )  # better done during measurement (waiting for trigger)
                self.y_set_obj(self.y_vec[it])
                self._append_data(iteration=it)
                if self.show_progress_bar: p.iterate()
        finally:
            self._end_measurement()

            qt.mend()
Ejemplo n.º 6
0
 def measure_2D_AWG(self):
     '''
     x_vec is sequence in AWG
     '''
     
     if self.y_set_obj == None:
         print 'axes parameters not properly set...aborting'
         return
 
     qt.mstart()
     qt.msleep()   #if stop button was pressed by now, abort without creating data files
     
     self.mode = 3 #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG
     self._prepare_measurement_file()
     
     if self.show_progress_bar: 
         p = Progress_Bar(len(self.y_vec),name=self.dirname)
     try:
         # measurement loop
         for it in range(len(self.y_vec)):
             qt.msleep() # better done during measurement (waiting for trigger)
             self.y_set_obj(self.y_vec[it])
             self._append_data(iteration=it)
             if self.show_progress_bar: p.iterate()
     finally:
         self._end_measurement()
     
         qt.mend()
    def get_data(self, n=1, enable_continuous=False):
        """
        Reads out the nth trace

        Input:
            None

        Output:
            2D ndarray
        """
        logging.debug(__name__ + " : Get the data ")
        qt.mstart()
        sweep_time = float(self._visainstrument.query(":SENSe:SWEep:TIME?"))
        # print sweep_time
        self._visainstrument.write(":INIT:CONT OFF")
        self._visainstrument.write(":INIT:IMMediate")
        wait_time = 1.05 * sweep_time * self.get_averages(query=False)
        ##        print time.ctime()
        #        print 'waiting %f seconds'%wait_time
        qt.msleep(wait_time + 0.5)
        #        print time.ctime()
        #        print 'reading'
        try:
            datastr = self._visainstrument.query(":FETCh:SANalyzer" + str(n) + "?")
        except Exception as error:
            pass
        finally:
            datastr = self._visainstrument.query(":FETCh:SANalyzer" + str(n) + "?")

        if enable_continuous:
            self._visainstrument.write(":INIT:CONT ON")
        qt.mend()
        return np.reshape(np.array(datastr.split(","), dtype=float), (-1, 2))
Ejemplo n.º 8
0
    def measure_2D(self):

        if self.x_set_obj == None or self.y_set_obj == None:
            print 'axes parameters not properly set...aborting'
            return
        if self.ReadoutTrace:
            raise ValueError(
                'ReadoutTrace is currently not supported for 2D measurements')

        qt.mstart()
        self.mode = 2  #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG
        self._prepare_measurement_file()
        #self._create_dat_plots(mode='2d')

        if self.show_progress_bar:
            p = Progress_Bar(len(self.x_vec) * len(self.y_vec),
                             name=self.dirname)
        try:
            # measurement loop
            for x in self.x_vec:
                self.x_set_obj(x)
                for y in self.y_vec:
                    qt.msleep()
                    self.y_set_obj(y)
                    qt.msleep()
                    self._append_data()
                    if self.show_progress_bar: p.iterate()
                self._hdf_amp.next_matrix()
                self._hdf_pha.next_matrix()
        finally:
            self._end_measurement()
            qt.mend()
Ejemplo n.º 9
0
    def measure_2D(self):

        if self.x_set_obj == None or self.y_set_obj == None:
            print 'axes parameters not properly set...aborting'
            return
        if self.ReadoutTrace:
            raise ValueError('ReadoutTrace is currently not supported for 2D measurements')
        
        qt.mstart()
        self.mode = 2 #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG
        self._prepare_measurement_file()
        #self._create_dat_plots(mode='2d')

        if self.show_progress_bar: p = Progress_Bar(len(self.x_vec)*len(self.y_vec),name=self.dirname)
        try:
            # measurement loop
            for x in self.x_vec:
                self.x_set_obj(x)
                for y in self.y_vec:
                    qt.msleep() 
                    self.y_set_obj(y)
                    qt.msleep() 
                    self._append_data()
                    if self.show_progress_bar: p.iterate()
                self._hdf_amp.next_matrix()
                self._hdf_pha.next_matrix()
        finally:
            self._end_measurement()
            qt.mend()
Ejemplo n.º 10
0
def test_hh():
    
    qt.mstart()
    initialize_hh()
    hharp.StartMeas(int(1e3 * 60 * 2))
    [histogram,hist_ch0,hist_ch1,hist_ch1_long] = hharp.get_T3_pulsed_g2_2DHistogram_v2(
                binsize_T3 = par_binsize_T3,
                binsize_sync=par_binsize_sync,
                range_sync=par_range_sync,
                binsize_g2=par_binsize_g2,
                range_g2=par_range_g2,
                sync_period = par_sync_period,
                )
    data = qt.Data(name='interference test_hh')
    data.add_coordinate('dt')
    data.add_coordinate('sync')
    data.add_value('counts')
    
    cr_stats = qt.Data(name = 'Statistics_cr_checks') 
    cr_stats.add_coordinate('repetition nr')
    cr_stats.add_value('lt1_cr_succes_percentage')
    cr_stats.add_value('lt1_cr_checks')
    cr_stats.add_value('lt2_cr_succes_percentage')
    cr_stats.add_value('lt2_cr_checks')
    cr_stats.add_value('tpqi_starts')
   
    save_and_plot_data(data,histogram,histogram,hist_ch0,hist_ch1,hist_ch1_long)
    qt.mend()
    optimize()
Ejemplo n.º 11
0
	def measure_2D_AWG(self):
		'''
		x_vec is sequence in AWG
		'''
		
		if self.y_set_obj == None:
			print 'axes parameters not properly set...aborting'
			return
	
		qt.mstart()
		qt.msleep()   #if stop button was pressed by now, abort without creating data files
		
		self._prepare_measurement_dat_file(mode='2dAWG')
		self._create_dat_plots(mode='2dAWG')

		p = Progress_Bar(len(self.y_vec),name=self.dirname)
		try:
			# measurement loop
			for it in range(len(self.y_vec)):
				qt.msleep() # better done during measurement (waiting for trigger)
				self.y_set_obj(self.y_vec[it])
				self._append_data([self.y_vec[it]],trace=True,it=it)
				self._update_plots()
				p.iterate()
		#except Exception as e:
		#	print e
		
		finally:
			self._safe_plots()
			self._generate_avg_data(final=True)
			self._close_files()
		
			qt.mend()
Ejemplo n.º 12
0
	def measure_2D(self):

		if self.x_set_obj == None or self.y_set_obj == None:
			print 'axes parameters not properly set...aborting'
			return
		
		qt.mstart()
		self._prepare_measurement_dat_file(mode='2d')
		self._create_dat_plots(mode='2d')

		p = Progress_Bar(len(self.x_vec)*len(self.y_vec),name=self.dirname)
		try:
			# measurement loop
			for x in self.x_vec:
				self.x_set_obj(x)
				if self.save_dat: self.data_raw.new_block()
				for y in self.y_vec:
					qt.msleep() # better done during measurement (waiting for trigge
					self.y_set_obj(y)
					#sleep(self.tdy)
					qt.msleep() # better done during measurement (waiting for trigger)
					self._append_data([x,y],trace=False)
					self._update_plots()
					p.iterate()
		finally:
			self._safe_plots()
			self._close_files()
			qt.mend()
Ejemplo n.º 13
0
def main():

    initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = 3 * 6
    hh_measurement_time = int(1e3 * 60 * 20)

    qt.mstart()
    histogram = zeros((200, 2000))
    for idx in arange(repetitions):
        if msvcrt.kbhit() and msvcrt.getch() == "q": break
        print 'Starting measurement cycle', idx
        histogram += measurement_cycle(hh_measurement_time)
        print 'Finished measurement cycle', idx, 'start saving'
        data = qt.Data(name='interference' + str(idx))
        data.add_coordinate('dt')
        data.add_coordinate('sync')
        data.add_value('counts')
        save_and_plot_data(data, histogram)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

        if not optimize(): break
        print 'Optimisation step', idx, ' completed'

    qt.mend()
    optimize()
Ejemplo n.º 14
0
def main():

    initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = 3*6 
    hh_measurement_time = int(1e3 * 60 * 20 )

    qt.mstart()
    histogram=zeros((200,2000))
    for idx in arange(repetitions):
        if msvcrt.kbhit() and msvcrt.getch() == "q" : break
        print 'Starting measurement cycle', idx
        histogram += measurement_cycle(hh_measurement_time)
        print 'Finished measurement cycle', idx, 'start saving'
        data = qt.Data(name='interference'+str(idx))
        data.add_coordinate('dt')
        data.add_coordinate('sync')
        data.add_value('counts')
        save_and_plot_data(data,histogram)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

        if not optimize(): break
        print 'Optimisation step', idx, ' completed'
    
    qt.mend()
    optimize()
Ejemplo n.º 15
0
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'
Ejemplo n.º 16
0
    def get_trace(self, mode='lin'):
        '''
        Send trigger to device, wait for aquiring the data,
        and read back the data from the device.
        '''
        qt.mstart()

        startfreq = self.get_start_freq(query=False)
        stopfreq = self.get_stop_freq(query=False)
        numpoints = self.get_numpoints(query=False)

        if mode=='lin':
            freqs = numpy.linspace(startfreq,stopfreq,numpoints)
        elif mode=='log':
            freqs = numpy.logspace(numpy.log10(startfreq),numpy.log10(stopfreq),numpoints)
        else:
            print 'mode needs to be either "lin" or "log"!'
            return False

        sweep_time = self.get_sweep_time(query=False)
        
        print 'sending trigger to network analyzer, and wait to finish'
        print 'estimated waiting time: %.2f s' % sweep_time
        self.send_trigger()
        qt.msleep(sweep_time)
    
        print 'readout network analyzer'
        reply = self.read()
        reply = numpy.array(reply)
    
        qt.mend()

        return (freqs, reply)
Ejemplo n.º 17
0
def launch2Dmeasurement(measurement_name):
    '''
    Performs a 2D measurement: y=f(x)
    Input: measurement_name <string>: name of the measurement
    '''
    initialize_instruments()
    #################################################################
    #Qt.Data File Creation
    #################################################################
    data = create_measurement_datafile(
        '2D', measurement_name)  #Create the data file for a 2D measurement
    initialize_settings(
        data,
        dimension=2)  #Save current scripts and modules in the data directory
    print '2D Measurement'
    print data
    print 'Saved in: ' + data.get_dir()
    #################################################################
    #Run the list of functions user-selected in settings._init_sweep
    #################################################################
    initialize_sweep()
    #################################################################
    # Measure
    #################################################################
    points = arange(0.0,
                    settings.get_npoints_x() + 1,
                    1.0)  # points: array of steps, including hysteresis
    if settings.get_hysteretic_x():
        points = concatenate((points, points[::-1]))
    qt.mstart()  #Send Start signal to qt
    #Measurement Loop
    for point in points:
        result = list()  #list to fill with data point (x1,x2,x3,y1,y2,y3,...)
        # set all the coordinates
        for coordinate in settings.get_coordinates_x():
            #Calculate value to set
            setvalue = ((coordinate[3] - coordinate[2]) *
                        point) / settings.get_npoints_x() + coordinate[2]
            result.append(setvalue)
            setdevicevalue(coordinate[0], coordinate[1], setvalue)
        # wait for result
        qt.msleep(settings.get_waittime())
        # execute the functions to prepare the reading
        execute_function_list_point
        # read out all the values
        for value in settings.get_values():
            y = getdevicevalue(value[0], value[1])
            result.append(y)
        # save the data point
        data.add_data_point(*result)
        data.emit('new-data-point')

    #################################################################
    # Closing
    #################################################################
    terminate_sweep()
    data.close_file()
    qt.msleep(3)
    settings.copy_tree()
Ejemplo n.º 18
0
def ht_calibrate(f_vec, p_vec):
    '''
    this example is based on 'measure_module.py'
    you will need to set up a vector of frequencies and then call the
    measurment script.

    To run the function type in the terminal:

    fv = numpy.arange(1e9,2e9,50e6)
    esr_meas.simple(fv,power,TC)
    '''


    n63 = qt.instruments['NIDAQ6363']
    pxi = qt.instruments['pxi']

    qt.mstart()

    data = qt.Data(name='herotek_calibration')
    data.add_coordinate('Frequency, NI_RFSG [GHz]')
    data.add_coordinate('Power, NI_RFSG [dBm]')
    data.add_value('Analog Input (V)')
    data.create_file()

    p2d = qt.Plot2D(data, 'bO',
    name = 'Herotek',
    clear = True,
    coorddim = 1,
    valdim = 2,
    maxtraces = 1)

    p3d = qt.Plot3D(data, name='measure3D', coorddims=(0,1), valdim=2, style='image')

    pxi.set_power(-50)
    pxi.set_frequency(1e9)
    pxi.set_status('on')
    for f in f_vec:
        pxi.set_frequency(f)
        logging.debug('frequency set: %s GHz' % (f*1e-9))
        if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break
        for p in p_vec:
            pxi.set_power(p)
            qt.msleep(0.1)
            logging.debug(__name__ + 'power set to: %s dBm' % (p))
            tot = 0
            Navg = 128
            for i in numpy.arange(0,Navg):
                tot = tot + n63.get_ai0()
            meas_v = tot/Navg
            data.add_data_point(f*1e-9,p,meas_v)
        data.new_block()
        p3d.update()



    pxi.set_status('off')
    data.close_file()
    qt.mend()
Ejemplo n.º 19
0
def main():

    counters_lt1.set_is_running(0)
    counters.set_is_running(0)
  
    if not debug_mode:initialize_hh()

    generate_sequence()

    # configure measurement
    repetitions = par_reps

    hh_measurement_time = int(1e3 * 60 *  par_meas_time) #ms

    qt.mstart()
    
    cr_stats = qt.Data(name = 'Statistics_cr_checks') 
    cr_stats.add_coordinate('repetition nr')
    cr_stats.add_value('lt1_cr_below threshold')
    cr_stats.add_value('lt1_cr_checks')
    cr_stats.add_value('lt2_cr_below_threshold')
    cr_stats.add_value('lt2_cr_checks')
    cr_stats.add_value('tpqi_starts')
    cr_stats.add_value('lt1_repump_cts')
    cr_stats.add_value('lt2_repump_cts')
    cr_stats.add_value('lt1_triggers_received')
    cr_stats.add_value('lt2_triggers_sent')
    cr_stats.add_value('lt1_oks_sent')
    cr_stats.add_value('lt2_oks_received')
    cr_stats.create_file()

    gated_ch0_summed=zeros(par_range_g2)
    gated_ch1_summed=zeros(par_range_g2)
    
    for idx in arange(repetitions):
        if msvcrt.kbhit():
            kb_char=msvcrt.getch()
            if kb_char == "q" : break
        
        print 'Starting measurement cycle', idx, 'current time:', time.strftime('%H:%M',time.localtime())
        [hist_ch0, hist_ch1, gated_ch0, gated_ch1] = measurement_cycle(hh_measurement_time)

#        gated_ch0_summed += gated_ch0
#        gated_ch1_summed += gated_ch1
        print 'Finished measurement cycle', idx, 'start saving'
        
        print_save_cr_check_info(cr_stats,idx)

        data = qt.Data(name='PLU_calibration'+"_"+str(idx))
        data.add_coordinate('dt')
        data.add_value('counts')
        save_and_plot_data(data,hist_ch0, hist_ch1, gated_ch0, gated_ch1,gated_ch0_summed,gated_ch1_summed)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

    cr_stats.close_file()    
    qt.mend()
    end_measuring()
def main():

    generate_sequence()
    awg.set_runmode("SEQ")
    awg.start()
    while awg.get_state() != "Waiting for trigger":
        qt.msleep(1)

    repetitions = par_reps
    hh_measurement_time = int(1e3 * 60 * par_meas_time)  # ms

    qt.mstart()

    cr_stats = qt.Data(name="Statistics_cr_checks")
    cr_stats.add_coordinate("repetition nr")
    cr_stats.add_value("lt1_cr_below threshold")
    cr_stats.add_value("lt1_cr_checks")
    cr_stats.add_value("lt2_cr_below_threshold")
    cr_stats.add_value("lt2_cr_checks")
    cr_stats.add_value("tpqi_starts")
    cr_stats.add_value("lt1_repump_cts")
    cr_stats.add_value("lt2_repump_cts")
    cr_stats.add_value("lt1_triggers_received")
    cr_stats.add_value("lt2_triggers_sent")
    cr_stats.add_value("lt1_oks_sent")
    cr_stats.add_value("lt2_oks_received")
    cr_stats.create_file()

    for idx in arange(repetitions):

        if msvcrt.kbhit():
            kb_char = msvcrt.getch()
            if kb_char == "q":
                break

        print "Starting measurement cycle", idx, "current time:", time.strftime("%H:%M", time.localtime())
        measurement_cycle(hh_measurement_time)

        print_save_cr_check_info(cr_stats, idx)

        if not debug_mode:
            histogram_summed += histogram
            hist_roi_summed += hist_roi
        print "Finished measurement cycle", idx, "start saving"

        data = qt.Data(name="interference" + "_" + str(idx))
        data.add_coordinate("dt")
        data.add_coordinate("sync")
        data.add_value("counts")
        save_and_plot_data(
            data, histogram, histogram_summed, hist_ch0, hist_ch1, hist_ch1_long, hist_roi, hist_roi_summed
        )
        print "Data saving cycle", idx, "completed"
        qt.msleep(1)

    cr_stats.close_file()
    qt.mend()
    end_measuring()
Ejemplo n.º 21
0
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()
Ejemplo n.º 22
0
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()
 def run(self):
     qt.mstart()
     self.Fire()
     qt.msleep(0.1)
     while not self.buttons[8]:
         print "=============================="
         self.Fire()
         qt.msleep(0.1)
     qt.mend()
     print "So long, and thanks for all the fish!"
Ejemplo n.º 24
0
 def run(self):
     qt.mstart()
     self.Fire()
     qt.msleep(0.1)
     while not self.buttons[8]:
         print "=============================="
         self.Fire()
         qt.msleep(0.1)
     qt.mend()
     print "So long, and thanks for all the fish!"
def main():

    initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = 4
    hh_measurement_time = int(1e3 * 60 * 15)  #ms

    qt.mstart()

    cr_stats = qt.Data(name='Statistics_cr_checks')
    cr_stats.add_coordinate('repetition nr')
    cr_stats.add_value('lt1_cr_succes_percentage')
    cr_stats.add_value('lt1_cr_checks')
    cr_stats.add_value('lt2_cr_succes_percentage')
    cr_stats.add_value('lt2_cr_checks')
    cr_stats.add_value('tpqi_starts')
    cr_stats.add_value('lt1_repump_cts')
    cr_stats.add_value('lt2_repump_cts')
    cr_stats.add_value('lt1_triggers_received')
    cr_stats.add_value('lt2_triggers_sent')
    cr_stats.add_value('lt1_oks_sent')
    cr_stats.add_value('lt2_oks_received')
    cr_stats.create_file()

    histogram_summed = zeros((par_range_sync, par_range_g2))
    for idx in arange(repetitions):
        if msvcrt.kbhit() and msvcrt.getch() == "q": break

        print 'Starting measurement cycle', idx, 'current time:', time.strftime(
            '%H:%M', time.localtime())
        [histogram, hist_ch0, hist_ch1,
         hist_ch1_long] = measurement_cycle(hh_measurement_time)
        print_save_cr_check_info(cr_stats, idx)

        print shape(histogram)
        histogram_summed += histogram
        print 'Finished measurement cycle', idx, 'start saving'

        data = qt.Data(name='interference' + str(idx))
        data.add_coordinate('dt')
        data.add_coordinate('sync')
        data.add_value('counts')

        save_and_plot_data(data, histogram, histogram_summed, hist_ch0,
                           hist_ch1, hist_ch1_long)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

        if not optimize(): break
        print 'Optimisation step', idx, ' completed'

    cr_stats.close_file()
    qt.mend()
Ejemplo n.º 26
0
def meas_BW(min_pos, max_pos, steps, name = 'beamwaist'):


#generate list of steps
    x_list = numpy.linspace(min_pos, max_pos, steps)

    ins_xps = qt.instruments['xps']
    ins_fm = qt.instruments['fm']


    # create data object
    qt.mstart()

    qt.msleep(0.2)


    d = qt.Data(name='BeamWaist')
    d.add_coordinate('displacement (mm)')
    d.add_value('power')
    d.create_file()
    filename=d.get_filepath()[:-4]

    plot2d = qt.Plot2D(d, name=name)
    stop_scan = False
    result = numpy.zeros(steps)
    for i,cur_x in enumerate(x_list):

        if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): stop_scan=True
        ins_xps.set_abs_positionZ(float(-1*cur_x))

        qt.msleep(0.05)
        result[i] = ins_fm.get_power()
        d.add_data_point(cur_x, result[i])

        if stop_scan: break


    ins_xps.set_abs_positionZ(-1*min_pos)
    i_max = result.tolist().index(max(result))
    i_min = result.tolist().index(min(result))

    print 'result imax is: %s' % result[i_max]
    knife_fit = fit.fit1d(x_list, result,fit_knife_simple, result[i_max],
                    0, 2, result[i_min], do_print=False,ret=True)
    if type(knife_fit) != dict:
                print 'fit failed!'
    else:
        print 'best fit params are: A: %.03f x0: %.03f w: %.03f b: %.03f' % (
        knife_fit['params'][0], knife_fit['params'][1], knife_fit['params'][2],
        knife_fit['params'][3])
    plot2d.set_plottitle('Beam Waist: %.03f +- %.03f' % (knife_fit['params'][2], knife_fit['error'][2]))
    d.close_file()
    plot2d.save_png(filename+'.png')

    qt.mend()
Ejemplo n.º 27
0
    def measure_1D(self):
        '''
        measure method to record a single (averaged) VNA trace, S11 or S21 according to the setting on the VNA
        '''
        self._scan_1D = True
        self._scan_2D = False
        self._scan_3D = False

        if not self.dirname:
            self.dirname = 'VNA_tracedata'
        self._file_name = self.dirname.replace(' ', '').replace(',','_')
        if self.exp_name:
            self._file_name += '_' + self.exp_name
        self._prepare_measurement_vna()
        self._prepare_measurement_file()

        """opens qviewkit to plot measurement, amp and pha are opened by default"""
        if self.open_qviewkit:
            qviewkit.plot(self._data_file.get_filepath(), datasets=['amplitude', 'phase'])
        if self._fit_resonator:
            self._resonator = resonator(self._data_file.get_filepath())

        print 'recording trace...'
        sys.stdout.flush()

        qt.mstart()
        self.vna.avg_clear()
        if self.vna.get_averages() == 1 or self.vna.get_Average() == False:   #no averaging
            self._p = Progress_Bar(1,self.dirname,self.vna.get_sweeptime())
            qt.msleep(self.vna.get_sweeptime())      #wait single sweep
            self._p.iterate()
        else:   #with averaging
            self._p = Progress_Bar(self.vna.get_averages(),self.dirname,self.vna.get_sweeptime())
            if "avg_status" in self.vna.get_function_names():
                for a in range(self.vna.get_averages()):
                    while self.vna.avg_status() <= a:
                        qt.msleep(.2) #maybe one would like to adjust this at a later point
                    self._p.iterate()
            else: #old style
                for a in range(self.vna.get_averages()):
                    qt.msleep(self.vna.get_sweeptime())      #wait single sweep time
                    self._p.iterate()

        data_amp, data_pha = self.vna.get_tracedata()
        data_real, data_imag = self.vna.get_tracedata('RealImag')

        self._data_amp.append(data_amp)
        self._data_pha.append(data_pha)
        self._data_real.append(data_real)
        self._data_imag.append(data_imag)
        if self._fit_resonator:
            self._do_fit_resonator()

        qt.mend()
        self._end_measurement()
Ejemplo n.º 28
0
def main():

    initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = 100 
    hh_measurement_time = int(1e3 * 60 * 15) #ms

    qt.mstart()

    cr_stats = qt.Data(name = 'Statistics_cr_checks') 
    cr_stats.add_coordinate('repetition nr')
    cr_stats.add_value('lt1_cr_succes_percentage')
    cr_stats.add_value('lt1_cr_checks')
    cr_stats.add_value('lt2_cr_succes_percentage')
    cr_stats.add_value('lt2_cr_checks')
    cr_stats.add_value('tpqi_starts')
    cr_stats.add_value('lt1_repump_cts')
    cr_stats.add_value('lt2_repump_cts')
    cr_stats.add_value('lt1_triggers_received')
    cr_stats.add_value('lt2_triggers_sent')
    cr_stats.add_value('lt1_oks_sent')
    cr_stats.add_value('lt2_oks_received')
    cr_stats.create_file()


    #histogram=zeros((par_range_sync,par_range_g2))
    histogram_summed=zeros((par_range_sync,par_range_g2))
    for idx in arange(repetitions):
        if msvcrt.kbhit() and msvcrt.getch() == "q" : break

        print 'Starting measurement cycle', idx
        [histogram,hist_ch0,hist_ch1,hist_ch1_long] = measurement_cycle(hh_measurement_time)
        print_save_cr_check_info(cr_stats,idx)    

        
        print shape(histogram)
        histogram_summed += histogram
        print 'Finished measurement cycle', idx, 'start saving'
        
        data = qt.Data(name='interference'+str(idx))
        data.add_coordinate('dt')
        data.add_coordinate('sync')
        data.add_value('counts')
        
        save_and_plot_data(data,histogram,histogram_summed,hist_ch0,hist_ch1,hist_ch1_long)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

        #if not optimize(): break
        print 'Optimisation step', idx, ' completed'

    cr_stats.close_file()
    qt.mend()
Ejemplo n.º 29
0
def main():

    initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = 100
    hh_measurement_time = int(1e3 * 60 * 15)  # ms

    qt.mstart()

    cr_stats = qt.Data(name="Statistics_cr_checks")
    cr_stats.add_coordinate("repetition nr")
    cr_stats.add_value("lt1_cr_succes_percentage")
    cr_stats.add_value("lt1_cr_checks")
    cr_stats.add_value("lt2_cr_succes_percentage")
    cr_stats.add_value("lt2_cr_checks")
    cr_stats.add_value("tpqi_starts")
    cr_stats.add_value("lt1_repump_cts")
    cr_stats.add_value("lt2_repump_cts")
    cr_stats.add_value("lt1_triggers_received")
    cr_stats.add_value("lt2_triggers_sent")
    cr_stats.add_value("lt1_oks_sent")
    cr_stats.add_value("lt2_oks_received")
    cr_stats.create_file()

    histogram_summed = zeros((par_range_sync, par_range_g2))
    for idx in arange(repetitions):
        if msvcrt.kbhit() and msvcrt.getch() == "q":
            break

        print "Starting measurement cycle", idx, "current time:", time.strftime("%H:%M", time.localtime())
        [histogram, hist_ch0, hist_ch1, hist_ch1_long] = measurement_cycle(hh_measurement_time)
        print_save_cr_check_info(cr_stats, idx)

        print shape(histogram)
        histogram_summed += histogram
        print "Finished measurement cycle", idx, "start saving"

        data = qt.Data(name="interference" + str(idx))
        data.add_coordinate("dt")
        data.add_coordinate("sync")
        data.add_value("counts")

        save_and_plot_data(data, histogram, histogram_summed, hist_ch0, hist_ch1, hist_ch1_long)
        print "Data saving cycle", idx, "completed"
        qt.msleep(1)

        if not optimize():
            break
        print "Optimisation step", idx, " completed"

    cr_stats.close_file()
    qt.mend()
Ejemplo n.º 30
0
    def _measure(self):
        qt.mstart()
        plt.gca().set_xlabel("V [uV]")
        plt.gca().set_ylabel("I [nA]")
        try:
            if self._measure_IV_1D:
                for self._sweep in np.arange(self._sweeps):
                    if self._current_bias:
                        self._take_IV(
                            out_conversion_factor=self._conversion_IV,
                            in_amplification=self._V_amp,
                            out_divider=self._V_divider)
                    if self._voltage_bias:
                        self._take_IV(out_conversion_factor=1,
                                      in_amplification=self._conversion_IV,
                                      out_divider=self._V_divider)
                    self._p_iterate()

            if self._measure_IV_2D or self._measure_IV_3D:
                for self._x in self.x_vec:
                    self.x_set_obj(self._x)
                    sleep(self._tdx)

                    if self._measure_IV_2D:
                        if self._current_bias:
                            self._take_IV(
                                out_conversion_factor=self._conversion_IV,
                                in_amplification=self._V_amp,
                                out_divider=self._V_divider)
                        if self._voltage_bias:
                            self._take_IV(out_conversion_factor=1,
                                          in_amplification=self._conversion_IV,
                                          out_divider=self._V_divider)
                        self._p.iterate()

                    if self._measure_IV_3D:
                        for self._y in self.y_vec:
                            self.y_set_obj(self._y)
                            sleep(self._tdy)
                            if self._current_bias:
                                self._take_IV(
                                    out_conversion_factor=self._conversion_IV,
                                    in_amplification=self._V_amp,
                                    out_divider=self._V_divider)
                            if self._voltage_bias:
                                self._take_IV(
                                    out_conversion_factor=1,
                                    in_amplification=self._conversion_IV,
                                    out_divider=self._V_divider)
                            self._p.iterate()

        finally:
            self.daq.set_ao1(0)
            qt.mend()
Ejemplo n.º 31
0
 def run(self):
     '''This is how you begin the sweep. Checks if everything is setup then runs the measuremulti function'''
     self._check_ready1()
     if self._check_ready == True:
         print 'Starting measurement'
         self._time = time.localtime()
         qt.mstart()
         self._measuremulti(self._number_of_loops -1)
         qt.mend()
         print 'End of measurement'
     else:
         print 'Something is not set up properly. Check channels, channel factors, channel constants and loops.'           
Ejemplo n.º 32
0
def launch2Dmeasurement(measurement_name):
    '''
    Performs a 2D measurement: y=f(x)
    Input: measurement_name <string>: name of the measurement
    '''
    initialize_instruments()
    #################################################################
    #Qt.Data File Creation
    #################################################################
    data=create_measurement_datafile('2D',measurement_name) #Create the data file for a 2D measurement
    initialize_settings(data,dimension=2) #Save current scripts and modules in the data directory
    print '2D Measurement'
    print data
    print 'Saved in: '+data.get_dir()
    #################################################################
    #Run the list of functions user-selected in settings._init_sweep
    #################################################################
    initialize_sweep()
    #################################################################
    # Measure
    #################################################################
    points=arange(0.0,settings.get_npoints_x()+1,1.0) # points: array of steps, including hysteresis
    if settings.get_hysteretic_x():
        points=concatenate((points,points[::-1]))
    qt.mstart() #Send Start signal to qt
    #Measurement Loop
    for point in points:
        result=list() #list to fill with data point (x1,x2,x3,y1,y2,y3,...)
        # set all the coordinates
        for coordinate in settings.get_coordinates_x():
            #Calculate value to set
            setvalue=((coordinate[3]-coordinate[2])*point)/settings.get_npoints_x()+coordinate[2]
            result.append(setvalue)
            setdevicevalue(coordinate[0],coordinate[1], setvalue)
        # wait for result 
        qt.msleep(settings.get_waittime())
        # execute the functions to prepare the reading
        execute_function_list_point
        # read out all the values
        for value in settings.get_values():
            y=getdevicevalue(value[0],value[1])
            result.append(y)
        # save the data point
        data.add_data_point(*result)
        data.emit('new-data-point')
    
    #################################################################
    # Closing
    #################################################################    
    terminate_sweep()
    data.close_file()
    qt.msleep(3)
    settings.copy_tree()
Ejemplo n.º 33
0
	def initial_calibrate(self):
		if not self._FSUP_connected: 
			raise ValueError(('FSUP is possibly not connected. \nIncrease trust_region and maxage to interpolate values or connect FSUP and execute connect_FSUP(fsup)'))
		
		if self._swb != None: #switching to fsup
			self._swb.set_position('2')
		else:
			logging.warning(__name__ + ' : Switch was not switched. Define switchbox instrument via iq.connect_switchbox(swb). If you do not have a switchbox, make sure your cables are connected and go on.')
		qt.mstart()
		(hx_amp,hx_phase,hy_amp,hy_phase,phaseoffset)=(0,0,0,0,0) 
		mw_freq=self._f_rounded - self._iq_frequency
				if self._iq_frequency == 0:	logging.warning(__name__+': Your IQ Frequency is 0. It is better to calibrate with a finite IQ frequency because you will get inconsistent data in the calibration file otherwise. If you calibrate with iq!=0, the right values for iq=0 are extracted.')
Ejemplo n.º 34
0
def simple(s_vec):
    '''
    this example is based on 'measure_module.py'
    you will need to set up a vector of frequencies and then call the
    measurment script.

    To run the function type in the terminal:

    sv = numpy.arange(0,300000,1000)
    esr_meas.simple(sv)
    '''


    st0 = qt.instruments['Standa0']





    qt.mstart()

    data = qt.Data(name='hwp_sweep')
    data.add_coordinate('Step Position')
    data.add_value('Counts')
    data.create_file()
    filename=data.get_filepath()[:-4]

    plot2d_1 = qt.Plot2D(data, name='measure2D', valdim=1)


    for s in s_vec:
        if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break
        st0.move(s)
        logging.debug('step set: %s' % (s))
        n = 0
        qt.msleep(0.2)
        while n < 50:
            cur_pos = st0.get_position()
            if cur_pos == s:
                break
            else:
                n = n + 1
                qt.msleep(0.5)

        qt.msleep(0.5)
        ni63.get('ctr0')
        data.add_data_point(s,counts)



    plot2d_1.save_png(filename+'.png')
    data.close_file()
    qt.mend()
Ejemplo n.º 35
0
def simple(t_maximum, meas_period):

    # This example will monitor the SNSPD cooldown for a period of up to
    # t_maximum, which is measured in HOURS.



    ls211 = qt.instruments['ls211']
    snspd = qt.instruments['snspd']

    # meas_period is the measurement period denoted in seconds.





    qt.mstart()

    data = qt.Data(name='snspd_cooldown_monitor')
    data.add_coordinate('Measurement Index')
    data.add_value('Temperature')
    data.add_value('Channel 0 Voltage')
    data.add_value('Channel 1 Voltage')
    data.create_file()
    filename=data.get_filepath()[:-4]


    plot2d_1 = qt.Plot2D(data, name='measureSNSPDT', valdim=1)
    plot2d_2 = qt.Plot2D(data, name='measureSNSPDVs', valdim=2)
    plot2d_2.add_data(data, valdim=3)
    meas_idx = 0

    # Set bias on detectors
    snspd.set_bias0(0.2)
    snspd.set_bias1(0.2)
    while True:
        if (meas_idx > t_maximum*3600/15): break
        if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break
        currentT = ls211.get_temperature()
        currentV0 = snspd.get_vmeas0()
        currentV1 = snspd.get_vmeas1()

        qt.msleep(meas_period)
        data.add_data_point(meas_idx,currentT,currentV0,currentV1)
        meas_idx = meas_idx + 1



    plot2d_1.set_plottitle('SNSPD cooldown, measurement period %s seconds, measured for %s seconds total' % (meas_period, meas_period*meas_idx))

    plot2d_1.save_png(filename+'.png')
    data.close_file()
    qt.mend()
Ejemplo n.º 36
0
def main():

    initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = par_reps
    hh_measurement_time = int(1e3 * 60 * par_meas_time) #ms

    qt.mstart()

    cr_stats = qt.Data(name = 'Statistics_cr_checks') 
    cr_stats.add_coordinate('repetition nr')
    cr_stats.add_value('lt1_cr_succes_percentage')
    cr_stats.add_value('lt1_cr_checks')
    cr_stats.add_value('lt2_cr_succes_percentage')
    cr_stats.add_value('lt2_cr_checks')
    cr_stats.add_value('tpqi_starts')
    cr_stats.add_value('lt1_repump_cts')
    cr_stats.add_value('lt2_repump_cts')
    cr_stats.add_value('lt1_triggers_received')
    cr_stats.add_value('lt2_triggers_sent')
    cr_stats.add_value('lt1_oks_sent')
    cr_stats.add_value('lt2_oks_received')
    cr_stats.create_file()


    histogram_summed=zeros(65536)
    histogram=zeros(65536)
    for idx in arange(repetitions):
        if msvcrt.kbhit() and msvcrt.getch() == "q" : break
        
        print 'Starting measurement cycle', idx, 'current time:', time.strftime('%H:%M',time.localtime())
        histogram = measurement_cycle(hh_measurement_time)
        print_save_cr_check_info(cr_stats,idx)    

        print shape(histogram)
        histogram_summed += histogram
        print 'Finished measurement cycle', idx, 'start saving'
        
        data = qt.Data(name='antibunching'+str(idx))
        data.add_coordinate('dt')
        data.add_value('counts')
        
        save_and_plot_data(data,histogram,histogram_summed)
        print 'Data saving cycle', idx, 'completed'
        qt.msleep(1)

        if not optimize(): break
        print 'Optimisation step', idx, ' completed'

    cr_stats.close_file()
    qt.mend()
Ejemplo n.º 37
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
Ejemplo n.º 38
0
def simple(t_maximum, meas_period):

    # This example will monitor the T/H for a period of up to
    # t_maximum, which is measured in HOURS.



    thmon = qt.instruments['thmon']

    # meas_period is the measurement period denoted in seconds.





    qt.mstart()

    data = qt.Data(name='environment_monitor')
    data.add_coordinate('Time (minutes)')
    data.add_value('Temperature')
    data.add_value('Humidity')
    data.create_file()
    filename=data.get_filepath()[:-4]


    plot2d_1 = qt.Plot2D(data, name='env_temperature', valdim=1)
    plot2d_2 = qt.Plot2D(data, name='env_humidity', valdim=2)

    starttime = datetime.datetime.now()


    timedelta = 0
    while timedelta < t_maximum*3600:
        if (msvcrt.kbhit() and (msvcrt.getch() == 'q')): break
        currentT = thmon.get_probe1_temperature()*9/5+32
        currentH = thmon.get_humidity()
        currenttime = datetime.datetime.now()
        c = currenttime - starttime
        timedelta = (c.days * 86400 + c.seconds)
        qt.msleep(meas_period)
        data.add_data_point(timedelta/60.0,currentT,currentH)




    plot2d_1.set_plottitle('Environment temperature monitoring, SiC SD Lab, ' + starttime.strftime("%A, %d. %B %Y %I:%M%p"))
    plot2d_2.set_plottitle('Environment humidity monitoring, SiC SD Lab, ' + starttime.strftime("%A, %d. %B %Y %I:%M%p"))

    plot2d_1.save_png(filename+'.png')
    data.close_file()
    qt.mend()
Ejemplo n.º 39
0
    def measure_1D(self, sweep_type=1):
        '''
        measure method to record a single (averaged) VNA trace, S11 or S21 according to the setting on the VNA
        rescan: If True (default), the averages on the VNA are cleared and a new measurement is started. 
                If False, it will directly take the data from the VNA without waiting.
        '''
        
        self._sweep_type = sweep_type
        self._scan_1D = True
        self._scan_2D = False
        self._scan_3D = False
        self._scan_time = False
        
        self._measurement_object.measurement_func = 'measure_1D'
        self._measurement_object.x_axis = 'frequency'
        self._measurement_object.y_axis = ''
        self._measurement_object.z_axis = ''
        self._measurement_object.web_visible = self._web_visible
        if not self.dirname:
            self.dirname = 'IVD_tracedata'
        self._file_name = self.dirname.replace(' ', '').replace(',','_')
        if self.exp_name:
            self._file_name += '_' + self.exp_name
            
        # prepare storage
        self._prepare_measurement_IVD()
        self._prepare_measurement_file()


        """opens qviewkit to plot measurement, amp and pha are opened by default"""
        if self.open_qviewkit:
            self._qvk_process = qviewkit.plot(self._data_file.get_filepath(), datasets=['I_0', 'V_0'])
        print('recording trace...')
        sys.stdout.flush()

        qt.mstart()
        
        self.sweep.create_iterator()
        self.IVD.set_status(True)
        for st in range(self.sweep.get_nos()):
            #print st
            self.IVD.set_sweep_parameters(self.sweep.get_sweep())
            data_bias, data_sense = self.IVD.take_IV()
            self._data_I[st].append(data_bias)
            self._data_V[st].append(data_sense)
            #self._data_dVdI[st].append(np.gradient(self._data_V[st])/np.gradient(self._data_I[st]))
        self.IVD.set_status(False)


        qt.mend()
        self._end_measurement()
Ejemplo n.º 40
0
 def initial_calibrate(self):
     if not self._FSUP_connected: 
         raise ValueError(('FSUP is possibly not connected. \nIncrease trust_region and maxage to interpolate values or connect FSUP and execute connect_FSUP(fsup)'))
     
     if self._swb != None: #switching to fsup
         self._swb.set_position('2')
     else:
         logging.warning(__name__ + ' : Switch was not switched. Define switchbox instrument via iq.connect_switchbox(swb). If you do not have a switchbox, make sure your cables are connected and go on.')
     qt.mstart()
     (hx_amp,hx_phase,hy_amp,hy_phase,phaseoffset)=(0,0,0,0,0)
     self._f_rounded = np.round(self._sideband_frequency,-3)
     mw_freq=self._f_rounded - self._iq_frequency
     if self._iq_frequency == 0: logging.warning(__name__+': Your IQ Frequency is 0. It is better to calibrate with a finite IQ frequency because you will get inconsistent data in the calibration file otherwise. If you calibrate with iq!=0, the right values for iq=0 are extracted.')
     
     #self._sample.awg.stop()
     self._sample.awg.set({'ch1_output':0,'ch2_output':0,'runmode':'CONT'})
     self._sample.qubit_mw_src.set({'frequency':mw_freq, 'power':self._mw_power, 'status':1})
     
     print "Starting an initial calibration of %s for Frequency: %.2fGHz (MW-Freq: %.2fGHz), MW Power: %.2fdBm"%(self.mixer_name,self._sideband_frequency/1e9,mw_freq/1e9,self._mw_power)
     sys.stdout.flush()
     frequencies=[mw_freq-3*self._iq_frequency,mw_freq-2*self._iq_frequency,mw_freq-self._iq_frequency,mw_freq,mw_freq+self._iq_frequency,mw_freq+2*self._iq_frequency,mw_freq+3*self._iq_frequency]
     self.focus(mw_freq,1)
     self.load_zeros()
     (xold,yold)=(np.inf,np.inf)
     print "Finding initial values for DC offsets to reduce leakage when there is no pulse"
     dcx=self.minimize(self.xoptimize,-.02,.02,.01,5e-3,final_averages=1)[0]
     dcy=self.minimize(self.yoptimize,-.02,.02,.01,5e-3,final_averages=1)[0]
     while(np.all(np.around((dcx,dcy),3)!=np.around((xold,yold),3))):
         (xold,yold)=(dcx,dcy)
         dcx=self.minimize(self.xoptimize,dcx-.002,dcx+.002,.002,1e-3,final_averages=3,confirmonly=True)[0]
         dcy=self.minimize(self.yoptimize,dcy-.002,dcy+.002,.002,1e-3,final_averages=3,confirmonly=True)[0]
     if not self._iq_frequency == 0:
         print "Finding initial values for Sine and Cosine waveform parameters"
         self.load_wfm(sin_phase=phaseoffset,update_channels=(True,True),relamp=2,relamp2=2,init=True)
         self.focus(mw_freq,1)
         (xold,yold)=(0,0)
         x=self.minimize(self.xoptimize,-.02,.02,.01,5e-3,final_averages=1)[0]
         y=self.minimize(self.yoptimize,-.02,.02,.01,5e-3,final_averages=1)[0]
         while(np.all(np.around((x,y),3)!=np.around((xold,yold),3))):
             (xold,yold)=(x,y)
             x=self.minimize(self.xoptimize,x-.002,x+.002,.002,2e-3,final_averages=1,verbose=False,confirmonly=True)[0]
             y=self.minimize(self.yoptimize,y-.002,y+.002,.002,2e-3,final_averages=1,verbose=False,confirmonly=True)[0]
         self.focus(mw_freq-self._iq_frequency,4)
         relamp=self.minimize(self.relampoptimize,0.2,2,.3,10e-3,final_averages=1,bounds=(.5,2))[0]
         relamp2=self.minimize(self.relampoptimize2,0.2,2,.3,10e-3,final_averages=1,bounds=(.5,2))[0]
         phaseoffset=self.minimize(self.phaseoptimize,0,1,.2,5e-3,final_averages=1)[0]
     else:
         x,y,phaseoffset,relamp,relamp2 = 0,0,0,1,1
     print "Initial parameterset found, starting optimization..."
     return self.recalibrate(dcx,dcy,x,y,phaseoffset,relamp,relamp2)
Ejemplo n.º 41
0
    def _measure(self):
        '''
        measures and plots the data depending on the measurement type.
        the measurement loops feature the setting of the objects and saving the data in the .h5 file.
        '''
        qt.mstart()
        try:
            """
            loop: x_obj with parameters from x_vec
            """
            self.IVD.set_status(True)
            for ix, x in enumerate(self.x_vec):
                self.x_set_obj(x)
                sleep(1)
                
                #if self.log_function != None:
                #    for i,f in enumerate(self.log_function):
                #        self._log_value[i].append(float(f()))

                

                if self._scan_2D:
                    """ measurement """
                    self.sweep.create_iterator()
                    for st in range(self.sweep.get_nos()):
                        self.IVD.set_sweep_parameters(self.sweep.get_sweep())
                        data_bias, data_sense = self.IVD.take_IV(channel=1)
                        self._data_I[st].add(data_bias)
                        self._data_V[st].append(data_sense)
                        #self._data_dVdI[st].append(np.array(np.gradient(self._data_V[st]))[-1]/np.gradient(self._data_I[st]))
                        
                        if self._Fraunhofer:
                            self._IVC = IV_curve()
                            self._data_Ic[st].append(self._IVC.get_Ic(V=data_sense, I=data_bias, direction=self.IVD._direction))
                    
                    
                    #if self.progress_bar:
                    #    self._p.iterate()
                    qt.msleep()
            self.IVD.set_status(False)
        except Exception as e:
            print e.__doc__
            print e.message        
        finally:
            self._end_measurement()
            self.IVD.set_status(False, 1)
            #self.IVD.ramp_current(0, 100e-6, channel=2)
            self.IVD.set_status(False, 2)
            qt.mend()
    def save(self, meta=""):
        CyclopeanInstrument.save(self, meta)

        import qt
        qt.mstart()
        data = qt.Data(name='dummy 2D scan')
        data.add_coordinate('x [um]')
        data.add_coordinate('y [um]')
        data.add_value('counts [Hz]')
        data.create_file()
        for i in range(self._xsteps):
            for j in range(self._ysteps):
                data.add_data_point(self._x[i], self._y[j], self._data[j, i])
            data.new_block()
        data.close_file()
        qt.mend()
Ejemplo n.º 43
0
    def save(self, meta=""):
        CyclopeanInstrument.save(self, meta)

        import qt
        qt.mstart()
        data = qt.Data(name='dummy 2D scan')
        data.add_coordinate('x [um]')
        data.add_coordinate('y [um]')
        data.add_value('counts [Hz]')
        data.create_file()
        for i in range(self._xsteps):
            for j in range(self._ysteps):
                data.add_data_point(self._x[i], self._y[j], self._data[j,i])
            data.new_block()
        data.close_file()
        qt.mend()
Ejemplo n.º 44
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
Ejemplo n.º 45
0
def grid_search_print():
    qt.mstart()
    data = qt.Data(name='grid_search_MHF')
    data.add_coordinate('current (mA)')
    data.add_coordinate('feedforward (mA/V)')
    data.add_value('Mode Hops')
    data.create_file()
    plot3d = qt.Plot3D(data, name='measure_MH3D', style='image')
    topt = qt.instruments['topt']
    set_toptica_to_analog_scan()
    #topt.set_scan_offset(2.0)
    #topt.set_scan_amplitude(4.0)
    topt.set_scan_offset(45.0/17.5) # set to the equivalent of 45 V on the piezo
    topt.set_scan_amplitude(60.0/17.5) # set the amplitude to 60, so that we get +- 30 V (60 Vpp) of scan
    topt.set_scan_frequency(5.0)
    topt.set_scan_enabled(True)
    current_values = np.linspace(0.230,0.300,30)
    feedforward_values = np.linspace(-0.48,-0.60,5)
    laser_performance = np.zeros((np.size(current_values)*np.size(feedforward_values),1))
    for i in range(np.size(current_values)):
        for j in range(np.size(feedforward_values)):
            while k < 10:
                cur = current_values[i]
                ff = feedforward_values[j]
                topt.set_feedforward_factor(ff)
                topt.set_current(cur)
                time.sleep(0.2)
                threshold_voltage = 45.0/17.5 - 0.5*60.0/17.5+0.1
                n_peaks, peak_locs = get_peaks_and_count(threshold_voltage)
                peakdiffs = np.diff(np.array(peak_locs))
                norm_peakdiffs = peakdiffs/np.mean(peakdiffs)
                n_modehops = np.sum(np.abs(norm_peakdiffs) > 0.2)
                #print 'i %s j %s' % (i ,j)
                laser_performance[np.size(feedforward_values)*i+j] = n_modehops

                #print 'Found %d modehops for current %.3f A and FF %.3f' % (n_modehops, cur, ff)
                qt.msleep(0.001)
                if n_modehops > 1:
                    k = 10
                    break
            data.add_data_point(cur,ff,n_modehops)

        data.new_block()
    qt.mend()
    return laser_performance
Ejemplo n.º 46
0
    def get_trace(self):
        '''
        This function performs a full measurement.
        First a trigger is sent to initiate a sweep.
        An estimate is made of the time the sweep takes.
        After the estimated time the data is queried from
        the device. Usually the estimated time is a bit
        lower then the actual time, the device will
        respond as soon as it is finished.
        It is assumed that the instrument is already on
        'trigger hold'-mode.

        Input:
            None

        Ouptput:
            freqs (array of floats):    The frequencies at which the
                                        reflection / transmission was
                                        measured
            reply (arrray of foats):    Measured data

        '''
        qt.mstart()

        startfreq = self.get_start_freq(query=False)
        stopfreq = self.get_stop_freq(query=False)
        numpoints = self.get_numpoints(query=False)
        IF_Bandwidth = self.get_IF_Bandwidth(query=False)

        freqs = numpy.linspace(startfreq,stopfreq,numpoints)
        sweep_time = numpoints / IF_Bandwidth

        print 'sending trigger to network analyzer, and wait to finish'
        print 'estimated waiting time: %.2f s' % sweep_time
        self.send_trigger()
        qt.msleep(sweep_time)

        print 'reading out network analyzer'
        reply = self.read()
        reply = numpy.array(reply)

        qt.mend()

        return (freqs, reply)
Ejemplo n.º 47
0
def test_hh():

    qt.mstart()
    initialize_hh()
    hharp.StartMeas(int(1e3 * 60 * 2))
    histogram = hharp.get_T3_pulsed_g2_2DHistogram(
        binsize_sync=par_binsize_sync,
        range_sync=par_range_sync,
        binsize_g2=par_binsize_g2,
        range_g2=par_range_g2,
        sync_period=par_sync_period,
    )
    data = qt.Data(name='interference test_hh')
    data.add_coordinate('dt')
    data.add_coordinate('sync')
    data.add_value('counts')
    save_and_plot_data(data, histogram)
    qt.mend()
    optimize()
Ejemplo n.º 48
0
def main():

    #initialize_hh()
    generate_sequence()

    # configure measurement
    repetitions = 1 
    hh_measurement_time =0# int(1e3 * 10)

    qt.mstart()

    for idx in arange(repetitions):

        histogram = measurement_cycle(hh_measurement_time)
       # data = qt.Data(name='interference'+str(idx))
       # data.add_coordinate('dt')
       # data.add_coordinate('sync')
       # data.add_value('counts')
       # save_and_plot_data(data,histogram)
        qt.msleep(1)
    
    qt.mend()
Ejemplo n.º 49
0
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()
Ejemplo n.º 50
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()
Ejemplo n.º 51
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()
Ejemplo n.º 52
0
    def startmeasurement(self):
        useinstruments.createinstruments(self.listsettings[0])

        print 'All instruments loaded.'

        measurementvectors.createvectors(self.listsettings[0])
        measurementvectors.createdatafile(self.listsettings[0])
        useinstruments.initinstruments(self.listsettings[0],
                                       measurementvectors.v_dac,
                                       measurementvectors.v_vec,
                                       measurementvectors.instrument_array)
        measurementvectors.createplots(self.listsettings[0])

        qt.mstart()

        print 'measurement started...'
        measurementvectors.measurementloop(self.listsettings[0])
        useinstruments.rampback(self.listsettings[0])
        print 'measurement finished!'
        print 'ALL other Voltages and Fields hanging at last value'

        qt.mend()
        self.delete_from_waitinglist()
Ejemplo n.º 53
0
    def measure_1D(self):

        if self.x_set_obj == None:
            print 'axes parameters not properly set...aborting'
            return

        qt.mstart()
        self.mode = 1  #1: 1D, 2: 2D, 3:1D_AWG/2D_AWG
        self._prepare_measurement_file()

        if self.show_progress_bar:
            p = Progress_Bar(len(self.x_vec), name=self.dirname)
        try:
            # measurement loop
            for x in self.x_vec:
                self.x_set_obj(x)
                qt.msleep(
                )  # better done during measurement (waiting for trigger)
                self._append_data()
                if self.show_progress_bar: p.iterate()
        finally:
            #self._safe_plots()
            self._end_measurement()
            qt.mend()
med.set_user('Ben,Sal,Vibhor,Raj')

print rigol.query('*IDN?')

# 'start measurement'
#def measure_temp_fsl(start_frequency, stop_frequency, runtime):

start_frequency = 10
stop_frequency = 18000
bandwidth = 0.1  #MHz
max_runtime = 10  #sec
rf_power = 0
norm_runs = 1

#normalization routine
qt.mstart()
spyview_process(reset=True)  #clear old meta-settings
filename = 'fsl_temp_sec_normalization'

print 'prepare datafile'
data = qt.Data(name=filename)
data.add_coordinate('Frequency (MHz)', size=fsl.get_sweeppoints())
data.add_coordinate('time [s]')
data.add_value('RF Power (dBm)')
data.add_value('Summed trace ')
#data.add_coordinate('temp [K]')
data.add_value('Temp (K)')
#data.add_value(rigol.get_function()[1:-1]+ ' ') #whatever rigol is set to
data.create_file()
data.copy_file('poormansdipstick_with_normalize.py')
Ejemplo n.º 55
0
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)
Ejemplo n.º 56
0
    def _measure(self):
        '''
        measures and plots the data depending on the measurement type.
        the measurement loops feature the setting of the objects and saving the data in the .h5 file.
        '''
        qt.mstart()
        try:
            """
            loop: x_obj with parameters from x_vec
            """
            for ix, x in enumerate(self.x_vec):
                self.x_set_obj(x)
                sleep(self.tdx)

                if self.log_function != None:
                    for i, f in enumerate(self.log_function):
                        self._log_value[i].append(float(f()))

                if self._scan_3D:
                    for y in self.y_vec:
                        """
                        loop: y_obj with parameters from y_vec (only 3D measurement)
                        """
                        if (
                                np.min(
                                    np.abs(self.center_freqs[ix] - y *
                                           np.ones(len(self.center_freqs[ix])))
                                ) > self.span / 2.
                        ) and self.landscape:  #if point is not of interest (not close to one of the functions)
                            data_amp = np.zeros(int(self._nop))
                            data_pha = np.zeros(int(
                                self._nop))  #fill with zeros
                        else:
                            self.y_set_obj(y)
                            sleep(self.tdy)
                            if self.averaging_start_ready:
                                self.vna.start_measurement()
                                qt.msleep(
                                    .2
                                )  #just to make sure, the ready command does not *still* show ready
                                while not self.vna.ready():
                                    qt.msleep(.2)
                            else:
                                self.vna.avg_clear()
                                qt.msleep(self._sweeptime_averages)

                            #if "avg_status" in self.vna.get_function_names():
                            #       while self.vna.avg_status() < self.vna.get_averages():
                            #            qt.msleep(.2) #maybe one would like to adjust this at a later point
                            """ measurement """
                            data_amp, data_pha = self.vna.get_tracedata()

                        if self._nop == 0:  # this does not work yet.
                            print data_amp[0], data_amp, self._nop
                            self._data_amp.append(data_amp[0])
                            self._data_pha.append(data_pha[0])
                        else:
                            self._data_amp.append(data_amp)
                            self._data_pha.append(data_pha)
                        if self._fit_resonator:
                            self._do_fit_resonator()
                        if self.progress_bar:
                            self._p.iterate()
                        qt.msleep()
                    """
                    filling of value-box is done here.
                    after every y-loop the data is stored the next 2d structure
                    """
                    self._data_amp.next_matrix()
                    self._data_pha.next_matrix()

                if self._scan_2D:
                    if self.averaging_start_ready:
                        self.vna.start_measurement()
                        qt.msleep(
                            .2
                        )  #just to make sure, the ready command does not *still* show ready
                        while not self.vna.ready():
                            qt.msleep(.2)
                    else:
                        self.vna.avg_clear()
                        qt.msleep(self._sweeptime_averages)
                    """ measurement """
                    data_amp, data_pha = self.vna.get_tracedata()
                    self._data_amp.append(data_amp)
                    self._data_pha.append(data_pha)
                    if self._nop < 10:
                        #print data_amp[self._nop/2]
                        self._data_amp_mid.append(
                            float(data_amp[self._nop / 2]))
                        self._data_pha_mid.append(
                            float(data_pha[self._nop / 2]))

                    if self._fit_resonator:
                        self._do_fit_resonator()
                    if self.progress_bar:
                        self._p.iterate()
                    qt.msleep()
        except Exception as e:
            print e.__doc__
            print e.message
        finally:
            self._end_measurement()
            qt.mend()
Ejemplo n.º 57
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