Exemple #1
0
    def measure_2D_ddc_time_trace(self):
        """
        Performs a digital down conversion for exactly one value in your awg sequence. But you can sweep other
        parameters, such as mw-power or so.
        :return:
        """
        if self.y_set_obj is None:
            raise ValueError('y-axes parameters not properly set')
        time_end = float(self.sample.mspec.get_samples()
                         ) / self.sample.mspec.get_samplerate()
        time_array = np.linspace(0, time_end, self.sample.mspec.get_samples())
        self.set_x_parameters(time_array, 'time', True, 'sec')

        self.mode = 2  # 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:
            for y in self.y_vec:
                qkit.flow.sleep()
                self.y_set_obj(y)
                qkit.flow.sleep()
                self._append_data(ddc=True)
                if self.show_progress_bar: p.iterate()
        finally:
            self._end_measurement()
Exemple #2
0
 def turn(self, angle):
     """
     Turns the step motor and thus the phase shifter at a given angle
     :param angle: value in degrees positive or negative.
     :return: None
     """
     self.angle += angle
     if self.angle < self.min_angle or self.angle > self.max_angle:
         logging.error("Out of range, operation aborted to prevent damage!")
         self.angle -= angle
     else:
         self.c.turn(angle)
         max_steps = self.c.get_max_steps()
         if self.show_progress_bar:
             pb = Progress_Bar(max_steps - 2)
         try:
             while self.c.get_steps() < max_steps - 1:
                 if self.show_progress_bar:
                     for i in range(self.c.get_steps() - pb.progr):
                         pb.iterate()
                 else:
                     pass
         except KeyboardInterrupt:
             logging.warning("KeyboardInterrupt: Rotation stopped!")
             self.c.stop_rotation()
             self.angle -= int(angle *
                               (float(max_steps - self.c.get_steps())) /
                               max_steps)
Exemple #3
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()
Exemple #4
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()
Exemple #5
0
    def measure_3D_AWG(self):
        '''
        x_vec is sequence in AWG
        '''

        if self.z_set_obj is None or self.y_set_obj is None:
            raise ValueError('x-axes parameters not properly set')
        if self.ReadoutTrace:
            raise ValueError(
                'ReadoutTrace is currently not supported for 3D_AWG measurements'
            )

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

        if self.show_progress_bar:
            p = Progress_Bar(len(self.y_vec) * len(self.z_vec),
                             name=self.dirname)
        try:
            # measurement loop
            for z in self.z_vec:
                self.z_set_obj(z)
                for y in self.y_vec:
                    qkit.flow.sleep()
                    self.y_set_obj(y)
                    qkit.flow.sleep()
                    self._append_data()
                    if self.show_progress_bar: p.iterate()
                for i in range(self.ndev):
                    self._hdf_amp[i].next_matrix()
                    self._hdf_pha[i].next_matrix()
        finally:
            self._end_measurement()
Exemple #6
0
    def measure_2D_AWG(self, iterations=1):
        '''
        x_vec is sequence in AWG
        '''

        if self.y_set_obj is None:
            raise ValueError('y-axes parameters not properly set')

        qkit.flow.sleep(
        )  # if stop button was pressed by now, abort without creating data files

        if iterations > 1:
            self.z_vec = range(iterations)
            self.z_coordname = 'iteration'
            self.z_set_obj = lambda z: True
            self.z_unit = ''

            self.measure_3D_AWG()

            # For 3D measurements with iterations, averages are only created at the end to get a consistent averaging base.
            hdf_file = hdf.Data(self._hdf.get_filepath())
            for j in range(self.ndev):
                amp = np.array(hdf_file["/entry/data0/amplitude_%i" % j])
                pha = np.array(hdf_file["/entry/data0/phase_%i" % j])
                amp_avg = sum(amp[i] for i in range(iterations)) / iterations
                pha_avg = sum(pha[i] for i in range(iterations)) / iterations
                hdf_amp_avg = hdf_file.add_value_matrix('amplitude_avg_%i' % i,
                                                        x=self._hdf_y,
                                                        y=self._hdf_x,
                                                        unit='a.u.')
                hdf_pha_avg = hdf_file.add_value_matrix('phase_avg_%i' % i,
                                                        x=self._hdf_y,
                                                        y=self._hdf_x,
                                                        unit='rad')

                for i in range(len(self.y_vec)):
                    hdf_amp_avg.append(amp_avg[i])
                    hdf_pha_avg.append(pha_avg[i])
            hdf_file.close_file()

        else:
            self.mode = 3  # 1: 1D, 2: 2D, 3:1D_AWG/2D_AWG, 4:3D_AWG
            self._prepare_measurement_file()
            if self.ndev > 1:
                raise ValueError(
                    'Multiplexed readout is currently not supported for 2D measurements'
                )
            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)):
                    qkit.flow.sleep(
                    )  # 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()
