示例#1
0
def check_correlations(aliceTtags, aliceChannels, bobTtags, bobChannels,
                       resolution, A_B_timetags, A_B_channels, channels1,
                       channels2, delays, coincidence_window_radius):

    for delay, ch1, ch2 in zip(delays, channels1, channels2):
        if delay < 0:
            A_B_timetags[A_B_channels == ch2] += (abs(delay)).astype(uint64)
        else:
            A_B_timetags[A_B_channels == ch1] += delay.astype(uint64)

    indexes_of_order = A_B_timetags.argsort(kind="mergesort")
    A_B_channels = take(A_B_channels, indexes_of_order)
    A_B_timetags = take(A_B_timetags, indexes_of_order)

    buf_num = ttag.getfreebuffer()
    buffer = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e7))
    buffer.resolution = 260e-12
    buffer.channels = max(A_B_channels) + 1
    buffer.addarray(A_B_channels, A_B_timetags)

    buf_num = ttag.getfreebuffer()
    bufDelays = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e7))
    bufDelays.resolution = resolution
    bufDelays.channels = max(A_B_channels) + 1
    bufDelays.addarray(A_B_channels, A_B_timetags.astype(uint64))

    with_delays = (bufDelays.coincidences(
        (A_B_timetags[-1] - 1) * bufDelays.resolution,
        coincidence_window_radius))
    remade = remake_coincidence_matrix(with_delays)

    print "__COINCIDENCES WITH DELAYS ->>\n", remade.astype(uint64)
示例#2
0
def startTagger():
    global buf
    ttnumber = ttag.getfreebuffer() - 1
    print "ttnumber: ", ttnumber
    buf = ttag.TTBuffer(ttnumber)  #Opens the buffer
    #  Timetag time units are float
    buf.start()
    return buf
示例#3
0
def openttag(toFile=None):
    fromFile = '/mnt/odrive/HPD/ShanePyStuff/scripts/UQDttagger2/ttag/UQD/src/uqd.uqcfg'
    ttnumber = ttag.getfreebuffer() - 1
    print "ttnumber: ", ttnumber
    buf = ttag.TTBuffer(ttnumber)  #Opens the buffer
    buf.tagsAsTime = False
    #buf.start()
    if toFile != None:
        shutil.copyfile(fromFile, toFile)
    return buf
示例#4
0
    def Start(self):
        if not self.connected:
            print('Connect the rotator before starting acquisition')
            return

        self.btnConnect.setEnabled(False)
        if not self.inAcq:
            self.inAcq = True

            self.txtBufferNo.setEnabled(False)
            self.btnStart.setStyleSheet('background-color: red')
            self.btnStart.setText('Stop')

            self.getParameters()

            self.runStart += 1
            if self.runStart > 1:
                return
            self.UpdateLabels()
            print('Acquisition started')
            self.ttagBuf = ttag.TTBuffer(self.bufNum)
            self.btnSaveData.setEnabled(True)
            self.Ncounts = []
            for angle in np.arange(self.iniAngle, self.finAngle,
                                   self.stepAngle):
                QtGui.qApp.processEvents()
                if not self.inAcq:
                    break
                self.ttagBuf.start()
                time.sleep(self.integrationTime / .9)
                self.ttagBuf.stop()
                time.sleep(.1)
                self.Ncounts.append(self.ttagBuf.singles(self.integrationTime))

                self.con.goto(angle, wait=True)  ## Move plate to angle=angle

                time.sleep(timeAfterPlateMove)
                self.UpdateView()

            self.runStart = 0
            self.btnConnect.setEnabled(True)
            print('Acquisition stopped')

        self.inAcq = False
        self.txtBufferNo.setEnabled(True)
        self.btnStart.setStyleSheet('')
        self.btnStart.setText('Start')
