Пример #1
0
    def _update_dac(self, channels, samples, marker1 = None, marker2 = None, drive = None, path = None):
        '''
            update waveform data on the awg

            Input:
                samples - matrix of samples to put on awg channels
                channels - channels to install them on
        '''
        samples = np.array(samples)
        if(marker1 == None):
            marker1 = np.zeros(samples.shape)
            marker1[:,1:10]=1
        if(marker2 == None):
            marker2 = np.zeros(samples.shape)
            marker2[:,1:10]=1

            
        if "GHzDAC" == self._awg.get_type():   #Martinis board
            drive = 'c:'
            path = '\\waveforms'
            for idx in range(0, len(channels)):
                if(channels[idx] == -1): continue # only apply I or Q if the user wishes that
                channel = 1+channels[idx]
                
                fn = drive + path + '\\ch%d'%channel
                self._awg.send_waveform(samples[idx, :], marker1[idx, :], marker2[idx, :], fn, self._dac_clock)
                self._awg.load_waveform(channel, 'ch%d'%channel, drive, path)
                
            # setup channel overall amplitude
            for channel in [self._dac_channel_I, self._dac_channel_Q]:
                getattr(self._awg, 'set_ch%d_amplitude'%(channel+1))(self._tone_amp)
            self._awg.run()
            
        elif "Tabor_WX1284C" == self._awg.get_type():   #Tabor AWG
            self._awg.preset_readout()
            try:
                self._awg.set_clock(self._sample.readout_clock)
            except:
                logging.warning('Clock and amplitude settings not written.')
            self._awg.wfm_send2(samples[0],samples[1],m1 = marker1[0],m2 = marker2[0],seg=1)
            self._awg.define_sequence(1,1)
        elif "Tektronix" in self._awg.get_type():   #Tektronix AWG
            try:
                self._awg.set_clock(self._sample.readout_clock)
                self._awg.set_ch1_amplitude(self._tone_amp)
                self._awg.set_ch2_amplitude(self._tone_amp)
            except:
                logging.warning('Clock and amplitude settings not written.')
            if self._sample:
                lawg.update_sequence([1],lambda t, sample: [samples[0],samples[1]], self._sample, awg = self._awg)
            else:
                logging.error('Please provide sample object in instantiating readout when using Tektronix AWG for readout.')
Пример #2
0
    def _update_dac(self, channels, samples, marker1 = None, marker2 = None, drive = None, path = None):
        '''
            update waveform data on the awg

            Input:
                samples - matrix of samples to put on awg channels
                channels - channels to install them on
        '''
        samples = np.array(samples)
        if(marker1 == None):
            marker1 = np.zeros(samples.shape)
            marker1[:,1:10]=1
        if(marker2 == None):
            marker2 = np.zeros(samples.shape)
            marker2[:,1:10]=1

            
        if "GHzDAC" == self._awg.get_type():   #Martinis board
            drive = 'c:'
            path = '\\waveforms'
            for idx in range(0, len(channels)):
                if(channels[idx] == -1): continue # only apply I or Q if the user wishes that
                channel = 1+channels[idx]
                
                fn = drive + path + '\\ch%d'%channel
                self._awg.send_waveform(samples[idx, :], marker1[idx, :], marker2[idx, :], fn, self._dac_clock)
                self._awg.load_waveform(channel, 'ch%d'%channel, drive, path)
                
            # setup channel overall amplitude
            for channel in [self._dac_channel_I, self._dac_channel_Q]:
                getattr(self._awg, 'set_ch%d_amplitude'%(channel+1))(self._tone_amp)
            self._awg.run()
            
        elif "Tabor_WX1284C" == self._awg.get_type():   #Tabor AWG
            #self._awg.preset_readout()
            try:
                self._awg.set_clock(self._sample.readout_clock)
            except:
                logging.warning('Clock and amplitude settings not written.')
            self._awg.wfm_send2(samples[0],samples[1],m1 = marker1[0],m2 = marker2[0],seg=1)
            self._awg.define_sequence(1,1)
        elif "Tektronix" in self._awg.get_type():   #Tektronix AWG
            try:
                self._awg.set_clock(self._sample.readout_clock)
                self._awg.set_ch1_amplitude(self._tone_amp)
                self._awg.set_ch2_amplitude(self._tone_amp)
            except:
                logging.warning('Clock and amplitude settings not written.')
            if self._sample:
                lawg.update_sequence([1],lambda t, sample: [samples[0],samples[1]], self._sample, awg = self._awg)
            else:
                logging.error('Please provide sample object in instantiating readout when using Tektronix AWG for readout.')