Exemple #7
0
    def measure_3D(self, web_visible=True):
        '''
        measure full window of vna while sweeping x_set_obj and y_set_obj with parameters x_vec/y_vec. sweep over y_set_obj is the inner loop, for every value x_vec[i] all values y_vec are measured.

        optional: measure method to perform the measurement according to landscape, if set
        self.span is the range (in units of the vertical plot axis) data is taken around the specified funtion(s)
        note: make sure to have properly set x,y vectors before generating traces
        '''
        if not self.x_set_obj or not self.y_set_obj:
            logging.error('axes parameters not properly set...aborting')
            return
        self._scan_1D = False
        self._scan_2D = False
        self._scan_3D = True
        self._scan_time = False

        self._measurement_object.measurement_func = 'measure_3D'
        self._measurement_object.x_axis = self.x_coordname
        self._measurement_object.y_axis = self.y_coordname
        self._measurement_object.z_axis = 'frequency'
        self._measurement_object.web_visible = web_visible

        if not self.dirname:
            self.dirname = self.x_coordname + ', ' + self.y_coordname
        self._file_name = '3D_' + self.dirname.replace(' ', '').replace(
            ',', '_')
        if self.exp_name:
            self._file_name += '_' + self.exp_name

        if self.progress_bar:
            self._p = Progress_Bar(
                len(self.x_vec) * len(self.y_vec),
                '3D VNA sweep ' + self.dirname,
                self.vna.get_sweeptime_averages())

        self._prepare_measurement_vna()
        self._prepare_measurement_file()
        """opens qviewkit to plot measurement, amp and pha are opened by default"""
        """only middle point in freq array is plotted vs x and y"""
        if self.open_qviewkit:
            self._qvk_process = qviewkit.plot(self._data_file.get_filepath(),
                                              datasets=['amplitude', 'phase'])
        if self._fit_resonator:
            self._resonator = resonator(self._data_file.get_filepath())

        if self.landscape:
            self.center_freqs = np.array(self.landscape).T
        else:
            self.center_freqs = []  #load default sequence
            for i in range(len(self.x_vec)):
                self.center_freqs.append([0])

        self._measure()
