Example #1
0
 def plotElement(self, plotid, gatex, gatey, channelx, channely, dividerx,
                 dividery):
     #if self.w is None:
     #    self.w = PlotWindow(pulse=self.gelem)
     #    self.w.show()
     self.generateElement()
     plotter(self.gelem)
     if plotid != 0:
         annotateshape(plotid, gatex, gatey, self.gelem, channelx, channely,
                       dividerx, dividery)
Example #2
0
w_loadR = rect(Ltime,LoadAmp*GainR*0.2)  #here
w_emptyL = rect(Etime,0e-3*GainL*0.2)
w_initL = ramp(Inittime,0,20e-3*GainL*0.2)
w_PihalfPulseL = rect(Pihalftime, -30e-3*GainR*0.2)
w_minus_PihalfPulseL = rect(Pihalftime, 30e-3*GainR*0.2)
w_loadL = rect(Ltime,-LoadAmp*GainR*0.2)  #here
#wave w_markerleft = marker(marker_pos/2, 1)
#wave w_markerMiddle = marker(marker_pos/2, 0)
#wave w_markerRight = marker(MeasureTime, 0)
w_measureR = rect(MeasureTime,0*GainR*0.2) #dont use up waveform mempey to stay in 0,0
w_measureL = rect(MeasureTime,0*GainL*0.2)
#100 us pulse, 1 us in empty, 1 us in load and almost all the time in measure
#make it zero average
w_pulseR = w_minus_PihalfPulseR + w_minus_PihalfPulseR + w_emptyR + w_initR + w_PihalfPulseR + w_loadR + w_PihalfPulseR #+ w_measureR
w_pulseL = w_minus_PihalfPulseL + w_minus_PihalfPulseL + w_initL + w_emptyL + w_PihalfPulseL + w_loadL + w_PihalfPulseL + w_measureL
plotter(w_pulseL)
plt.show()
plotter(w_pulseR)
plt.show()
'''
#We want to step the detuning from 0 to 12 mV in as many steps as possible
#the amount of steps depends on the max number of samples the sequencer can store
for i in range(200):
  Ltime = i*1.25e-9*f_sam  #time in (1,1) in steps of 10 ns, i=100 is 1 us
  w_measureR = 0*GainR*rect(MeasureTime-2*Ltime,0.2) 
  w_measureL = 0*GainL*rect(MeasureTime-2*Ltime,0.2) 
  w_loadL = -LoadAmp*GainL*rect(Ltime, 0.2) 
  w_loadR = LoadAmp*GainR*rect(Ltime, 0.2) 
  w_initL = LoadAmp*GainL*rect(Ltime,0.2) 
  w_initR = -LoadAmp*GainR*rect(Ltime,0.2) 
  w_pulseR = w_pulseR  + w_minus_PihalfPulseR + w_minus_PihalfPulseR + w_initR + w_emptyR + w_PihalfPulseR+ w_loadR  + w_PihalfPulseR +w_measureR
    def home(self):

        # Create channel voltage, divider and offset boxes and buttons
        win4 = QWidget(self)
        lay4 = QGridLayout(win4)
        vpp = QLabel(self)
        vpp.setText('Vpp')
        offset = QLabel(self)
        offset.setText('Offset')
        lay4.addWidget(vpp, 0, 1, 1, 1)
        lay4.addWidget(offset, 0, 2, 1, 1)
        number_channels = 4
        chlabel = list(range(number_channels))
        chbox = list(range(number_channels))
        offbox = list(range(number_channels))
        for i in range(number_channels):
            chlabel[i] = QLabel(self)
            chlabel[i].setText('Ch%d' % (i + 1))
            chbox[i] = QLineEdit(self)
            chbox[i].setText('4.5')
            offbox[i] = QLineEdit(self)
            offbox[i].setText('0')
            lay4.addWidget(chlabel[i], i + 1, 0, 1, 1)
            lay4.addWidget(chbox[i], i + 1, 1, 1, 1)
            lay4.addWidget(offbox[i], i + 1, 2, 1, 1)
        win4.move(10, 75)

        # Continuous sequence?
        contseq = QWidget(self)
        lay_contseq = QGridLayout(contseq)
        contseqboxlabel = QLabel(self)
        contseqboxlabel.setText('Simple continuous element?')
        contseqboxlabel.resize(contseqboxlabel.minimumSizeHint())
        contseqbox = QCheckBox(self)
        lay_contseq.addWidget(contseqboxlabel, 0, 0, 1, 1)
        lay_contseq.addWidget(contseqbox, 0, 1, 1, 1)
        contseq.move(20, 280)

        # Upload to AWG
        # Function
        uploadbtn = QPushButton('Upload To AWG', self)
        uploadbtn.clicked.connect(lambda state: self.uploadToAWG(
            str(Choose_awg.currentText()), chbox))

        # Choose awg
        Choose_awg = QComboBox(self)
        Choose_awg.addItem('AWG5014')
        Choose_awg.addItem('AWG5208')

        # Update sequencing parameters: table and update button
        win2 = QWidget(self)
        lay2 = QVBoxLayout(win2)
        seqtable = QTableWidget(4, 4, self)
        seqtable.setColumnCount(4)
        # Set top headers
        hlist = ["TrigWait", "NumReps", "JumpTarget", "Goto"]
        for i in range(len(hlist)):
            seqtable.setColumnWidth(i, 70)
            seqtable.setHorizontalHeaderItem(i, QTableWidgetItem(hlist[i]))
        seqtable.setRowCount(0)
        updateseqbtn = QPushButton('Update sequence', self)
        updateseqbtn.clicked.connect(
            lambda state: self.changedSeqTable(seqtable))
        updateseqbtn.resize(updateseqbtn.minimumSizeHint())
        lay2.addWidget(seqtable)
        lay2.addWidget(updateseqbtn)
        win2.move(450, 30)
        win2.resize(win2.minimumSizeHint())

        # Update sequencing parameters: do this?
        changeseqbox = QCheckBox(self)
        changeseqbox.move(630, 10)
        changeseqbox.stateChanged.connect(lambda state: self.seqchangeWidget(
            changeseqbox, win2, seqtable, seqpts))
        changeseqboxlabel = QLabel(self)
        changeseqboxlabel.setText('Change sequencing options?')
        changeseqboxlabel.move(450, 10)
        changeseqboxlabel.resize(changeseqboxlabel.minimumSizeHint())

        # Build Sequence and take parameters
        win3 = QWidget(self)
        lay3 = QGridLayout(win3)
        buildseqlabel = QLabel(self)
        buildseqlabel.setText('Select a parameter to build the sequence:')
        buildseqlabel.resize(buildseqlabel.minimumSizeHint())
        buildseqbtn = QPushButton('Build sequence', self)
        buildseqbtn.clicked.connect(lambda state: self.buildSequenceWrap(
            chbox, offbox, contseqbox, timevoltbox, whichpulse, sparambox,
            seqstart, seqstop, seqpts))
        buildseqbtn.resize(buildseqbtn.minimumSizeHint())
        buildseqbtn.move(350, 100)

        # Native and special parameters
        timevoltbox = QComboBox(self)
        timevoltbox.addItem("Time")
        for i in range(number_channels):
            timevoltbox.addItem("Ch%{} Voltage".format(i))
        whichpulse = QLineEdit(self)
        whichpulse.setText('Which pulse?')
        whichpulse.resize(whichpulse.sizeHint())
        sparambox = QComboBox(self)
        sparambox.addItem("-Special-")
        for i in range(len(params)):
            sparambox.addItem(params[i])
        # Start/stop and build
        lay32 = QHBoxLayout()
        lay32.addStretch()
        startslabel = QLabel(self)
        startslabel.setText('Start:')
        stopslabel = QLabel(self)
        stopslabel.setText('Stop:')
        pointsslabel = QLabel(self)
        pointsslabel.setText('Points:')
        seqstart = QLineEdit(self)
        seqstart.setText('0')
        seqstart.resize(seqstart.minimumSizeHint())
        seqstop = QLineEdit(self)
        seqstop.setText('0')
        seqstop.resize(seqstop.minimumSizeHint())
        seqpts = QLineEdit(self)
        seqpts.setText('0')
        seqpts.resize(seqpts.minimumSizeHint())

        lay3.addWidget(buildseqlabel, 0, 0, 1, 3)
        lay3.addWidget(timevoltbox, 1, 0, 1, 1)
        lay3.addWidget(whichpulse, 1, 1, 1, 1)
        lay3.addWidget(sparambox, 1, 2, 1, 1)
        lay3.addWidget(startslabel, 2, 0, 1, 1)
        lay3.addWidget(stopslabel, 2, 1, 1, 1)
        lay3.addWidget(pointsslabel, 2, 2, 1, 1)
        lay3.addWidget(seqstart, 3, 0, 1, 1)
        lay3.addWidget(seqstop, 3, 1, 1, 1)
        lay3.addWidget(seqpts, 3, 2, 1, 1)
        lay3.addWidget(buildseqbtn, 4, 0, 1, 3)
        lay3.addWidget(uploadbtn, 5, 0, 1, 3)
        lay3.addWidget(Choose_awg, 6, 0, 1, 2)
        win3.move(10, 300)
        win3.resize(win3.minimumSizeHint())

        #Element and sequence saving and loading
        #Functions
        win1 = QWidget(self)
        lay1 = QGridLayout(win1)

        # load sequence
        whichSeq = QLineEdit(self)
        whichSeq.setText('enter file name')
        #whichSeq.setGeometry(110,60,70,20)
        loadsbtn = QPushButton('Load Sequence', self)
        loadsbtn.clicked.connect(
            lambda state: self.loadSequence(whichSeq.text()))
        # save sequence
        SeqTo = QLineEdit(self)
        SeqTo.setText('enter file name')
        #SeqTo.setGeometry(20,60,70,20)
        savesbtn = QPushButton('Save Sequence', self)
        savesbtn.clicked.connect(
            lambda state: self.gseq.write_to_json(SeqTo.text()))
        # plot sequence
        plotsbtn = QPushButton('Plot Sequence', self)
        plotsbtn.clicked.connect(lambda state: plotter(self.gseq))

        lay1.addWidget(savesbtn, 0, 0)
        lay1.addWidget(loadsbtn, 0, 1)
        lay1.addWidget(plotsbtn, 0, 2)
        lay1.addWidget(SeqTo, 1, 0)
        lay1.addWidget(whichSeq, 1, 1)
        win1.move(10, 0)
        win1.resize(win1.minimumSizeHint())

        #AWG Panel stuff
        # Create channel voltage, divider and offset boxes and buttons
        #Divider linked to base GUI!!
        win5 = QWidget(self)
        lay5 = QGridLayout(win5)
        awgframeh = QFrame(self)
        awgframeh.setFrameShape(QFrame.Shape(0x0004))
        #awgframeh2=QFrame(self);
        #awgframeh2.setFrameShape(QFrame.Shape(0x0004));
        awgframev = QFrame(self)
        awgframev.setFrameShape(QFrame.Shape(0x0005))
        lay5.addWidget(awgframeh, 0, 0, 1, 6)
        lay5.addWidget(awgframev, 0, 0, 7, 1)
        awglabel = QLabel(self)
        awglabel.setText('AWG Tools:')
        allonlabel = QLabel(self)
        allonlabel.setText('All on:')
        allonbox = QCheckBox(self)
        allonbox.stateChanged.connect(lambda state: self.runChan(
            allonbox, 0, str(Choose_awg.currentText())))
        achlabel1 = 'Ch1'
        achlabel2 = 'Ch2'
        achlabel3 = 'Ch3'
        achlabel4 = 'Ch4'
        achlabel = [achlabel1, achlabel2, achlabel3, achlabel4]
        for i in range(len(achlabel)):
            achlabel[i] = QLabel(self)
            achlabel[i].setText('Ch%d' % (i + 1))
        avpp = QLabel(self)
        avpp.setText('Vpp')
        aoffset = QLabel(self)
        aoffset.setText('Offset')
        aoutput = QLabel(self)
        aoutput.setText('Output')
        achbox1 = QLineEdit(self)
        achbox2 = QLineEdit(self)
        achbox3 = QLineEdit(self)
        achbox4 = QLineEdit(self)
        achbox = [achbox1, achbox2, achbox3, achbox4]
        aoffbox1 = QLineEdit(self)
        aoffbox2 = QLineEdit(self)
        aoffbox3 = QLineEdit(self)
        aoffbox4 = QLineEdit(self)
        aoffbox = [aoffbox1, aoffbox2, aoffbox3, aoffbox4]
        aoutbox1 = QCheckBox(self)
        aoutbox2 = QCheckBox(self)
        aoutbox3 = QCheckBox(self)
        aoutbox4 = QCheckBox(self)
        aoutbox = [aoutbox1, aoutbox2, aoutbox3, aoutbox4]
        aoutbox1.stateChanged.connect(lambda state: self.runChan(
            aoutbox1, 1, str(Choose_awg.currentText())))
        aoutbox2.stateChanged.connect(lambda state: self.runChan(
            aoutbox2, 2, str(Choose_awg.currentText())))
        aoutbox3.stateChanged.connect(lambda state: self.runChan(
            aoutbox3, 3, str(Choose_awg.currentText())))
        aoutbox4.stateChanged.connect(lambda state: self.runChan(
            aoutbox4, 4, str(Choose_awg.currentText())))
        runAWGtn = QPushButton('Run AWG', self)
        runAWGtn.clicked.connect(
            lambda state: self.runAWG(str(Choose_awg.currentText())))
        lay5.addWidget(awglabel, 1, 1, 1, 1)
        lay5.addWidget(runAWGtn, 1, 2, 1, 1)
        for i in range(len(achbox)):
            achbox[i].setText('4.5')
            aoffbox[i].setText('0')
            lay5.addWidget(achbox[i], i + 3, 2, 1, 1)
            lay5.addWidget(achlabel[i], i + 3, 1, 1, 1)
            lay5.addWidget(aoffbox[i], i + 3, 3, 1, 1)
            lay5.addWidget(aoutbox[i], i + 3, 4, 1, 1)
        lay5.addWidget(avpp, 2, 2, 1, 1)
        lay5.addWidget(aoffset, 2, 3, 1, 1)
        lay5.addWidget(aoutput, 2, 4, 1, 1)
        lay5.addWidget(allonlabel, 1, 3, 1, 1)
        lay5.addWidget(allonbox, 1, 4, 1, 1)
        win5.resize(win5.minimumSizeHint())
        win5.move(450, 270)

        #Filter Correction
        filtbtn = QPushButton('Filter correction', self)
        hfiltboxlabel = QLabel(self)
        hfiltboxlabel.setText('High pass (us):')
        hfiltboxlabel.resize(hfiltboxlabel.minimumSizeHint())
        hfiltboxlabel.move(20, 235)
        lfiltboxlabel = QLabel(self)
        lfiltboxlabel.setText('Low pass (us):')
        lfiltboxlabel.resize(lfiltboxlabel.minimumSizeHint())
        lfiltboxlabel.move(170, 235)
        hfiltbox = QLineEdit(self)
        hfiltbox.setText('80')
        hfiltbox.resize(hfiltbox.minimumSizeHint())
        hfiltbox.move(20, 250)
        lfiltbox = QLineEdit(self)
        lfiltbox.setText('-')
        lfiltbox.resize(lfiltbox.minimumSizeHint())
        lfiltbox.move(170, 250)
        filtbtn.clicked.connect(
            lambda state: self.filterCorrection(hfiltbox, lfiltbox))
        filtbtn.resize(filtbtn.minimumSizeHint())
        filtbtn.move(320, 250)

        self.show()
        win2.hide()
Example #4
0
seq.addElement(2, elem2)
seq.addElement(3, elem3)
seq.setSequencingNumberOfRepetitions(3, compression)
seq.setSR(SR)

# Now make the variation
seq2 = seq.copy()
seq2.element(2).changeArg(1, 'perturbation', 'start', 0.75)
seq2.element(2).changeArg(1, 'perturbation', 'stop', 0.75)
#
seq3 = seq.copy()
seq3.element(2).changeArg(1, 'perturbation', 'start', 0.5)
seq3.element(2).changeArg(1, 'perturbation', 'stop', 0.5)
#
fullseq = seq + seq2 + seq3
plotter(fullseq)
#-------------------------------------------------------
mainseq = bb.Sequence()
mainseq.setSR(SR)

mainseq.addSubSequence(1, seq)
mainseq.addSubSequence(2, seq2)
mainseq.addSubSequence(3, seq3)

mainseq.setSequencingNumberOfRepetitions(1, 25)
mainseq.setSequencingNumberOfRepetitions(2, 25)
mainseq.setSequencingNumberOfRepetitions(3, 25)

mainseq.setChannelAmplitude(
    1, 5)  # Call signature: channel, amplitude (peak-to-peak)
mainseq.setChannelOffset(1, 0)
 def plot_elem_nr(self,elem_nr):
     plotter(self.seq.element(elem_nr))
 def plot(self):
     plotter(self.seq)
    plotter = bb.plotter

import numpy as np
import matplotlib.pyplot as plt
import json

from pulseClass import DesignExperiment

file = 'pulse_jsons/rabi.json'

with open(file, 'r') as read_file:
    master = json.load(read_file)

experiment = DesignExperiment(gain=1.0)
base = experiment.build_base_from_json(master)
plotter(base)
plt.show()

detunings = np.linspace(0, 30.0e-3, 5)
durations = np.linspace(10.0e-9, 200e-9, 1)
detuning_vector = [1.0, 1.0]
lever_arms = [0.454, 0.854]  # meV/V for LB (ch 2 - dac 11), RB (ch 1 - dac 7)
'''
sequence = experiment.add_dc_correction()
'''

sequence = experiment.vary_base_sequence('rabi',
                                         detuning_vector,
                                         detunings,
                                         durations,
                                         lever_arms,
Example #8
0
    def setup_awg(self,
                  program_awg=True,
                  start_awg=True,
                  stop_awg=True,
                  plot=False,
                  **kw):
        if stop_awg:
            self.awg.stop()

        if program_awg:

            seq = self.sequence(**kw)
            seq.setSR(self.SR)

            for ch_no, ch_set in self.chan_settings.items():
                seq.setChannelAmplitude(ch_no, ch_set['Vpp'])
                seq.setChannelOffset(ch_no, ch_set['offset'])

            if self.wait == 'first':
                seq.setSequencingTriggerWait(1, 1)
            elif self.wait == 'off':
                seq.setSequencingTriggerWait(1, 0)
            elif self.wait == 'all':
                for i in range(1, seq.length_sequenceelements + 1):
                    seq.setSequencingTriggerWait(i, 1)
            elif self.wait == None:
                pass
            else:
                raise ValueError("Unknown sweep_wait setting '{}".format(
                    self.wait))

            if self.repeat_mode == 'sequence':
                seq.setSequencingGoto(seq.length_sequenceelements, 1)
            elif self.repeat_mode == None:
                pass
            else:
                raise ValueError("Unknown sweep_repeat setting '{}".format(
                    self.repeat_mode))

            # plot if required
            if plot:
                plotter(seq)

            if isinstance(self.awg, AWG5014):
                pkg = seq.outputForAWGFile()
                self.awg.make_send_and_load_awg_file(*pkg[:])

                for ch_no, ch_lst in self.chan_map.items():
                    self.awg.set('ch{}_state'.format(ch_no), 1)

                for ch_no, ch_set in self.chan_settings.items():
                    self.awg.set('ch{}_amp'.format(ch_no), ch_set['Vpp'])
                    self.awg.set('ch{}_offset'.format(ch_no), ch_set['offset'])
                    for m, val in enumerate(ch_set['marker_hi']):
                        self.awg.set('ch{}_m{}_high'.format(ch_no, m + 1), val)
                    for m, val in enumerate(ch_set['marker_lo']):
                        self.awg.set('ch{}_m{}_low'.format(ch_no, m + 1), val)

                self.awg.clock_freq(self.SR)

            elif isinstance(self.awg, AWG5208):
                # forge the sequence
                forged_sequence = seq.forge()

                # create a sequence file
                seqx_file = self.awg.make_SEQX_from_forged_sequence(
                    forged_sequence, [1 for i in self.chan_map.keys()],
                    seq.name)
                seqx_file_name = f'{seq.name}.seqx'

                # clear lists of sequences and waveforms on the instrument in order
                # to prevent cluttering
                self.awg.clearSequenceList()
                self.awg.clearWaveformList()

                # send the sequence file to the instrument and load it
                self.awg.sendSEQXFile(seqx_file, filename=seqx_file_name)
                self.awg.loadSEQXFile(seqx_file_name)

                self.awg.sample_rate(self.SR)

                # load seqs to channels
                for ch_no, ch_desc in self.chan_map.items():
                    chan = self.awg.channels[ch_no - 1]

                    track_number = ch_no
                    chan.setSequenceTrack(seq.name, track_number)

                    chan.resolution(12)
                    chan.set('state', 1)

                for ch_no, ch_set in self.chan_settings.items():
                    self.awg.channels[ch_no - 1].set('awg_amplitude',
                                                     ch_set['Vpp'])
                    for i in range(1, len(ch_set['marker_hi']) + 1):
                        self.awg.channels[ch_no - 1].set(
                            'marker{}_high'.format(i),
                            ch_set['marker_hi'][i - 1])
                        self.awg.channels[ch_no - 1].set(
                            'marker{}_low'.format(i),
                            ch_set['marker_lo'][i - 1])

        if start_awg:
            if isinstance(self.awg, AWG5014):
                self.awg.start()
            elif isinstance(self.awg, AWG5208):
                self.awg.play()