Пример #3
0
def radial(thetas, phis, wfm, sample, marker=None, delay=0, markerfunc=None):
    angles = [[0, 0]]
    for i, th in enumerate(thetas):
        angles = np.append(angles,
                           np.array([
                               np.ones(phis[i]) * th,
                               np.linspace(0,
                                           2 * np.pi,
                                           phis[i],
                                           endpoint=False)
                           ]).T,
                           axis=0)
    angles = angles[1:]
    if not os.path.exists(
            qt.config.get('datadir') + time.strftime("\\%Y%m%d")):
        os.makedirs(qt.config.get('datadir') + time.strftime("\\%Y%m%d"))
    np.savetxt(
        qt.config.get('datadir') +
        time.strftime("\\%Y%m%d\\Tomography_%H%M%S.set"), angles)
    sample.update_instruments()
    if marker == None:
        new_marker = None
    else:
        new_marker = [[], [], [], []]
        if marker.shape[0] == 4:  #each marker is defined
            for i in range(len(marker)):
                new_marker[i] = [
                    append_wfm(
                        marker[i],
                        np.zeros_like(
                            gwf.square(0, sample,
                                       angle[0] / np.pi * sample.tpi + delay)))
                    for angle in angles
                ]
        else:
            new_marker[0] = [
                append_wfm(
                    marker,
                    np.zeros_like(
                        gwf.square(0, sample,
                                   angle[0] / np.pi * sample.tpi + delay)))
                for angle in angles
            ]
            new_marker[1:4] = [np.zeros_like(new_marker[0]) for i in range(3)]
        new_marker = [[new_marker[0], new_marker[1]],
                      [new_marker[2], new_marker[3]]]
    result = load_awg.update_sequence(
        range(len(angles)),
        lambda t, sample2: iq.convert(
            append_wfm(
                wfm,
                gwf.square(angles[t][0] / np.pi * sample.tpi, sample, angles[
                    t][0] / np.pi * sample.tpi + delay) * np.exp(1j * angles[t]
                                                                 [1]))),
        sample,
        marker=new_marker,
        markerfunc=markerfunc)
    print "You have a tomography resolution of %i points" % len(angles)
    return result
Пример #4
0
def radial(thetas, phis, wfm, sample, marker = None, delay = 0, markerfunc = None):
	angles=[[0,0]]
	for i,th in enumerate(thetas):
		angles=np.append(angles,np.array([np.ones(phis[i])*th,np.linspace(0,2*np.pi,phis[i],endpoint=False)]).T,axis=0)
	angles=angles[1:]
	if not os.path.exists(qt.config.get('datadir')+time.strftime("\\%Y%m%d")):
		os.makedirs(qt.config.get('datadir')+time.strftime("\\%Y%m%d"))
	np.savetxt(qt.config.get('datadir')+time.strftime("\\%Y%m%d\\Tomography_%H%M%S.set"),angles)
	sample.update_instruments()
	if marker == None:
		new_marker = None
	else:
		new_marker = [[],[],[],[]]
		if marker.shape[0] == 4: #each marker is defined
			for i in range(len(marker)):
				new_marker[i] = [ append_wfm(marker[i],np.zeros_like(gwf.square(0, sample, angle[0]/np.pi*sample.tpi + delay))) for angle in angles ]
		else:
			new_marker[0] = [ append_wfm(marker,np.zeros_like(gwf.square(0, sample,  angle[0]/np.pi*sample.tpi + delay))) for angle in angles ]
			new_marker[1:4]=[ np.zeros_like(new_marker[0]) for i in range(3) ]
		new_marker = [[new_marker[0],new_marker[1]],[new_marker[2],new_marker[3]]]
	result = load_awg.update_sequence(range(len(angles)), lambda t, sample2: iq.convert(append_wfm(wfm,gwf.square(angles[t][0]/np.pi*sample.tpi, sample, angles[t][0]/np.pi*sample.tpi + delay)*np.exp(1j*angles[t][1]))), sample, marker = new_marker, markerfunc=markerfunc)
	print "You have a tomography resolution of %i points"%len(angles)
	return result