示例#5
0
def calculate_delays(aliceTtags,
                     aliceChannels,
                     bobTtags,
                     bobChannels,
                     resolution=260e-12,
                     coincidence_window_radius=200 - 12,
                     delay_max=1e-6):

    channels1 = [0, 1, 2, 3]
    channels2 = [4, 5, 6, 7]

    A_B_timetags = concatenate([aliceTtags, bobTtags])
    A_B_channels = concatenate([aliceChannels, bobChannels])

    indexes_of_order = A_B_timetags.argsort(kind="mergesort")
    A_B_channels = take(A_B_channels, indexes_of_order)
    A_B_timetags = take(A_B_timetags, indexes_of_order)

    buf_num = ttag.getfreebuffer()
    bufN = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e11))
    bufN.resolution = resolution
    bufN.channels = max(A_B_channels) + 1
    bufN.addarray(A_B_channels, A_B_timetags)

    coincidences_before = (bufN.coincidences(
        (A_B_timetags[-1] - 1) * bufN.resolution, coincidence_window_radius))
    remade = remake_coincidence_matrix(coincidences_before)
    print "__COINCIDENCES BEFORE-->>\n", remade.astype(uint64)

    channel_number = int(max(append(channels1, channels2)))
    delays = zeros(channel_number)
    k = 0
    for i, j in zip(channels1, channels2):
        delays[i] = (getDelay(
            bufN,
            i,
            j,
            delaymax=delay_max,
            time=(A_B_timetags[-1] - 1) * bufN.resolution)) / bufN.resolution
        print delays[i]
        k += 1
    check_correlations(aliceTtags, aliceChannels, bobTtags, bobChannels,
                       resolution, A_B_timetags, A_B_channels, channels1,
                       channels2, delays, coincidence_window_radius)
    print("Saving delays to file.")
    save("./resultsLaurynas/Delays/delays.npy", delays)
示例#6
0
    def Start(self):
        if not self.inAcq:
            self.inAcq = True
            self.txtPause.setEnabled(False)
            self.txtBufferNo.setEnabled(False)
            self.btnStart.setStyleSheet('background-color: red')
            self.btnStart.setText('Stop')

            self.getParameters()
            self.timer.start(self.pause)

            self.ttagBuf = ttag.TTBuffer(self.bufNum)

        else:
            self.timer.stop()
            self.inAcq = False
            self.txtPause.setEnabled(True)
            self.txtBufferNo.setEnabled(True)
            self.btnStart.setStyleSheet('')
            self.btnStart.setText('Start')
示例#7
0
def prep():
    #Alice and Bob Channels
    aliceChannels = [0, 1, 2, 3]
    bobChannels = [4, 5, 6, 7]

    #binsize: The time in seconds of a bin
    binsize = 1 / (32 * 120.0e6)

    #Create the buffer that will do stuff
    bufAlice = ttag.TTBuffer(1)

    print("Binning...")

    #The time allocated to each bin:
    c, t = binData(bufAlice, binsize)

    #Create data sequences for Alice and Bob
    bob, alice, bob_pol, alice_pol = extractAliceBob(c, t, aliceChannels,
                                                     bobChannels)

    print("Finding Intersect")
    #Make sure Alice and Bob datasets coencide
    aliceMask = logical_and(alice > bob[0], alice < bob[-1])
    bobMask = logical_and(bob > alice[0], bob < alice[-1])

    bob = bob[bobMask]
    bob_pol = bob_pol[bobMask]
    alice = alice[aliceMask]
    alice_pol = alice_pol[aliceMask]

    #Now, rezero
    z = min(bob[0], alice[0])

    bob -= z
    alice -= z

    return (alice, bob, alice_pol, bob_pol)
示例#8
0
import ttag
bufNum = ttag.getfreebuffer() - 1
buf = ttag.TTBuffer(bufNum)
buf.stop()
#Run UQDinterface
# is this needed anymore? SN, May 17, 2014
#args = ['sudo', 'bash','launch.sh']
#f = open('test','w')
#process = subprocess.Popen(args,stdout=f)

#print "The process ID is:"
#print process.pid+1  # p.pid is the PID for the new shell.  p.pid is the PID for UQDinterface in the new shell
#print process.pid+2
#time.sleep(1)

