Example #1
0
def test_equality_false(blueprint_tophat):
    elem1 = bb.Element()
    elem2 = bb.Element()
    elem1.addBluePrint(1, blueprint_tophat)
    elem2.addBluePrint(1, blueprint_tophat)
    elem1.changeArg(1, 'ramp', 'start', 2)
    assert elem1 != elem2
Example #2
0
def test_points(SR, N):
    elem = bb.Element()

    with pytest.raises(KeyError):
        elem.points

    bp = bb.BluePrint()

    bp.insertSegment(0, ramp, (0, 0), dur=N / SR)
    bp.setSR(SR)

    wfm = np.linspace(-1, 1, N)
    elem.addArray(1, wfm, SR)
    elem.addBluePrint(2, bp)

    assert elem.points == N

    elem = bb.Element()
    bp = bb.BluePrint()

    bp.insertSegment(0, ramp, (0, 0), dur=N / SR)
    bp.setSR(SR)

    wfm = np.linspace(-1, 1, N)
    elem.addArray(2, wfm, SR)
    elem.addBluePrint(1, bp)

    assert elem.points == N
Example #3
0
    def sequence(self):
        seq = bb.Sequence()
        seq.name = 'SSB'

        net_time = self.seq_len() - self.pre_delay() - self.post_delay()

        for i, f in enumerate(self.ssb_frequency()):
            elem = bb.Element()
            bps = BluePrints(self.chan_map, sample_rate=self.sample_rate())

            bps['src_I'].insertSegment(0, ramp, (0, 0), dur=self.pre_delay())
            bps['src_I'].insertSegment(1,
                                       sine, (f, self.ssb_amp(), 0, 0),
                                       dur=net_time)
            bps['src_I'].insertSegment(2, ramp, (0, 0), dur=self.post_delay())

            bps['src_Q'].insertSegment(0, ramp, (0, 0), dur=self.pre_delay())
            bps['src_Q'].insertSegment(1,
                                       sine,
                                       (f, self.ssb_amp(), 0, -np.pi / 2),
                                       dur=net_time)
            bps['src_Q'].insertSegment(2, ramp, (0, 0), dur=self.post_delay())

            bps['ro_trigger'] = [(self.pre_delay(), self.trigger_len())]
            bps['ro_gate'] = [(self.pre_delay(), net_time)]
            bps['src_gate'] = [(self.pre_delay(), net_time)]

            for n, bp in bps():
                elem.addBluePrint(n, bp)

            seq.addElement(i + 1, elem)

        return seq
Example #4
0
def test_addArray():

    SR = 1e9
    N = 2500

    wfm = np.linspace(0, N / SR, N)
    m1 = np.zeros(N)
    m2 = np.ones(N)

    elem = bb.Element()
    elem.addArray(1, wfm, SR, m1=m1, m2=m2)
    elem.addArray('2', wfm, SR, m1=m1)
    elem.addArray('readout_channel', wfm, SR, m2=m2)

    elem.validateDurations()

    M = 2400
    wfm2 = np.linspace(0, M / SR, M)
    elem.addArray(3, wfm2, SR)

    with pytest.raises(ElementDurationError):
        elem.validateDurations()

    with pytest.raises(ValueError):
        elem.addArray(1, wfm, SR, m1=m1[:-1])

    with pytest.raises(ValueError):
        elem.addArray(2, wfm, SR, m2=m2[3:])