Пример #5
0
def threepoint(ts,
               wfm_func,
               sample,
               loop=False,
               drive='c:',
               path='\\waveforms',
               reset=True,
               marker=None,
               markerfunc=None,
               largeblocks=False,
               delay=0):
    '''
		This is a helper function to pass the right sequences to your AWG for a tomographic measurement.
		
		For each value in ts, three measurements are done:
		* One without a rotation
		* One with a rotation around x just before the readout
		* One with a rotation around y just before the readout
		If largeblocks=False (default): all 3 mmts are done for one value in ts, then go on to the next value. If largeblocks=True, the mmts consists of 3 large blocks with all ts, so the tomographic mmt sequence changes slowly.
		
		The wfm_func is automatically shifted by a pi/2 pulse + delay, THE MARKER IS ONLY SHIFTED WHEN PASSED AS markerfunc!
		
		
		
		At the end, three mmts are appended: no pulse, pi/2 pulse and pi-pulse, all without any tomographic pulse, in order to get a good scale for the analysis.
	'''
    def phase_t(t):
        if largeblocks:  #In this version, all ts will be gone through first and then all phases
            phase = t / len(ts)
            t = t % len(ts)
            if phase == 3:
                return [-1 - t, 0]
            return [ts[t], [0, 1, 1j][phase]]
            phase = [0, 1, 1j][phase]  #map the index to the right values
            t = ts[t]
            return [t, phase]

        else:  #In this version, all phases will be gone through first and then all ts
            phase = t % 3
            t = t / 3
            if t >= len(ts):
                return [-1 - phase, 0]

            return [ts[t], [0, 1, 1j][phase]]
            phase = [0, 1, 1j][phase]  #map the index to the right values
            return [t, phase]

    def wfm_helper(t, sample):
        t, phase = phase_t(t)
        if t == -1: return gwf.square(0, sample)
        if t == -2: return gwf.square(sample.tpi, sample)
        if t == -3: return gwf.square(sample.tpi2, sample)
        return append_wfm(
            wfm_func(t, sample),
            gwf.square(sample.tpi2, sample, sample.tpi2 + delay) * phase)

    def marker_helper(t, sample):
        t, phase = phase_t(t)
        if t < 0: return gwf.square(0, sample)
        return append_wfm(
            markerfunc(t, sample), gwf.square(0, sample, sample.tpi2 + delay)
        )  #ToDo: This does not work for the general array markerfunc=[[funcA1,None],[None,funcB2]]

    ts2 = range(3 * len(ts) + 3)
    if marker != None:
        if largeblocks:  #The following is for option 1, where first all x, then all y coordinates are taken
            marker = np.append(
                np.append(
                    np.append(marker, marker, axis=2), marker,
                    axis=2),  # Add the same marker three times because of the 
                np.zeros_like(marker[:, :, :3, :]),
                axis=2)

        else:  #The folllowing is for option 2, where all coordinates are taken for one ts:
            marker = np.append(marker.repeat(3, axis=2),
                               np.zeros_like(marker[:, :, :3, :]),
                               axis=2)
    if markerfunc == None:
        return load_awg.update_sequence(
            ts2,
            lambda t, sample: iq.convert(wfm_helper(t, sample)),
            sample,
            loop=loop,
            drive=drive,
            path=path,
            reset=reset,
            marker=marker,
            markerfunc=None)
    else:
        return load_awg.update_sequence(
            ts2,
            lambda t, sample: iq.convert(wfm_helper(t, sample)),
            sample,
            loop=loop,
            drive=drive,
            path=path,
            reset=reset,
            marker=marker,
            markerfunc=lambda t, sample: marker_helper(t, sample))
    def _update_dac(self, channels, samples, marker1 = None, marker2 = None, drive = None, path = None):
        """
            update waveform data on the awg

            Input:
                samples - matrix of samples to put on awg channels
                channels - channels to install them on
        """
        if self._awg is None:
            logging.warning("You haven't provided a readout awg so I can't load a pulse in. "
                            "You have to do it manually!")
            return
        samples = np.array(samples)
        if marker1 is None:
            marker1 = np.zeros(samples.shape)
            marker1[:,1:10]=1
        if marker2 is None:
            marker2 = np.zeros(samples.shape)
            marker2[:,1:10]=1

        if "GHzDAC" == self._awg.get_type():   #Martinis board
            drive = 'c:'
            path = '\\waveforms'
            for idx in range(0, len(channels)):
                if(channels[idx] == -1): continue # only apply I or Q if the user wishes that
                channel = 1+channels[idx]
                
                fn = drive + path + '\\ch%d'%channel
                self._awg.send_waveform(samples[idx, :], marker1[idx, :], marker2[idx, :], fn, self._dac_clock)
                self._awg.load_waveform(channel, 'ch%d'%channel, drive, path)
                
            # setup channel overall amplitude
            for channel in [self._dac_channel_I, self._dac_channel_Q]:
                getattr(self._awg, 'set_ch%d_amplitude'%(channel+1))(self._tone_amp)
            self._awg.run()
            
        elif "Tabor_WX1284C" == self._awg.get_type():   #Tabor AWG
            #self._awg.preset_readout()
            try:
                self._awg.set_clock(self.sample.readout_clock)
            except:
                logging.warning('Clock and amplitude settings not written.')

            seg_n=0
            for i in range (1,32000):
                if int(self._awg.ask(":TRAC:DEF%i?"%i).split()[-1])==0:
                    seg_n = i
                    break
            self._awg.wfm_send2(samples[0],samples[1],m1 = marker1[0],m2 = marker2[0],channel=self._dac_channel_I, seg=seg_n)
            self._awg.define_sequence(self._dac_channel_I,[seg_n,seg_n,seg_n])

        elif "Tektronix" in self._awg.get_type():   #Tektronix AWG
            try:
                self._awg.set_clock(self.sample.readout_clock)
                self._awg.set_ch1_amplitude(self._tone_amp)
                self._awg.set_ch2_amplitude(self._tone_amp)
            except:
                logging.warning('Clock and amplitude settings not written.')
            if self.sample:
                lawg.update_sequence([1],lambda t, sample: [samples[channels[0]],samples[channels[1]]], self.sample, awg = self._awg, marker = [[marker1,marker2],[marker1,marker2]], show_progress_bar=False)
            else:
                logging.error('Please provide sample object in instantiating readout when using Tektronix AWG for readout.')