#ttnumber = int(raw_input("Time tagger to open:"))
ttnumber = ttag.getfreebuffer() - 1
print "ttnumber: ", ttnumber
buf = ttag.TTBuffer(ttnumber)  #Opens the buffer
buf.tagsAsTime = False
buf.start()
time.sleep(1)

print "Channels:", buf.channels
print "Resolution:", buf.resolution
print "Datapoints:", buf.datapoints
print "Buffer size:", buf.size()

ptr = 0

updateTime = ptime.time()
fps = 0
logdata = False
seq_count = 0
示例#10
0
    aliceTtags = array(alice[1], dtype=uint64)
    bobTtags = array(bob[1], dtype=uint64)

    aliceChannels = array(alice[0], dtype=uint8)
    bobChannels = array(bob[0], dtype=uint8)

    A_B_timetags = concatenate((aliceTtags, bobTtags))
    A_B_channels = concatenate((aliceChannels, bobChannels))
    indexes_of_order = A_B_timetags.argsort(kind="mergesort")
    A_B_channels = take(A_B_channels, indexes_of_order)
    A_B_timetags = take(A_B_timetags, indexes_of_order)
    A_B_channels.astype(uint8)
    A_B_timetags.astype(uint64)

    buf_num = ttag.getfreebuffer()
    buffer = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e7))
    buffer.resolution = 156.25e-12
    buffer.channels = max(A_B_channels) + 1
    buffer.addarray(A_B_channels, A_B_timetags)
    resolution = 156.25e-12,
    channels1 = [0, 1, 2, 3]
    channels2 = [4, 5, 6, 7]

    #     (d1,d2) = calculate_delays(aliceTtags, aliceChannels, bobTtags, bobChannels,resolution= 156.25e-12,coincidence_window_radius = 5e-9, channel_array=channels1)
    #     print d1,d2
    set_printoptions(edgeitems=50)

    coincidence_window_radius = 1e-4
    print "radius in bins: ", coincidence_window_radius / buffer.resolution, "time back in bins, ", int(
        ((A_B_timetags[-1] - 1) * buffer.resolution) / buffer.resolution)