def elem_from_lists(step_list_a: list, step_list_b: list, ramplist: list,
                    duration: float = 1e-6, dac_a: float = 0, dac_b: float = 0,
                    divider_a: float = 1.0, divider_b: float = 1.0,
                    SR: float = 1e9,
                    chx: int = 1, chy: int = 2) -> bb.Element:
    #Make element from pulse table
    elem = bb.Element()
    blueprint_a = bb.BluePrint()
    blueprint_a.setSR(SR)
    blueprint_b = bb.BluePrint()
    blueprint_b.setSR(SR)
    step_a_old = 0
    step_b_old = 0
    for i in range(len(step_list_a)):
        if ramplist[i] == 1:
            step_a = (step_list_a[i]-dac_a)*divider_a
            step_b = (step_list_b[i]-dac_b)*divider_b
            blueprint_a.insertSegment(i, ramp, (step_a_old, step_a), name=ascii_lowercase[i], dur=duration)
            blueprint_b.insertSegment(i, ramp, (step_b_old, step_b), name=ascii_lowercase[i], dur=duration)
        else:
            step_a = (step_list_a[i]-dac_a)*divider_a
            step_b = (step_list_b[i]-dac_b)*divider_b
            blueprint_a.insertSegment(i, ramp, (step_a, step_a), name=ascii_lowercase[i], dur=duration)
            blueprint_b.insertSegment(i, ramp, (step_b, step_b), name=ascii_lowercase[i], dur=duration)
        step_a_old = step_a
        step_b_old = step_b

    elem.addBluePrint(chx, blueprint_a)
    elem.addBluePrint(chy, blueprint_b)
    elem.validateDurations()
    return elem
    def MultiQ_Lifetime_overlap(self, start:float, stop:float, npts:int) -> None:
        """ 
        Updates the broadbean sequence so it contains one channels containing a pi-pulse
        varying the time between the end of the pi-pulse and the readout
        and two channels for the readout for IQ mixing 
        
            args:
            start (float): Starting point of the delta time
            stop (float): Endpoint point of the delta time
            npts (int): Number of point in the time interval
        """
        
        self.seq.empty_sequence()
        readout_freq = self.readout_freq_1.get()
        pulse_to_readout_time = np.linspace(start,stop,npts)
        readout_freq = self.readout_freq_1.get() #- self.cavity.frequency()
        for i,delta_time in enumerate(pulse_to_readout_time):
            self.elem = bb.Element()
            seg_pi = self.seg_pi(delta_time)
            self.elem.addBluePrint(1, seg_pi)
            self.elem_add_readout_pulse(readout_freq)
            self.seq.seq.addElement(i+1,self.elem)

            self.seq_settings_infinity_loop(i+1,npts)
        self.seq.seq.setSR(self.SR.get())
      
        self.seq.set_all_channel_amplitude_offset(amplitude=1, offset=0)
    def MultiQ_SSB_Spec_NoOverlap(self, start:float, stop:float, npts:int) -> None:
        """ 
        Updates the broadbean sequence so it contains two channels with orthogonal sine/cosine pulses for an array of  frequencies
        and two channels for the readout for IQ mixing 

            args:
            start (float): Starting point of the frequency interval
            stop (float): Endpoint point of the frequency interval
            npts (int): Number of point in the frequency interval
        """
        self.seq.empty_sequence()
        freq_interval = np.linspace(start,stop,npts)
        readout_freq = self.readout_freq_1.get() #- self.cavity.frequency()

        for i,f in enumerate(freq_interval):
            self.elem = bb.Element()
            if i == 0:
                seg_sin = self.seg_sine(frequency = f,marker=True)
            else:
                seg_sin = self.seg_sine(frequency = f, marker=False)
            seg_cos = self.seg_sine(frequency = f, phase=np.pi/2)
            self.elem.addBluePrint(1, seg_sin)
            self.elem.addBluePrint(2, seg_cos)
            self.elem_add_readout_pulse(readout_freq)
            self.seq.seq.addElement(i+1, self.elem)
            self.seq_settings_infinity_loop(i+1,npts)
        self.seq.seq.setSR(self.SR.get())

        self.seq.set_all_channel_amplitude_offset(amplitude=1, offset=0)
Example #8
0
def blueprints2element(bps):
    """
    Create a bb element from a BluePrints object.
    """
    e = bb.Element()
    for n, bp in bps():
        e.addBluePrint(n, bp)
    return e