Exemple #8
0
    def measure_2D(self, web_visible=True):
        '''
        measure method to record a (averaged) VNA trace, S11 or S21 according to the setting on the VNA
        for all parameters x_vec in x_obj
        '''

        if not self.x_set_obj:
            logging.error('axes parameters not properly set...aborting')
            return
        if len(self.x_vec) == 0:
            logging.error(
                'No points to measure given. Check your x vector... aborting')
            return
        self._scan_1D = False
        self._scan_2D = True
        self._scan_3D = False
        self._scan_time = False

        self._measurement_object.measurement_func = 'measure_2D'
        self._measurement_object.x_axis = self.x_coordname
        self._measurement_object.y_axis = 'frequency'
        self._measurement_object.z_axis = ''
        self._measurement_object.web_visible = web_visible

        if not self.dirname:
            self.dirname = self.x_coordname
        self._file_name = '2D_' + self.dirname.replace(' ', '').replace(
            ',', '_')
        if self.exp_name:
            self._file_name += '_' + self.exp_name

        if self.progress_bar:
            self._p = Progress_Bar(len(self.x_vec),
                                   '2D VNA sweep ' + self.dirname,
                                   self.vna.get_sweeptime_averages())

        self._prepare_measurement_vna()
        self._prepare_measurement_file()
        """opens qviewkit to plot measurement, amp and pha are opened by default"""
        if self._nop < 10:
            if self.open_qviewkit:
                self._qvk_process = qviewkit.plot(
                    self._data_file.get_filepath(),
                    datasets=['amplitude_midpoint', 'phase_midpoint'])
        else:
            if self.open_qviewkit:
                self._qvk_process = qviewkit.plot(
                    self._data_file.get_filepath(),
                    datasets=['amplitude', 'phase'])
        if self._fit_resonator:
            self._resonator = resonator(self._data_file.get_filepath())
        self._measure()
Exemple #9
0
 def _wait_progress_bar(self):
     ti = time()
     if self.progress_bar: 
         self._p = Progress_Bar(self.IVD.get_averages(),self.dirname,self.IVD.get_sweeptime())
     qt.msleep(.2)
     # wait for data
     while not self.IVD.ready():
         if time()-ti > self.IVD.get_sweeptime(query=False):
             if self.progress_bar: self._p.iterate()
             ti = time()
         qt.msleep(.2)
     
     if self.progress_bar:
         while self._p.progr < self._p.max_it:
             self._p.iterate()
Exemple #10
0
 def ramp_to(self, target = 0, channel = 0, steps = 20, dt = 0.1):
     """
     Ramp current to target
     Inputs:
         - target: target current value (mA)
         - channel: channel index (1..)
         - steps: number of steps
         - dt: wait time between two steps
     """
     p = Progress_Bar(steps,'Ramping current')
     for c in np.linspace(self.do_get_current(channel),target,steps):
         self.do_set_current(c, channel, verbose=False)
         p.iterate('{:.3g}mA'.format(c))
         time.sleep(dt)
     self.do_set_current(target, channel ,verbose=True)
Exemple #11
0
 def ramp_to(self, target=0, ch=1, steps=100, dt=0.05):
     """
     ramp current to target
     Inputs:
         - target: target current value
         - ch: channel index (1..)
         - steps: number of steps
         - dt: wait time between two steps
     """
     p = Progress_Bar(steps, 'Ramping current')  #init progress bar
     for c in np.linspace(self.do_get_current(ch), target, steps):
         self.do_set_current(c, ch, verbose=False)
         p.iterate("%.3gmA" % c)
         time.sleep(dt)
     self.do_set_current(c, ch, verbose=True)
Exemple #12
0
    def measure_IV_3D(self):
        self._measure_IV_1D = False
        self._measure_IV_2D = False
        self._measure_IV_3D = True
        if not self._check_measurement:
            return

        self._scan_name = 'IV_vs_' + self.x_coordname + '_' + self.y_coordname
        if self.exp_name:
            self._scan_name += '_' + self.exp_name
        self._p = Progress_Bar(len(self.x_vec) * len(self.y_vec))

        self._prepare_measurement_file()
        self._save_settings()
        #qviewkit.plot_hdf(self._data.filepath())

        self._measure()
        self._end_measurement()
Exemple #13
0
 def ramp_current(self, current, ramp_rate=1e-3, progress_bar=False):
     """
     ramps the bias current to a specified value with the specified ramp_rate.
     current: float, end current
     ramp_rate: float, change of voltage per second
     progress_bar: bool, weather the progress_bar should be displayed
     """
     start_current = self.do_get_measure_current()
     if np.sign(current - start_current) != np.sign(ramp_rate):
         ramp_rate *= (-1)
     current_values = np.arange(start_current, current, 0.1 * ramp_rate)
     if progress_bar:
         pb = Progress_Bar(len(current_values))
     for c in current_values:
         self.do_set_bias_current(c)
         time.sleep(0.1)
         if progress_bar:
             pb.iterate()