示例#11
0
def check_correlations(aliceTtags, aliceChannels, bobTtags, bobChannels,
                       resolution, A_B_timetags, A_B_channels, channels1,
                       channels2, delays, coincidence_window_radius,
                       matrix_before, delay_max, dic, l, b1, b2):
    #     print "TIMETAGS BEFORE DELAYS:", A_B_timetags,A_B_channels
    #     print("- Applying Delays")
    #     save("./Debugging/aliceChD.npy",A_B_channels[in1d(A_B_channels,channels1)])
    #     save("./Debugging/aliceTtagsD.npy",A_B_timetags[in1d(A_B_channels,channels1)])
    #
    #     save("./Debugging/bobChD.npy",A_B_channels[in1d(A_B_channels,channels2)])
    #     save("./Debugging/bobTtagsD.npy",A_B_timetags[in1d(A_B_channels,channels2)])
    #
    for delay, ch1, ch2 in zip(delays, channels1, channels2):
        if delay < 0:
            #             print "abs-->>",(abs(delay)).astype(int)
            A_B_timetags[A_B_channels == ch2] += (abs(delay)).astype(uint64)
        else:
            #             print "-->",delay
            A_B_timetags[A_B_channels == ch1] += delay.astype(uint64)

    indexes_of_order = A_B_timetags.argsort(kind="mergesort")
    A_B_channels = take(A_B_channels, indexes_of_order)
    A_B_timetags = take(A_B_timetags, indexes_of_order)
    #     print "SORTED TTAGS: ", A_B_timetags,A_B_channels

    buf_num = ttag.getfreebuffer()
    buffer = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e7))
    buffer.resolution = 260e-12
    buffer.channels = max(A_B_channels) + 1
    buffer.addarray(A_B_channels, A_B_timetags)

    #     a_ttags = array([])
    #     a_channels = array([])
    #     for ch in [0,1,2,3]:
    #         a_ttags = append(a_ttags, A_B_timetags[A_B_channels == ch])
    #         a_channels = append(a_channels, A_B_channels[A_B_channels == ch])
    #
    #     indexes_of_order = a_ttags.argsort(kind = "mergesort")
    #     a_channels = take(a_channels,indexes_of_order)
    #     a_ttags = take(a_ttags,indexes_of_order)
    #
    #
    #
    #
    #     a_laser_delay_string = laser(a_ttags[a_channels == 3], resolution, coincidence_window_radius)
    #
    #
    #
    #
    #
    #     b_ttags = array([])
    #     b_channels = array([])
    #     for ch in [4,5,6,7]:
    #         b_ttags = append(b_ttags, A_B_timetags[A_B_channels == ch])
    #         b_channels = append(b_channels, A_B_channels[A_B_channels == ch])
    #
    #     indexes_of_order = b_ttags.argsort(kind = "mergesort")
    #     b_channels = take(b_channels,indexes_of_order)
    #     b_ttags = take(b_ttags,indexes_of_order)
    #
    #
    #     savetxt("./DarpaQKD/a_ttags3-7",a_ttags[a_channels == 3],fmt='%15d')
    # #     print "with getcoinc",get_coinc(a_ttags, a_channels, b_ttags, b_channels, 3, 7, int(coincidence_window_radius/resolution))
    #     savetxt("./DarpaQKD/intersection3-7.npy",intersect1d(a_laser_delay_string,b_ttags[b_channels == 7]),fmt='%10d')
    #     print "Coincidences WITH delays",len(intersect1d(a_laser_delay_string,b_ttags[b_channels == 7]))

    #     (d1,d2) = getDelays(buffer,channels1,channels2,delaymax=coincidence_window_radius,time=(A_B_timetags[-1]-1)*buffer.resolution)
    #     A_B_timetags = A_B_timetags.astype(float)
    #     for i in range(len(channels1)):
    #         A_B_timetags[A_B_channels==channels1[i]]-=d1[i]
    #     for i in range(len(channels2)):
    #         A_B_timetags[A_B_channels==channels2[i]]-=d2[i]
    #     A_B_timetags = A_B_timetags.astype(uint64)

    buf_num = ttag.getfreebuffer()
    bufDelays = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e7))
    bufDelays.resolution = resolution
    bufDelays.channels = max(A_B_channels) + 1
    bufDelays.addarray(A_B_channels, A_B_timetags.astype(uint64))

    #     print bufDelays.singles((A_B_timetags[-1]-1)*bufDelays.resolution)
    with_delays = (bufDelays.coincidences(
        (A_B_timetags[-1] - 1) * bufDelays.resolution,
        coincidence_window_radius))
    #     print "__WITH_DELAYS-->\n",with_delays
    remade = remake_coincidence_matrix(with_delays)

    #     print "========================================================================================================="
    #     print coincidence_window_radius
    #     print "__REMADE-->>\n",remade
    remade1 = array(
        [[(remade[0][0] + remade[0][1] + remade[1][0] + remade[1][1]) /
          sum(sum(remade)),
          (remade[0][2] + remade[0][3] + remade[1][2] + remade[1][3]) /
          sum(sum(remade))],
         [(remade[2][0] + remade[2][1] + remade[3][0] + remade[3][1]) /
          sum(sum(remade)),
          (remade[2][2] + remade[2][3] + remade[3][2] + remade[3][3]) /
          sum(sum(remade))]])
    print remade[2][2], remade[3][3]
    dic[l] = (remade[2][2] + remade[3][3]) - (b1 + b2)
    return dic
    #     print array([  [(remade[0][0] + remade[0][1]+remade[1][0]+remade[1][1]), (remade[0][2] + remade[0][3]+remade[1][2]+remade[1][3])],
    #                   [(remade[2][0] + remade[2][1]+remade[3][0]+remade[3][1]), (remade[2][2] + remade[2][3]+remade[3][2]+remade[3][3])]
    #               ])
    print "========================================================================================================="
    #
    #     print "__CONTRIBUTION-->>\n", remade1

    save("./Debugging/aliceChD.npy", A_B_channels[in1d(A_B_channels,
                                                       channels1)])
    save("./Debugging/aliceTtagsD.npy",
         A_B_timetags[in1d(A_B_channels, channels1)])

    save("./Debugging/bobChD.npy", A_B_channels[in1d(A_B_channels, channels2)])
    save("./Debugging/bobTtagsD.npy",
         A_B_timetags[in1d(A_B_channels, channels2)])

    #     print"----",len(bobTtags)
    #     bobTtags = load("./DarpaQKD/bobCorrectedT.npy")
    #     bobChannels = load("./DarpaQKD/bobCorrectedC.npy")
    #     aliceTtags = load("./DarpaQKD/aliceCorrectedT.npy")
    #     aliceChannels = load("./DarpaQKD/aliceCorrectedC.npy")

    #     a_laser_string = laser(aliceTtags[aliceChannels==3], resolution, coincidence_window_radius)
    #     print a_laser_string
    #     print "Coincidences WITH CORRECTIONS",len(intersect1d(a_laser_string,bobTtags[bobChannels == 7]))/float(len(bobTtags[bobChannels == 7]))

    #     print len(bobTtags)
    A_B_timetags1 = concatenate([aliceTtags, bobTtags])
    A_B_channels1 = concatenate([aliceChannels, bobChannels])

    indexes_of_order = A_B_timetags1.argsort(kind="mergesort")
    A_B_channels1 = take(A_B_channels1, indexes_of_order)
    A_B_timetags1 = take(A_B_timetags1, indexes_of_order)

    buf_num = ttag.getfreebuffer()
    bufCorrec = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e7))
    bufCorrec.resolution = resolution
    bufCorrec.channels = max(A_B_channels1) + 1
    bufCorrec.addarray(A_B_channels1, A_B_timetags1.astype(uint64))

    with_corrections = (bufCorrec.coincidences(
        (A_B_timetags1[-1] - 1) * bufCorrec.resolution,
        coincidence_window_radius))
    #     print "__WITH_Corrections-->\n",with_corrections
    #     print "__REMADE-->>\n",remake_coincidence_matrix(with_corrections)

    #     a_laser_string = laser(aliceTtags[:len(aliceTtags)/88000], resolution, int(coincidence_window_radius/resolution))
    #     print "Coincidences with delays",len(intersect1d(a_laser_string,bobTtags[:len(aliceTtags)/88000]))
    #     print "with delays: number of 0 channels and number of channel 4",len(A_B_timetags[A_B_channels == 1]),len(A_B_timetags[A_B_channels == 4])
    #     print "COINcidences between 0 and 4 after delays: ", get_coinc(aliceTtags, aliceChannels, bobTtags, bobChannels, 0, 4, int(coincidence_window_radius/resolution))

    #     print "__DIFF___->>>>\n",matrix_before.astype(int64)-(bufDelays.coincidences((A_B_timetags[-1]-1)*bufDelays.resolution, coincidence_window_radius).astype(int64))

    length_in_bins = int(delay_max / resolution) * 2