Example #9
0
def subseq1():
    """
    A small sequence meant to be used as a subsequence
    """

    longdur = 201e-9

    wait = bb.BluePrint()
    wait.insertSegment(0, ramp, args=(0, 0), dur=10e-9)
    wait.setSR(SR1)

    wiggle = bb.BluePrint()
    wiggle.insertSegment(0, sine, args=(10e6, 10e-3, 0, 0), dur=longdur)
    wiggle.setSR(SR1)

    blob = bb.BluePrint()
    blob.insertSegment(0, gauss, args=(25e-3, 12e-9, 0, 0), dur=longdur)
    blob.setSR(SR1)

    slope = bb.BluePrint()
    slope.insertSegment(0, ramp, (0, 15e-3), dur=longdur)
    slope.setSR(SR1)

    elem1 = bb.Element()
    elem1.addBluePrint(1, wait)
    elem1.addBluePrint(2, wait)
    elem1.addBluePrint(3, wait)

    elem2 = bb.Element()
    elem2.addBluePrint(1, wiggle)
    elem2.addBluePrint(2, slope)
    elem2.addBluePrint(3, blob)

    elem3 = elem1.copy()

    seq = Sequence()
    seq.setSR(SR1)
    seq.addElement(1, elem1)
    seq.addElement(2, elem2)
    seq.addElement(3, elem3)
    seq.setSequencingNumberOfRepetitions(1, 10)
    seq.setSequencingNumberOfRepetitions(3, 10)

    return seq
def protosequence1():

    SR = 1e9

    th = bb.BluePrint()
    th.insertSegment(0, ramp, args=(0, 0), name='ramp', dur=10e-6)
    th.insertSegment(1, ramp, args=(1, 1), name='ramp', dur=5e-6)
    th.insertSegment(2, ramp, args=(0, 0), name='ramp', dur=10e-6)
    th.setSR(SR)

    wiggle1 = bb.BluePrint()
    wiggle1.insertSegment(0, sine, args=(4e6, 0.5, 0, 0), dur=25e-6)
    wiggle1.setSR(SR)

    wiggle2 = bb.BluePrint()
    wiggle2.insertSegment(0, sine, args=(8e6, 0.5, 0, 0), dur=25e-6)
    wiggle2.setSR(SR)

    elem1 = bb.Element()
    elem1.addBluePrint(1, th)
    elem1.addBluePrint(2, wiggle1)

    elem2 = bb.Element()
    elem2.addBluePrint(1, th)
    elem2.addBluePrint(2, wiggle2)

    seq = bb.Sequence()
    seq.addElement(1, elem1)
    seq.addElement(2, elem2)
    seq.setSR(SR)
    seq.name = 'protoSequence'

    seq.setChannelAmplitude(1, 2)
    seq.setChannelAmplitude(2, 2)
    seq.setChannelOffset(1, 0)
    seq.setChannelOffset(2, 0)
    seq.setSequencingTriggerWait(1, 1)
    seq.setSequencingTriggerWait(2, 1)
    seq.setSequencingEventJumpTarget(1, 1)
    seq.setSequencingEventJumpTarget(2, 1)
    seq.setSequencingGoto(1, 1)
    seq.setSequencingGoto(2, 1)

    return seq
Example #11
0
def test_invalid_durations(SR1, SR2, N, M):
    """
    There are soooo many ways to have invalid durations, here
    we hit a couple of them
    """

    # differing sample rates

    elem = bb.Element()
    bp = bb.BluePrint()

    bp.insertSegment(0, ramp, (0, 0), dur=N / SR2)
    bp.setSR(SR2)

    wfm = np.linspace(-1, 1, N)
    elem.addArray(1, wfm, SR1)
    elem.addBluePrint(2, bp)

    if SR1 == SR2:
        elem.validateDurations()
    else:
        with pytest.raises(ElementDurationError):
            elem.validateDurations()

    # differing durations
    bp1 = bb.BluePrint()
    bp1.insertSegment(0, ramp, (0, 1), dur=N / SR1)
    bp1.setSR(SR1)

    bp2 = bb.BluePrint()
    bp2.insertSegment(0, ramp, (0, 2), dur=M / SR1)
    bp2.setSR(SR1)

    elem = bb.Element()
    elem.addBluePrint(1, bp1)
    elem.addBluePrint(2, bp2)

    if N == M:
        elem.validateDurations()
    else:
        with pytest.raises(ElementDurationError):
            elem.validateDurations()