Exemple #14
0
    def measure_IV(self):
        self._measure_IV_1D = True
        self._measure_IV_2D = False
        self._measure_IV_3D = False
        if not self._check_measurement:
            return

        self._scan_name = 'IV'
        if self.exp_name:
            self._scan_name += '_' + self.exp_name
        self._p = Progress_Bar(self._sweeps)

        self._prepare_measurement_file()
        self._save_settings()
        #qviewkit.plot_hdf(self._data.get_filepath()

        self._measure()
        self._end_measurement()
Exemple #15
0
    def measure_1D(self):
        if self.x_set_obj is None:
            raise ValueError('x-axes parameters not properly set')

        self.mode = 1  # 1: 1D, 2: 2D, 3:1D_AWG/2D_AWG, 4:3D_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)
                qkit.flow.sleep()
                self._append_data()
                if self.show_progress_bar: p.iterate()
        finally:
            self._end_measurement()
Exemple #16
0
 def ramp_voltage(self, voltage, ramp_rate=1e-3, progress_bar=False):
     """
     ramps the bias voltage to a specified value with the specified ramp_rate.
     Keep in mind the defined current limit
     voltage: float, end voltage
     ramp_rate: float, change of voltage per second
     progress_bar: bool, weather the progress_bar should be displayed
     """
     start_voltage = self.do_get_measure_voltage()
     if np.sign(voltage - start_voltage) != np.sign(ramp_rate):
         ramp_rate *= (-1)
     voltage_values = np.arange(start_voltage, voltage, 0.1 * ramp_rate)
     if progress_bar:
         pb = Progress_Bar(len(voltage_values))
     for v in voltage_values:
         self.do_set_bias_voltage(v)
         time.sleep(0.1)
         if progress_bar:
             pb.iterate()
Exemple #17
0
    def measure_2D(self, web_visible=True):
        '''
        measure method to record a (averaged) VNA trace, S11 or S21 according to the setting on the VNA
        for all parameters x_vec in x_obj
        '''

        if not self.x_set_obj:
            logging.error('axes parameters not properly set...aborting')
            return
        self._scan_1D = False
        self._scan_2D = True
        self._scan_3D = False
        self._scan_time = False

        self._measurement_object.measurement_func = 'measure_2D'
        self._measurement_object.x_axis = self.x_coordname
        self._measurement_object.y_axis = 'frequency'
        self._measurement_object.z_axis = ''
        self._measurement_object.web_visible = web_visible

        if not self.dirname:
            self.dirname = self.x_coordname
        self._file_name = '2D_' + self.dirname.replace(' ', '').replace(
            ',', '_')
        if self.exp_name:
            self._file_name += '_' + self.exp_name

        if self.progress_bar:
            self._p = Progress_Bar(len(self.x_vec),
                                   '2D signal analyzer sweep ' + self.dirname,
                                   self.sig_analyzer.get_sweeptime_averages())

        self._prepare_measurement_sig_analyzer()
        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=self.traces_names)
        self._measure()