示例#12
0
def calculate_delays(aliceTtags,
                     aliceChannels,
                     bobTtags,
                     bobChannels,
                     l,
                     dic,
                     resolution=260e-12,
                     coincidence_window_radius=200 - 12,
                     delay_max=1e-6):

    channels1 = [0, 1, 2, 3]
    channels2 = [4, 5, 6, 7]

    A_B_timetags = concatenate([aliceTtags, bobTtags])
    A_B_channels = concatenate([aliceChannels, bobChannels])

    indexes_of_order = A_B_timetags.argsort(kind="mergesort")
    A_B_channels = take(A_B_channels, indexes_of_order)
    A_B_timetags = take(A_B_timetags, indexes_of_order)

    #     print "TIME: ", A_B_timetags[-1]*resolution, " in seconds"
    buf_num = ttag.getfreebuffer()
    bufN = ttag.TTBuffer(buf_num, create=True, datapoints=int(5e11))
    bufN.resolution = resolution
    bufN.channels = max(A_B_channels) + 1
    bufN.addarray(A_B_channels, A_B_timetags)
    #     print aliceChannels[-20:],aliceTtags[-20:]
    #     print bobChannels[-20:],bobTtags[-20:]
    #     print A_B_channels[-20:],A_B_timetags[-20:]
    coincidences_before = (bufN.coincidences(
        (A_B_timetags[-1] - 1) * bufN.resolution, coincidence_window_radius))
    #     print "__BEFORE DELAYS-->\n",coincidences_before
    remade = remake_coincidence_matrix(coincidences_before)
    #     print "__REMADE-->>\n",remade
    remade1 = array(
        [[(remade[0][0] + remade[0][1] + remade[1][0] + remade[1][1]) /
          sum(sum(remade)),
          (remade[0][2] + remade[0][3] + remade[1][2] + remade[1][3]) /
          sum(sum(remade))],
         [(remade[2][0] + remade[2][1] + remade[3][0] + remade[3][1]) /
          sum(sum(remade)),
          (remade[2][2] + remade[2][3] + remade[3][2] + remade[3][3]) /
          sum(sum(remade))]])
    #
    #     print array([  [(remade[0][0] + remade[0][1]+remade[1][0]+remade[1][1]), (remade[0][2] + remade[0][3]+remade[1][2]+remade[1][3])],
    #                   [(remade[2][0] + remade[2][1]+remade[3][0]+remade[3][1]), (remade[2][2] + remade[2][3]+remade[3][2]+remade[3][3])]
    #               ])
    print "", remade[2][2], remade[3][3]
    #     print "__CONTRIBUTION-->>\n", remade1
    #
    #
    #
    #
    #     a_laser_string = laser(aliceTtags[aliceChannels==3], resolution, coincidence_window_radius)
    #     print "Coincidences without delays",len(intersect1d(a_laser_string,bobTtags[bobChannels == 7]))/float(len(bobTtags[bobChannels == 7]))

    #     print "number of 0 channels and number of channel 4",len(A_B_timetags[A_B_channels == 0]),len(A_B_timetags[A_B_channels == 4])
    #     print "Coincidences between 0 and 4 by Laurynas: ", get_coincidences(A_B_timetags, A_B_channels, 0, 4, coincidence_window_radius*2/bufN.resolution)
    #     print "That's it"

    #    1.9e-7 biggest u can make and still get correlations this corresponds to 1458 bins in diameter of coincidence window
    #    UPDATE: actaully you can take smaller fraction of the strings to determine delays but then you need to increase coincidence window
    delays = zeros(7)
    k = 0
    for i, j in zip(channels1, channels2):
        delays[i] = getDelay(bufN,
                             i,
                             j,
                             delaymax=delay_max,
                             time=(A_B_timetags[-1] - 1) * bufN.resolution)
        #         delays[i] = getDelay(bufN,i,j,delaymax=coincidence_window_radius,time=5.0)
        #         print delays[i]
        k += 1

    delays1 = zeros((len(channels1), len(channels2)))
    delays2 = zeros((len(channels1), len(channels2)))
    #
    #     for j in range(len(delays1)):
    #         for i in range(len(delays2)):
    #             delays2[j][i] = getDelay(bufN,channels1[j],channels2[i], delaymax=delay_max,time=(A_B_timetags[-1]-1)*bufN.resolution)
    #
    #     #Next, set all of delays for channels1
    #     for j in range(len(delays2)):
    #         for i in range(len(delays1)):
    #             delays1[j][i] = getDelay(bufN,channels1[i],channels2[j], delaymax=delay_max,time=(A_B_timetags[-1]-1)*bufN.resolution)
    delays1 = delays1 / bufN.resolution
    delays2 = delays2 / bufN.resolution
    #     print "DIRECT_____>",(delays/bufN.resolution)
    #
    #     print "MATRIX for alice_____>",(delays1)
    #     print "MATRIX for bob_____>",(delays2)
    #
    #     for i in range(len(channels1)):
    #         for j in range(len(channels2)-1):
    #             print channels2[j],"-",channels2[j+1],": ",delays1[i][j]-delays1[i][j+1]

    #     sys.stdout.flush()

    #     print "will now plotting corellations to check if it looks good."
    #     return check_correlations(aliceTtags,aliceChannels,bobTtags,bobChannels,resolution, A_B_timetags.astype(uint64), A_B_channels, channels1, channels2,delays/bufN.resolution, coincidence_window_radius,coincidences_before, delay_max,dic,l,remade[2][2],remade[3][3])
    #
    #     print("Saving delays to file.")
    save("./resultsLaurynas/Delays/delays.npy", delays / bufN.resolution)