Example #12
0
def protosequence2():

    SR = 1e9

    saw = bb.BluePrint()
    saw.insertSegment(0, ramp, args=(0, 100e-3), dur=11e-6)
    saw.insertSegment(1, 'waituntil', args=(25e-6))
    saw.setSR(SR)

    lineandwiggle = bb.BluePrint()
    lineandwiggle.insertSegment(0, 'waituntil', args=(11e-6))
    lineandwiggle.insertSegment(1, sine, args=(10e6, 50e-6, 10e-6), dur=14e-6)
    lineandwiggle.setSR(SR)

    elem1 = bb.Element()
    elem1.addBluePrint(1, saw)
    elem1.addBluePrint(2, lineandwiggle)

    elem2 = bb.Element()
    elem2.addBluePrint(2, saw)
    elem2.addBluePrint(1, lineandwiggle)

    seq = bb.Sequence()
    seq.setSR(SR)
    seq.addElement(1, elem1)
    seq.addElement(2, elem2)

    seq.setChannelAmplitude(1, 1.5)
    seq.setChannelOffset(1, 0)
    seq.setChannelAmplitude(2, 1)
    seq.setChannelOffset(2, 0)
    seq.setSequencingTriggerWait(1, 0)
    seq.setSequencingTriggerWait(2, 1)
    seq.setSequencingNumberOfRepetitions(1, 2)
    seq.setSequencingEventJumpTarget(1, 0)
    seq.setSequencingEventJumpTarget(2, 0)
    seq.setSequencingGoto(1, 2)
    seq.setSequencingGoto(2, 1)

    return seq
Example #13
0
def badseq_missing_pos():

    SR = 1e9

    saw = bb.BluePrint()
    saw.insertSegment(0, ramp, args=(0, 100e-3), dur=11e-6)
    saw.insertSegment(1, 'waituntil', args=(25e-6))
    saw.setSR(SR)

    lineandwiggle = bb.BluePrint()
    lineandwiggle.insertSegment(0, 'waituntil', args=(11e-6))
    lineandwiggle.insertSegment(1, sine, args=(10e6, 50e-6, 10e-6), dur=14e-6)
    lineandwiggle.setSR(SR)

    elem1 = bb.Element()
    elem1.addBluePrint(1, saw)
    elem1.addBluePrint(2, lineandwiggle)

    elem2 = bb.Element()
    elem2.addBluePrint(2, saw)
    elem2.addBluePrint(1, lineandwiggle)

    seq = bb.Sequence()
    seq.setSR(SR)
    seq.addElement(1, elem1)
    seq.addElement(3, elem2)  # <--- A gap in the sequence

    seq.setChannelAmplitude(1, 1.5)
    seq.setChannelOffset(1, 0)
    seq.setChannelAmplitude(2, 1)
    seq.setChannelOffset(2, 0)
    seq.setSequencingTriggerWait(3, 1)
    seq.setSequencingNumberOfRepetitions(1, 2)
    seq.setSequencingGoto(1, 2)
    seq.setSequencingGoto(3, 1)
    # seq.setSequenceSettings(1, 0, 2, 0, 2)
    # seq.setSequenceSettings(2, 1, 1, 0, 1)

    return seq
Example #14
0
 def __init__(self, AWG=None, gelem=None, libpath='pulselib/'):
     self.gelem = bb.Element()
     self.table = QTableWidgetDF()
     self.awgclock = 1.2e9
     self.libpath = join(pathlib.Path(__file__).parents[0], libpath)
     self.seq_files = [
         f for f in listdir(self.libpath) if isfile(join(self.libpath, f))
     ]
     self.corrDflag = 0
     self.w = None
     self.ch_x = None
     self.ch_y = None
     self.ramp = None
Example #15
0
def squarepulse_baseelem():

    SR = 1e6

    basebp = bb.BluePrint()
    basebp.insertSegment(0, ramp, (0, 0), dur=0.5e-4)
    basebp.insertSegment(1, ramp, (1, 1), dur=1e-4, name='varyme')
    basebp.insertSegment(2, 'waituntil', 5e-4)
    basebp.setSR(SR)

    baseelem = bb.Element()
    baseelem.addBluePrint(1, basebp)

    return baseelem