Exemple #18
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()
Exemple #19
0
    def monitor_depo(self):
        """
        Main sputter deposition monitoring function.

        Consider using the threaded version by calling start_depmon().

        Records the film resistance, thickness and deposition rate live during the sputter process.
        Stores everything into a h5 file.
        Provides measures to estimate the resulting resistance of the final film and thereby
        facilitates live adjustments to the sputter parameters.

        Note:
            set_duration and set_resolution should be called before to set the monitoring length and time resolution.
            set_filmparameters should be called before to provide the actual target values.
        """

        self._init_depmon()

        if self.progress_bar:
            self._p = Progress_Bar(
                self._duration / self._resolution,
                'EVAP_timetrace ' + self.dirname,
                self._resolution)  # FIXME: Doesn't make much sense...

        print('Monitoring deposition...')
        sys.stdout.flush()

        if self.open_qviewkit:
            self._qvk_process = qviewkit.plot(
                self._data_file.get_filepath(),
                datasets=['views/resistance_thickness'])

        try:
            """
            Initialize the data lists.
            """
            class MonData(object):
                resistance = np.array([])
                thickness = np.array([])

            mon_data = MonData()
            """
            Main loop:
            """
            mon_data.t0 = time.time(
            )  # note: Windows has limitations on time precision (about 16ms)
            for mon_data.it, _ in enumerate(self.x_vec):
                self._acquire(mon_data)

                if self.progress_bar:
                    self._p.iterate()

                # calculate the time when the next iteration should take place
                ti = mon_data.t0 + (float(mon_data.it) + 1) * self._resolution
                # wait until the total dt(iteration) has elapsed
                while time.time() < ti:
                    time.sleep(0.05)

        except KeyboardInterrupt:
            print('Monitoring interrupted by user.')

        except Exception as e:
            print(e)
            print(e.__doc__)
            print(e.message)

        finally:
            self._end_measurement()
Exemple #20
0
    def measure_timetrace(self, web_visible=True):
        '''
        measure method to record a single VNA timetrace, this only makes sense when span is set to 0 Hz!,
        tested only with KEYSIGHT E5071C ENA and its corresponding qkit driver
        LGruenhaupt 11/2016
        '''
        if self.vna.get_span() > 0:
            print 'VNA span not set to 0 Hz... aborting'
            return

        self._scan_1D = False
        self._scan_2D = False
        self._scan_3D = False
        self._scan_time = True

        self._measurement_object.measurement_func = 'measure_timetrace'
        self._measurement_object.x_axis = 'time'
        self._measurement_object.y_axis = ''
        self._measurement_object.z_axis = ''
        self._measurement_object.web_visible = web_visible

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

        self.x_vec = np.arange(0, self.number_of_timetraces, 1)

        self._prepare_measurement_vna()
        self._prepare_measurement_file()

        if self.progress_bar:
            self._p = Progress_Bar(self.number_of_timetraces,
                                   'VNA timetrace ' + self.dirname,
                                   self.vna.get_sweeptime_averages())

        print 'recording timetrace(s)...'
        sys.stdout.flush()

        qt.mstart()
        try:
            """
            loop: x_obj with parameters from x_vec
            """

            for i, x in enumerate(self.x_vec):

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

                if self.averaging_start_ready:  #LG 11/2016
                    self.vna.start_measurement()
                    ti = time(
                    )  #changed from time.time() to time() - LGruenhaupt OCT_2016
                    tp = time()  #added to enable use of progress bar
                    #self._p = Progress_Bar(self.vna.get_averages(),self.dirname,self.vna.get_sweeptime_averages()) moved to line 303
                    ''' This is to prevent the vna.ready() function from timing out. LG NOV/16 '''
                    if self.vna.get_Average():
                        print 'this function only makes sense without averaging'
                        qt.mend()
                        self._end_measuremt()
                    else:
                        #self._p = Progress_Bar(1,self.dirname,self.vna.get_sweeptime())
                        qt.msleep(self.vna.get_sweeptime())
                        #self._p.iterate()

                        while not self.vna.ready():
                            qt.msleep(
                                .2
                            )  #this is just to check if the measurement has finished

                        data_amp, data_pha = self.vna.get_tracedata()
                        self._data_amp.append(data_amp)
                        self._data_pha.append(data_pha)
                qt.msleep()
                if self.progress_bar:
                    self._p.iterate()

                else:
                    print 'not implemented for this VNA, only works with Keysight ENA 5071C'
                    qt.mend()
                    self._end_measurement()

        except Exception as e:
            print e.__doc__
            print e.message
        finally:
            self._end_measurement()
            qt.mend()