示例#13
0
#Run UQDinterface
#args = ['sudo', '../../CppDemo/UQDinterface', '&']
#args = ['sudo', 'bash','launch.sh']
#f = open('test','w')
#p = subprocess.Popen(args,stdout=f)
#p = subprocess.Popen(args)

print "The process ID is:"
#print p.pid+1  # p.pid is the PID for the new shell.  p.pid is the PID for UQDinterface in the new shell
#print p.pid+2
#time.sleep(1)

#ttnumber = int(raw_input("Time tagger to open:"))
ttnumber = ttag.getfreebuffer() - 1
#buf = ttag.TTBuffer(ttnumber)  #Opens the buffer
buf = ttag.TTBuffer(0)  #Opens the buffer

print "Channels:", buf.channels
print "Resolution:", buf.resolution
print "Datapoints:", buf.datapoints
print "Buffer size:", buf.size()

currentTag = 1
lastTag = 0
biasList = np.array([x for x in range(8)])
#biasList = biasList[biasList == 7]

startOutter = 120
startInner = 120
numPatterns = 42
step = 2
示例#14
0
#If you want to dump by time, set to True, if dump by datapoints, set to False
dumpByTime = False

#Amount to dump -
#if dumpyByTime is True, the number of seconds to dump, if False, the number of datapoints\
dumpamt = -1