Example #16
0
def noise_element():
    """
    An element consisting of arrays of noise
    """

    noise1 = np.random.randn(250)
    noise2 = np.random.randn(250)
    noise3 = np.random.randn(250)

    elem = bb.Element()
    elem.addArray(1, noise1, SR=SR1)
    elem.addArray(2, noise2, SR=SR1)
    elem.addArray(3, noise3, SR=SR1)

    return elem
Example #17
0
def mixed_element(blueprint_tophat):
    """
    An element with blueprints and arrays
    """

    noise = np.random.randn(blueprint_tophat.points)
    wiggle = bb.BluePrint()
    wiggle.insertSegment(0, sine, args=(1, 10, 0, 0), dur=2.5)
    wiggle.setSR(blueprint_tophat.SR)

    elem = bb.Element()
    elem.addBluePrint(1, blueprint_tophat)
    elem.addArray(2, noise, blueprint_tophat.SR)
    elem.addBluePrint(3, wiggle)

    return elem
Example #18
0
    def make_seq(seqlen, channels, SR):

        seq = Sequence()
        seq.setSR(SR)

        for pos in range(1, seqlen + 1):

            elem = bb.Element()

            for chan in channels:
                bp = bb.BluePrint()
                bp.insertSegment(-1, ramp, (0, 0), dur=20 / SR)
                bp.insertSegment(-1, ramp, (1, 1), dur=10 / SR)
                bp.insertSegment(-1, ramp, (0, 0), dur=5 / SR)
                bp.setSR(SR)
                elem.addBluePrint(chan, bp)

            seq.addElement(pos, elem)

        return seq
Example #19
0
def bp_element():

    dur = 100e-9

    bp1 = bb.BluePrint()
    bp1.insertSegment(0, sine, (1e6, 10e-3, 0, 0), dur=dur)

    bp2 = bb.BluePrint()
    bp2.insertSegment(0, sine, (2e6, 10e-3, 0, np.pi / 2), dur=dur)

    bp3 = bb.BluePrint()
    bp3.insertSegment(0, sine, (3e6, 10e-3, 0, -1), dur=dur)

    for bp in [bp1, bp2, bp3]:
        bp.setSR(SR1)

    elem = bb.Element()
    for ch, bp in enumerate([bp1, bp2, bp3]):
        elem.addBluePrint(ch + 1, bp)

    return elem
Example #20
0
    def sequence(self):
        elem = bb.Element()

        bps = BluePrints(self.chan_map,
                         sample_rate=self.sample_rate(),
                         length=self.seq_len())
        bps['ro_trigger'] = [(self.pre_trigger_delay(), self.trigger_len())]

        try:
            bps['ro_gate'] = [
                (self.pre_trigger_delay() + self.post_trigger_delay(),
                 self.readout_gate_len())
            ]
        except KeyError:
            logger.warning(
                'No ro_gate defined in channel map. No readout gate pulse will be generated.'
            )

        try:
            bps['src_gate'] = [
                (self.pre_trigger_delay() + self.post_trigger_delay(),
                 self.readout_gate_len())
            ]
        except KeyError:
            logger.warning(
                'No src_gate defined in channel map. No src gate pulse will be generated.'
            )

        for n, bp in bps():
            elem.addBluePrint(n, bp)

        seq = bb.Sequence()
        seq.name = 'trig'
        seq.addElement(1, elem)

        seq.setSequencingTriggerWait(1, 0)
        seq.setSequencingGoto(1, 1)

        return seq
    def test_station(self, start:float, stop:float, npts:int,channel: int) -> None:
        """ 
        Updates the broadbean sequence so it containsone channel with a sine pulse for an array of  frequencies

            args:
            start (float): Starting point of the frequency interval
            stop (float): Endpoint point of the frequency interval
            npts (int): Number of point in the frequency interval
            channel (int): The Channel of the seq/AWG
        """
        self.seq.empty_sequence()
        freq_interval = np.linspace(start,stop,npts)

        for i,f in enumerate(freq_interval):
            elem = bb.Element()
            seg_sin = self.seg_sine(frequency = f)
            elem.addBluePrint(channel, seg_sin)
            self.seq.seq.addElement(i+1, elem)
            self.seq_settings_infinity_loop(i+1,npts)
        self.seq.seq.setSR(self.SR.get())

        self.seq.set_all_channel_amplitude_offset(amplitude=1, offset=0)