Exemple #21
0
    def measure_1D(self, rescan=True, web_visible=True):
        '''
        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._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 = web_visible

        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:
            self._qvk_process = 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()
        if rescan:
            if self.averaging_start_ready:
                self.vna.start_measurement()
                ti = time()
                if self.progress_bar:
                    self._p = Progress_Bar(self.vna.get_averages(),
                                           self.dirname,
                                           self.vna.get_sweeptime())
                qt.msleep(.2)
                while not self.vna.ready():
                    if time() - ti > self.vna.get_sweeptime(query=False):
                        if self.progress_bar: self._p.iterate()
                        ti = time()
                    qt.msleep(.2)
                if self.progress_bar:
                    while self._p.progr < self._p.max_it:
                        self._p.iterate()
            else:
                self.vna.avg_clear()
                if self.vna.get_averages() == 1 or self.vna.get_Average(
                ) == False:  #no averaging
                    if self.progress_bar:
                        self._p = Progress_Bar(1, self.dirname,
                                               self.vna.get_sweeptime())
                    qt.msleep(self.vna.get_sweeptime())  #wait single sweep
                    if self.progress_bar: self._p.iterate()
                else:  #with averaging
                    if self.progress_bar:
                        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
                            if self.progress_bar: self._p.iterate()
                    else:  #old style
                        for a in range(self.vna.get_averages()):
                            qt.msleep(self.vna.get_sweeptime()
                                      )  #wait single sweep time
                            if self.progress_bar: 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()
Exemple #22
0
def load_tabor(channel_sequences,
               ro_index,
               sample,
               reset=True,
               show_progress_bar=True):
    """
    This function takes the data, coming from virtual awg, and loads them into the awg
    :param channel_sequences: This must be a list of list, i.e., a list of channels each containing the sequences
    :param ro_index: coming from virtual awg, for each sequence there is a ro_index letting the awg know, when to
                     send the trigger.
    :param sample: you should know this
    :param reset: simply sets the awg_channel active, probably not needed
    :param show_progress_bar: enables the progress bar
    :return:
    """
    awg = sample.awg
    awg.clear_waveforms()
    number_of_channels = 0
    complex_channel = []
    for chan in channel_sequences:
        if True in (s.dtype == np.complex128 for s in chan):
            number_of_channels += 2
            complex_channel.append(True)
        else:
            number_of_channels += 1
            complex_channel.append(False)
    if number_of_channels > awg._numchannels:
        raise ValueError('more sequences than channels')
    # reordering channels if necessary
    if number_of_channels > 2:
        if complex_channel[:2] == [False, True]:
            logging.warning(
                'Channels reordered! Please do not split complex channels on two different channelpairs.'
                'Complex channel is on chpair 1')
            channel_sequences[:2] = [
                channel_sequences[1], channel_sequences[0]
            ]
            complex_channel[:2] = [True, False]
    #qkit.flow.start()

    if reset:
        _reset(awg, number_of_channels, ro_index)
    # Loading the waveforms into the AWG, differentiating between all cases
    if show_progress_bar:
        p = Progress_Bar(len(ro_index), 'Load AWG')

    if number_of_channels == 1:
        for j, seq in enumerate(channel_sequences[0]):
            _adjust_wfs_for_tabor(seq, [0], ro_index, 1, j, sample)
            if show_progress_bar:
                p.iterate()

    elif number_of_channels == 2:
        if complex_channel[0]:
            for j, seq in enumerate(channel_sequences[0]):
                _adjust_wfs_for_tabor(seq.real, seq.imag, ro_index, 1, j,
                                      sample)
                if show_progress_bar:
                    p.iterate()
        else:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1])):
                _adjust_wfs_for_tabor(seq[0], seq[1], ro_index, 1, j, sample)
                if show_progress_bar:
                    p.iterate()

    elif number_of_channels == 3:
        if complex_channel[0]:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1])):
                _adjust_wfs_for_tabor(seq[0].real, seq[0].imag, ro_index, 1, j,
                                      sample)
                _adjust_wfs_for_tabor(seq[1], [0], ro_index, 2, j, sample)
                if show_progress_bar:
                    p.iterate()
        else:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1],
                        channel_sequences[2])):
                _adjust_wfs_for_tabor(seq[0], seq[1], ro_index, 1, j, sample)
                _adjust_wfs_for_tabor(seq[2], [0], ro_index, 2, j, sample)
                if show_progress_bar:
                    p.iterate()

    else:  # 4 channels
        if complex_channel == [True, True]:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1])):
                _adjust_wfs_for_tabor(seq[0].real, seq[0].imag, ro_index, 1, j,
                                      sample)
                _adjust_wfs_for_tabor(seq[1].real, seq[1].imag, ro_index, 2, j,
                                      sample)
                if show_progress_bar:
                    p.iterate()
        elif complex_channel == [True, False, False]:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1],
                        channel_sequences[2])):
                _adjust_wfs_for_tabor(seq[0].real, seq[0].imag, ro_index, 1, j,
                                      sample)
                _adjust_wfs_for_tabor(seq[1], seq[2], ro_index, 2, j, sample)
                if show_progress_bar:
                    p.iterate()
        elif complex_channel == [False, False, True]:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1],
                        channel_sequences[2])):
                _adjust_wfs_for_tabor(seq[0], seq[1], ro_index, 1, j, sample)
                _adjust_wfs_for_tabor(seq[2].real, seq[2].imag, ro_index, 2, j,
                                      sample)
                if show_progress_bar:
                    p.iterate()
        else:
            for j, seq in enumerate(
                    zip(channel_sequences[0], channel_sequences[1],
                        channel_sequences[2], channel_sequences[3])):
                _adjust_wfs_for_tabor(seq[0], seq[1], ro_index, 1, j, sample)
                _adjust_wfs_for_tabor(seq[2], seq[3], ro_index, 2, j, sample)
                if show_progress_bar:
                    p.iterate()

    gc.collect()

    if number_of_channels <= 2:
        num_channels = [1, 2]
    else:
        num_channels = [1, 2, 3, 4]
    return np.all([awg.get('ch%i_status' % i) for i in num_channels])
Exemple #23
0
def update_sequence(ts,
                    wfm_func,
                    sample,
                    iq=None,
                    loop=False,
                    drive='c:',
                    path='\\waveforms',
                    reset=True,
                    marker=None,
                    markerfunc=None,
                    ch2_amp=2,
                    chpair=1,
                    awg=None,
                    show_progress_bar=True):
    '''
        set awg to sequence mode and push a number of waveforms into the sequencer
        
        inputs:
        
        ts: array of times, len(ts) = #sequenzes
        wfm_func: waveform function usually generated via generate_waveform using ts[i]; this can be a tuple of arrays (for channels 0,1, heterodyne mode) or a single array (homodyne mode)
        sample: sample object
        
        iq: Reference to iq mixer instrument. If None (default), the wfm will not be changed. Otherwise, the wfm will be converted via iq.convert()
        
        marker: marker array in the form [[ch1m1,ch1m2],[ch2m1,ch2m2]] and all entries arrays of sample length
        markerfunc: analog to wfm_func, set marker to None when used
        
        for the 6GS/s AWG, the waveform length must be divisible by 64
        for the 1.2GS/s AWG, it must be divisible by 4
        
        chpair: if you use the 4ch Tabor AWG as a single 2ch instrument, you can chose to take the second channel pair here (this can be either 1 or 2).
    '''
    qkit.flow.start()
    if awg == None:
        awg = sample.awg
    clock = sample.clock
    wfm_func2 = wfm_func
    if iq != None:
        wfm_func2 = lambda t, sample: iq.convert(wfm_func(t, sample))

    # create new sequence
    if reset:
        if "Tektronix" in awg.get_type():
            awg.set_runmode('SEQ')
            awg.set_seq_length(0)  #clear sequence, necessary?
            awg.set_seq_length(len(ts))
        elif "Tabor" in awg.get_type():
            awg.set('p%i_runmode' % chpair, 'SEQ')
            awg.define_sequence(chpair * 2 - 1, len(ts))

        #amplitude settings of analog output
        awg.set_ch1_offset(0)
        awg.set_ch2_offset(0)
        awg.set_ch1_amplitude(2)
        awg.set_ch2_amplitude(ch2_amp)

    #generate empty tuples
    wfm_samples_prev = [None, None]
    wfm_fn = [None, None]
    wfm_pn = [None, None]
    if show_progress_bar:
        p = Progress_Bar(
            len(ts) * (2 if "Tektronix" in awg.get_type() else 1),
            'Load AWG')  #init progress bar

    #update all channels and times
    for ti, t in enumerate(ts):  #run through all sequences
        qkit.flow.sleep()
        wfm_samples = wfm_func2(t, sample)  #generate waveform
        if not isinstance(wfm_samples[0],
                          (list, tuple, np.ndarray)):  #homodyne
            wfm_samples = [
                wfm_samples,
                np.zeros_like(wfm_samples, dtype=np.int8)
            ]

        for chan in [0, 1]:
            if markerfunc != None:  #use markerfunc
                try:
                    if markerfunc[chan][0] == None:
                        marker1 = np.zeros_like(wfm_samples, dtype=np.int8)[0]
                    else:
                        marker1 = markerfunc[chan][0](t, sample)

                    if markerfunc[chan][1] == None:
                        marker2 = np.zeros_like(wfm_samples, dtype=np.int8)[0]
                    else:
                        marker2 = markerfunc[chan][1](t, sample)

                except TypeError:  #only one markerfunc given
                    marker1, marker2 = np.zeros_like(wfm_samples,
                                                     dtype=np.int8)
                    if chan == 0:
                        marker1 = markerfunc(t, sample)

            elif marker == None:  #fill up with zeros
                marker1, marker2 = np.zeros_like(wfm_samples, dtype=np.int8)
            else:  #or set your own markers
                c_marker1, c_marker2 = marker[chan]
                marker1 = c_marker1[ti]
                marker2 = c_marker2[ti]

            if "Tektronix" in awg.get_type():
                wfm_fn[chan] = 'ch%d_t%05d' % (
                    chan + 1, ti)  # filename is kept until changed
                if len(wfm_samples) == 1 and chan == 1:
                    wfm_pn[chan] = '%s%s\\%s' % (
                        drive, path, np.zeros_like(
                            wfm_fn[0]))  #create empty array
                else:
                    wfm_pn[chan] = '%s%s\\%s' % (drive, path, wfm_fn[chan])
                awg.wfm_send(wfm_samples[chan], marker1, marker2, wfm_pn[chan],
                             clock)

                awg.wfm_import(wfm_fn[chan], wfm_pn[chan], 'WFM')

                # assign waveform to channel/time slot
                awg.wfm_assign(chan + 1, ti + 1, wfm_fn[chan])

                if loop:
                    awg.set_seq_loop(ti + 1, np.infty)
            elif "Tabor" in awg.get_type():
                if chan == 1:  #write out both together
                    awg.wfm_send2(wfm_samples[0], wfm_samples[1], marker1,
                                  marker2, chpair * 2 - 1, ti + 1)
                else:
                    continue
            else:
                raise ValueError("AWG type not known")
            if show_progress_bar: p.iterate()

        gc.collect()

    if reset and "Tektronix" in awg.get_type():
        # enable channels
        awg.set_ch1_status(True)
        awg.set_ch2_status(True)
        awg.set_seq_goto(len(ts), 1)
        awg.run()
        awg.wait(10, False)
    elif reset and "Tabor" in awg.get_type():
        # enable channels
        #awg.preset()
        awg.set_ch1_status(True)
        awg.set_ch2_status(True)
    qkit.flow.end()
    if sample.__dict__.has_key('mspec'):
        sample.mspec.spec_stop()
        sample.mspec.set_segments(len(ts))
    return np.all([awg.get('ch%i_status' % i) for i in [1, 2]])