Пример #7
0
def threepoint(ts, wfm_func, sample, loop = False, drive = 'c:', path = '\\waveforms', reset = True, marker=None, markerfunc = None, largeblocks = False, delay = 0):
	'''
		This is a helper function to pass the right sequences to your AWG for a tomographic measurement.
		
		For each value in ts, three measurements are done:
		* One without a rotation
		* One with a rotation around x just before the readout
		* One with a rotation around y just before the readout
		If largeblocks=False (default): all 3 mmts are done for one value in ts, then go on to the next value. If largeblocks=True, the mmts consists of 3 large blocks with all ts, so the tomographic mmt sequence changes slowly.
		
		The wfm_func is automatically shifted by a pi/2 pulse + delay, THE MARKER IS ONLY SHIFTED WHEN PASSED AS markerfunc!
		
		
		
		At the end, three mmts are appended: no pulse, pi/2 pulse and pi-pulse, all without any tomographic pulse, in order to get a good scale for the analysis.
	'''
	
	def phase_t(t): 
		if largeblocks: #In this version, all ts will be gone through first and then all phases
			phase = t/len(ts)
			t = t%len(ts)
			if phase == 3 :
				return [-1-t,0]
			return [ts[t],[0,1,1j][phase]]
			phase = [0,1,1j][phase]  #map the index to the right values
			t = ts[t]
			return [t,phase]

		else:	#In this version, all phases will be gone through first and then all ts
			phase = t%3
			t = t/3
			if t >= len(ts) :
				return [-1-phase,0]
			
			return [ts[t],[0,1,1j][phase]]
			phase = [0,1,1j][phase]  #map the index to the right values
			return [t,phase]
	
	def wfm_helper (t, sample):
		t,phase = phase_t(t)
		if t == -1 : return gwf.square(0,sample)
		if t == -2 : return gwf.square(sample.tpi,sample)
		if t == -3 : return gwf.square(sample.tpi2,sample)
		return append_wfm(wfm_func(t,sample),gwf.square(sample.tpi2,sample,sample.tpi2+delay)*phase)
	
	def marker_helper (t, sample):
		t,phase = phase_t(t)
		if t <0 : return gwf.square(0,sample)
		return append_wfm(markerfunc(t,sample),gwf.square(0,sample,sample.tpi2+delay)) #ToDo: This does not work for the general array markerfunc=[[funcA1,None],[None,funcB2]]
	
	ts2 = range(3*len(ts)+3)
	if marker!= None:
		if largeblocks:		#The following is for option 1, where first all x, then all y coordinates are taken
			marker = np.append(
						np.append(
							np.append(
								marker,
								marker,axis=2),
							marker,axis=2), # Add the same marker three times because of the 
						np.zeros_like(marker[:,:,:3,:]),axis=2)
			
		else:	#The folllowing is for option 2, where all coordinates are taken for one ts:
			marker = np.append(marker.repeat(3,axis=2),np.zeros_like(marker[:,:,:3,:]),axis=2)
	if markerfunc==None:
		return load_awg.update_sequence(ts2, lambda t, sample: iq.convert(wfm_helper(t,sample)), sample, loop = loop, drive = drive, path = path, reset = reset, marker=marker ,markerfunc=None)
	else:
		return load_awg.update_sequence(ts2, lambda t, sample: iq.convert(wfm_helper(t,sample)), sample, loop = loop, drive = drive, path = path, reset = reset, marker=marker ,markerfunc=lambda t, sample:marker_helper(t,sample))