Example #22
0
 def generateElement(self):
     # Make element from pulse table
     self.gelem = bb.Element()
     h = int((self.table.columnCount() - 2) / 3)
     prevlvl = 0
     v = self.table.rowCount()
     for col in range(2, h + 2):
         chno = int(self.table.horizontalHeaderItem(col).text()[2])
         gp = bb.BluePrint()
         gp.setSR(self.awgclock)
         for row in range(v):
             nm = self.table.verticalHeaderItem(row).text()
             dr = (float(self.table.item(row, 0).text())) * 1e-6
             rmp = int(self.table.item(row, 1).text())
             lvl = (float(self.table.item(
                 row, col).text())) * self.divider_ch[col - 2] * 1e-3
             mkr1 = int(self.table.item(row, h + 2).text())
             mkr2 = int(self.table.item(row, h + 3).text())
             if rmp == 0:
                 gp.insertSegment(row, ramp, (lvl, lvl), name=nm, dur=dr)
             if rmp == 1:
                 if row == 0:
                     gp.insertSegment(row, ramp, (0, lvl), name=nm, dur=dr)
                 else:
                     gp.insertSegment(row,
                                      ramp, (prevlvl, lvl),
                                      name=nm,
                                      dur=dr)
             if mkr1 == 1:
                 gp.setSegmentMarker(nm, (0, dr), 1)
             if mkr2 == 1:
                 gp.setSegmentMarker(nm, (0, dr), 2)
             prevlvl = lvl
         self.gelem.addBluePrint(chno, gp)
         h = h + 2
     self.gelem.validateDurations()
Example #23
0
from pathlib import Path
import pathlib
from PyQt5.QtCore import QCoreApplication, Qt
from PyQt5.QtWidgets import QFileDialog
from PyQt5.QtWidgets import QApplication, QWidget, QFrame, QMainWindow, QPushButton, QAction, QMessageBox, QLineEdit, QLabel, QSizePolicy
from PyQt5.QtWidgets import QCheckBox, QDialog, QTableWidget, QTableWidgetItem, QVBoxLayout, QHBoxLayout, QComboBox, QGridLayout
from broadbean.plotting import plotter
from pulsequantum.dftable import QTableWidgetDF
from pulsequantum.annotateshape import annotateshape
from pulsequantum.elem_from_plot import elem_on_plot
from pulsequantum.elem_from_plot import elem_from_lists

nchans = 2

ramp = bb.PulseAtoms.ramp  # Globally defined ramp, element, and sequence
gelem = bb.Element()
gseq = bb.Sequence()


class Gelem():
    def __init__(self, AWG=None, gelem=None, libpath='pulselib/'):
        self.gelem = bb.Element()
        self.table = QTableWidgetDF()
        self.awgclock = 1.2e9
        self.libpath = join(pathlib.Path(__file__).parents[0], libpath)
        self.seq_files = [
            f for f in listdir(self.libpath) if isfile(join(self.libpath, f))
        ]
        self.corrDflag = 0
        self.w = None
        self.ch_x = None
 def build_elem_from_bp(self, bps):
     elem = bb.Element()
     for index_ch, ch in enumerate(bps):
         elem.addBluePrint(index_ch+1, ch)
     elem.validateDurations()
     return elem
Example #25
0
    plotter = bb.plotter

sine = bb.PulseAtoms.sine
ramp = bb.PulseAtoms.ramp

SR = 1e9
t1 = 200e-6  # wait
t2 = 20e-9  # perturb the system
t3 = 250e-6  # read out

compression = 100  # this number has to be chosen with some care