buffernumber = 2

filename = "C:/Users/kwiat/Desktop/dumpedDATA.csv"

from pylab import *
import ttag

print "Writing File: \"" + filename + "\""
print "Amount to dump:", dumpamt
try:
    x = ttag.TTBuffer(buffernumber)
    #print
    if (dumpByTime):
        (c, t) = x(dumpamt)
    else:
        if (dumpamt == -1):
            dumpamt = len(x)
            print "Set Dump Amount:", dumpamt
        (c, t) = x[-int(dumpamt):]
    savetxt(filename, (c, t))
except Exception, e:
    print e
    raw_input()
示例#15
0
def startTagger():
  ttnumber = ttag.getfreebuffer()-1
  print "ttnumber: ", ttnumber
  buf = ttag.TTBuffer(ttnumber)  #Opens the buffer
  return buf
示例#16
0
def polarizationPlot(polA, polB):
    figure()
    suptitle("Polarization Channels")
    for i in range(4):
        subplot(2, 2, i + 1)
        title("Channel " + str(1 + i))

        v = polA[polB == i]

        bar([1, 2, 3, 4],
            array([sum(v == 0),
                   sum(v == 1),
                   sum(v == 2),
                   sum(v == 3)],
                  dtype=double) / float(len(v)))
        #if (i==0):
        #    legend()
    show()


if (__name__ == "__main__"):
    aliceChannels = [0, 1, 2, 3]
    bobChannels = [4, 5, 6, 7]
    binsize = 1 / (32 * 120.0e6)
    bufAlice = ttag.TTBuffer(1)
    plotAutocorrelations(bufAlice, ymax=3000, bins=10000)
    plotABCorrelations(bufAlice,
                       aliceChannels,
                       bobChannels,
                       bins=60,
                       pulsebin=binsize)