bp1 = bb.BluePrint()
bp1.insertSegment(0, ramp, (0, 0), dur=t1 / compression)
bp1.setSR(SR)
elem1 = bb.Element()
elem1.addBluePrint(1, bp1)
#
bp2 = bb.BluePrint()
bp2.insertSegment(0, ramp, (1, 1), dur=t2, name='perturbation')
bp2.setSR(SR)
elem2 = bb.Element()
elem2.addBluePrint(1, bp2)
#
bp3 = bb.BluePrint()
bp3.insertSegment(0, ramp, (0, 0), dur=t3 / compression, name='marker')
bp3.setSegmentMarker('marker', (0.0, 1e-6), 1)
bp3.setSR(SR)
elem3 = bb.Element()
elem3.addBluePrint(1, bp3)
Example #26
0
def makeT2Sequence(hightimes, trig_delay, RF_delay, meastime, cycletime,
                   pulsehigh, pulselow, no_of_avgs, SR):
    """
    Generate the pulse sequence for the experiment.
    The sequence consists of three parts:
    1: A wait with zeros allowing the ZI to get ready. This part is
    short, but repeated waitbits times
    2: A short zero part with the marker2 trigger for the ramp
    3: The high pulse and a marker1 trigger for the ZI
    Args:
        hightimes (iterables): The widths of the pulse (s)
        trig_delay (float): The delay to start measuring after the end of the
            pulse (s).
        meastime (float): The time of each measurement (s).
        cycletime (float): The time of each pulse-measure cycle (s).
        pulsehigh (float): The amplitude of the pulse (V)
        pulselow (float): The amplitude during the measurement (V)
        no_of_avgs (int): The number of averages
        SR (int): The AWG sample rate (Sa/s)
    """

    segname = 'high'

    # Fail if the sequence would end up being too long for the AWG to handle
    if len(hightimes) * cycletime * SR >= 16e6:
        raise ValueError("Sequence too long. You are trying to build a "
                         "sequence with {:d} MSamples. The maximally allowed "
                         "number of samples is "
                         "16 MSamples.".format(
                             int(len(hightimes) * cycletime * SR / 1e6)))

    ##################################################################
    # The pulsed part

    bp1 = bb.BluePrint()
    bp1.setSR(SR)
    bp1.insertSegment(0,
                      ramp, (pulsehigh, pulsehigh),
                      durs=hightimes[0],
                      name=segname)
    bp1.insertSegment(1,
                      ramp, (pulselow, pulselow),
                      durs=meastime,
                      name='measure')
    # dead time for the scope to re-arm its trigger
    bp1.insertSegment(2, 'waituntil', cycletime)

    bp1.setSegmentMarker(segname, (RF_delay, meastime),
                         1)  # segment name, (delay, duration), markerID
    bp1.setSegmentMarker(segname, (trig_delay, meastime), 2)

    pulseelem = bb.Element()
    pulseelem.addBluePrint(1, bp1)

    seq = bb.Sequence()
    seq.setSR(SR)

    for index, ht in enumerate(hightimes):

        elem = pulseelem.copy()
        elem.changeDuration(1, segname, ht)
        seq.addElement(index + 1, elem)
        seq.setSequenceSettings(index + 1, 0, no_of_avgs, 0, 0)

    return seq
Example #27
0
def test_copy(blueprint_tophat):
    elem1 = bb.Element()
    elem1.addBluePrint(1, blueprint_tophat)
    elem2 = elem1.copy()
    assert elem1 == elem2
Example #28
0
def test_equality_true(blueprint_tophat):
    elem1 = bb.Element()
    elem2 = bb.Element()
    elem1.addBluePrint(1, blueprint_tophat)
    elem2.addBluePrint(1, blueprint_tophat)
    assert elem1 == elem2
Example #29
0
def test_bare_init(blueprint_tophat):
    elem = bb.Element()
    elem.addBluePrint(1, blueprint_tophat)
    assert list(elem._data.keys()) == [1]
Example #30
0
def test_input_fail1(improper_bp):
    elem = bb.Element()
    with pytest.raises(ValueError):
        elem.addBluePrint(1, improper_bp)