示例#17
0
def runExperiment(threshLevels):
    currentTag = 1
    lastTag = 0
    delays = -1 * np.array([
        0, 0, 0, 0, 0, 0, 0, 0, 5e-9, 5e-9, 5e-9, 5e-9, 5e-9, 5e-9, 5e-9, 5e-9
    ])
    data = np.empty([1, 16])
    biasList = np.array([x for x in range(8)])
    #    biasList = biasList[biasList == 0]
    outmsg = 'VOLT %f' % float(V)
    for i in biasList:
        sim.conn(i + 1)
        sim.write('OPON')
        sim.write(outmsg)
        sim.write('xyz')
    time.sleep(1)  #Quick test to see if settle time an issue

    for level in threshLevels:
        writeSH(level)
        p = launch()

        print "The process ID is:"
        print p.pid + 2
        time.sleep(1)

        ttnumber = ttag.getfreebuffer() - 1
        buf = ttag.TTBuffer(ttnumber)  #Opens the buffer

        print "Channels:", buf.channels
        print "Resolution:", buf.resolution
        print "Datapoints:", buf.datapoints
        print "Buffer size:", buf.size()

        buf.start()
        time.sleep(Tacq + 0.5)
        buf.stop()

        try:
            xx = buf(Tacq)  # an array of the last 1 seconds worth of data
            currentTag = xx[1][-1]
        except:
            print "Can't run buf(Tacq) code"
        y = buf.singles(Tacq)

        for i in range(8):
            print "Row %d singles: " % (i + 1)
            print y[i]
        for i in range(8):
            print "Col %d singles: " % (i + 1)
            print y[i + 8]

        print "lastTag, currentTag:"
        print lastTag, currentTag

        if currentTag == lastTag:
            data[0, :] = 0
        else:
            data[0, :] = y
        if not currentTag == 1:
            lastTag = currentTag
        np.savetxt(fintcnts, data, fmt='%0.2f')
        kill(p)
    fintcnts.flush()
    fintcnts.close()

    for i in biasList:
        sim.conn(i + 1)
        sim.write('VOLT 0')
        sim.write('OPOF')
        sim.write('xyz')
    time.sleep(.5)
    sim.meter.loc()
示例#18
0
def startBuffer():
    bufNum = ttag.getfreebuffer() - 1
    buf = ttag.TTBuffer(bufNum)
    buf.start()
    time.sleep(1)
    return buf
示例#19
0
@author: qittlab
"""

import ttag
import numpy as np
import random
import time
import matplotlib.pyplot as plt

# Load fake data into buffer.

if True:
    bufNum = ttag.getfreebuffer()
    bufSize = 100000000
    buf = ttag.TTBuffer(bufNum, create=True, datapoints=bufSize)
    buf.resolution = 156e-12
    buf.channels = 16

    res = buf.resolution
    rate = 10e-6
    dr = 50e-9
    delay = int(2e-9 / res)
    tag = 0
    buf.add(random.randint(0, 8), tag)
    buf.add(random.randint(8, 16), tag)

    to = time.time()
    while (buf[-1][1] <= 1.2):
        #print buf[-1][1]
        tag += random.randint(int((rate - dr) / res), int((rate + dr) / res))
示例#20
0
# is this needed anymore? SN, May 17, 2014
#args = ['sudo', 'bash','launch.sh']
#f = open('test','w')
#process = subprocess.Popen(args,stdout=f)

#print "The process ID is:"
#print process.pid+1  # p.pid is the PID for the new shell.  p.pid is the PID for UQDinterface in the new shell
#print process.pid+2
#time.sleep(1)

#ttnumber = int(raw_input("Time tagger to open:"))

if False:  # For using real data from ttager
    ttnumber = ttag.getfreebuffer() - 1
    print "ttnumber: ", ttnumber
    buf = ttag.TTBuffer(ttnumber)  #Opens the buffer
    buf.start()
    time.sleep(1)

if True:  # For using fake data, manually added to buffer
    bufNum = ttag.getfreebuffer()
    print "bufNum", bufNum
    bufSize = 100000000
    buf = ttag.TTBuffer(bufNum, create=True, datapoints=bufSize)
    buf.resolution = 156e-12
    buf.channels = 16

    res = buf.resolution
    rate = 4e-6
    dr = 50e-9
    delay = int(2e-9 / res)