def SW_run(self):
        """Runs in own thread - reads data via Swabian box"""
        self.tag.setTriggerLevel(0, 0.1)
        self.tag.setTriggerLevel(1, 0.1)  # allows Swabian to read SNSPD counts
        sweep_t = 1. / (self.f)  # time for full sweep in s
        pixel_t = sweep_t / float(
            self.no_of_steps)  # time for each pixel of sweep in s
        times = pl.arange(1, self.no_of_steps)
        self.ctr = Counter(self.tag, [0, 1], int(pixel_t * 1e12),
                           int(self.no_of_steps))
        self.ctr.clear()  # clear buffer
        try:

            # go smoothly to start position
            self.updateStatusScanField('Please wait, synchronising...')
            self.tag.sync()  # clears all tags from timetagger before sync call
            self.synchro.wait()  # wait for sync pulse to be 1
            self.updateStatusScanField('Scanning...')
            while self.running:
                self.tag.sync()  # flush again
                self.synchro.wait()  # wait for start of sync pulse
                self.ctr.clear()  # clear buffer, start to be filled with data
                self.synchro.wait()  # wait for next sync pulse
                data = self.ctr.getData()  # read data from buffer
                self.synchro.clear()  # clear event
                for i in times:
                    self.buff1.append(sum(data[0][int(-i - 1):int(-i)]))
                    self.buff2.append(sum(data[1][int(-i - 1):int(-i)]))
                self.ctr.clear()
                self.gotdata = True
                while self.gotdata:
                    pass  # wait for plotting
        finally:
            pass
    def SW_run(self):
        """Runs in own thread - reads data via Swabian box"""
        self.measure_data = pl.zeros((50, ))
        try:
            self.tag = createTimeTagger()
            self.tag.setTriggerLevel(0, 0.15)
            self.tag.setTriggerLevel(1, 0.15)
            self.ctr = Counter(self.tag, [0, 1], int(1e9), int(self.dt))
            while self.running:
                time.sleep(self.dt / 1000.)
                rates = self.ctr.getData()
                if self.detID == 0:
                    newCount = pl.mean(rates[0]) * 1000
                elif self.detID == 1:
                    newCount = pl.mean(rates[1]) * 1000
                else:
                    newCount = (pl.mean(rates[0]) + pl.mean(rates[1])) * 1000
                self.measure_data[0] = newCount
                self.measure_data = pl.roll(self.measure_data, -1)
                print self.measure_data
                self.gotdata = True

        finally:
            self.ctr.stop()
            self.tag.reset()
            self.running = False
            self.btn.setEnabled(True)
 def SW_run(self):
     """Runs in own thread - reads data via Swabian box"""
     
     self.v_step = pl.array([pl.linspace(self.v_i, self.v_f, self.no_of_steps) for i in range(self.repeats)]).flatten()
     try:
         
         self.tag = createTimeTagger()
         self.tag.setTriggerLevel(0, 0.2)
         self.tag.setTriggerLevel(1, 0.2)
         self.ctr = Counter(self.tag, [0,1], int(1e9), int(self.dt))
         self.tag.sync()
         for v in self.v_step:
             if self.running:
                 self.voltT.setDACvoltage(voltage=float(v) / 1000, outputId=2)
                 time.sleep(self.dt/1000.)
                 rates = self.ctr.getData()
                 newCount = (pl.mean(rates[0]) + pl.mean(rates[1]))*1000
                 self.buff.append(newCount)
                 # print self.measure_data
                 self.gotdata = True
             
     finally:
         self.ctr.stop()
         self.tag.reset()
         self.running = False
         self.btn.setEnabled(True)        
    def set_up_counter(self,
                       counter_channel=None,
                       photon_source=None,
                       counter_channel2=None,
                       photon_source2=None,
                       clock_channel=None,
                       counter_buffer=None):
        """ Configures the actual counter with a given clock.

        @param str counter_channel: optional, physical channel of the counter
        @param str photon_source: optional, physical channel where the photons
                                  are to count from
        @param str counter_channel2: optional, physical channel of the counter 2
        @param str photon_source2: optional, second physical channel where the
                                   photons are to count from
        @param str clock_channel: optional, specifies the clock channel for the
                                  counter
        @param int counter_buffer: optional, a buffer of specified integer
                                   length, where in each bin the count numbers
                                   are saved.

        @return int: error code (0:OK, -1:error)
        """

        self.counter = Counter(self._tagger,
                               channels=[self._photon_source],
                               binwidth=int(
                                   (1 / self._count_frequency) * 1e12),
                               n_values=1)
        self.log.info('set up counter with {0}'.format(self._count_frequency))
        return 0
 def readout(self):
     """Takes a single reading of counts"""
     self.ctr = Counter(self.tag, [0, 1], int(1e9), int(self.dt))
     time.sleep(self.dt / 1000.)
     rates = self.ctr.getData()
     newCount = (pl.mean(rates[0]) + pl.mean(rates[1])) * 1000
     self.gotdata = True
     return newCount
Example #6
0
 def _reset(self):
     if hasattr(self,'_timer'):
         self._timer.Stop()
     self._create_plot()
     self._counter = Counter(self.tagger, self.channels, int(self.seconds_per_point*1e12), self.number_of_points)
     self.time = self._counter.getIndex() * 1e-12
     self.count_rate = self._counter.getData() / self.seconds_per_point
     self._timer = Timer(100, self._refresh_data)
     self._timer.Start()
Example #7
0
    def __init__(self, parameters, runTest=False):
        self.__dict__.update(parameters)
        try:
            self.tagger = createTimeTagger()
            self.tagger.reset()
            print(
                f"Tagger initialization successful: {self.tagger.getSerial()}")
        except RuntimeError:
            print(
                f"\nCheck if the TimeTagger device is being used by another instance."
            )
            sys.exit()

        if runTest:
            print("RUNNING WITH TEST SIGNAL!")
            for i in self.testSignals:
                self.tagger.setTestSignal(i, True)

        for idx, delay_t in enumerate(self.delayTimes):
            if delay_t != 0:
                self.tagger.setInputDelay(delay=delay_t, channel=idx + 1)

        self.hist_1 = Histogram(self.tagger, self.currentChan1[0],
                                self.trigChans[0], self.binWidth1,
                                self.numBins1)

        self.hist_2 = Histogram(self.tagger, self.currentChan2[0],
                                self.trigChans[0], self.binWidth2,
                                self.numBins2)

        self.virtChannel_start = DelayedChannel(
            self.tagger,
            input_channel=self.trigChans[0],
            delay=self.gate_delay[0])

        self.virtChannel_end = DelayedChannel(self.tagger,
                                              input_channel=self.trigChans[0],
                                              delay=self.gate_delay[1])

        self.gated_channel = GatedChannel(
            self.tagger,
            input_channel=self.gatedChan[0],
            gate_start_channel=self.virtChannel_start.getChannel(),
            gate_stop_channel=self.virtChannel_end.getChannel())

        g2_start, g2_end = self.combiner_channels(self.g2_channels_start,
                                                  self.g2_channels_end)

        self.corr = Correlation(self.tagger, g2_start, g2_end, self.binWidth1,
                                self.numBins1)

        self.counter = Counter(self.tagger, self.counter_channels,
                               self.binWidthCounter, self.numBinsCounter)
    def SW_run(self):
        """Runs in own thread - reads data via Swabian box"""
        self.ctr = Counter(self.tag, [0, 1], int(1000000000),
                           int(30 * self.no_of_steps))
        self.ctr.clear()

        try:

            if self.goBack:
                voltSteps = self.v_step[::-1]
                scanMessage = 'Scanning backwards... (off resonance)'
                self.voltT.setDACvoltage(outputId=1, voltage=self.res_v + 0.1)
            else:
                voltSteps = self.v_step
                if self.backAndForthMode:
                    scanMessage = 'Scanning forward.. (on resonance)'
                    self.voltT.setDACvoltage(outputId=1, voltage=self.res_v)
                else:
                    scanMessage = 'Scanning...'

            # go smoothly to start position
            self.updateStatusScanField('Please wait, going to start position.')
            self.voltT.lockinGoSmoothlyToVoltage(voltSteps[0],
                                                 outputId=1,
                                                 delay=0.001)

            # start measurement scan
            self.updateStatusScanField(scanMessage)

            start = time.clock()
            self.times = []
            self.tag.sync()
            start = time.clock()
            self.ctr.clear()
            for v in voltSteps:
                if self.running:
                    self.voltT.setDACvoltage(outputId=1,
                                             voltage=float(v) / 1000)
                    self.times.append((time.clock() - start) * 1000)
                    time.sleep(self.dt / 1000.)

                else:
                    break
            data1 = self.ctr.getData()[0]
            data2 = self.ctr.getData()[1]
            for i in self.times:
                self.buff1.append(sum(data1[int(-i - self.dt):int(-i)]))
                self.buff2.append(sum(data2[int(-i - self.dt):int(-i)]))
                print i, i + self.dt

            self.gotdata = True
        finally:
            self.running = False
Example #9
0
from TimeTagger import createTimeTagger, Combiner, Coincidence, Counter, Countrate, Correlation, TimeDifferences, TimeTagStream, TimeTagStreamBuffer, Scope, Event, CHANNEL_UNUSED
from time import sleep
from pylab import *

# create a timetagger instance
tagger = createTimeTagger()
tagger.reset();

# simple counter on channels 0 and 1 with 1 ms binwidth (1e9 ps) and 2000 successive values
print ("****************************************")
print ("*** Demonstrate a counter time trace ***")
print ("****************************************")
print ("")
print ("Create counters on channels 0 and 1 with 1 ms binwidth and 1000 points.")
print ("")
count = Counter(tagger, channels=[0,1], binwidth=int(1e9), n_values=int(1000))


# apply the built in test signal (~0.8 to 0.9 MHz) to channels 0 and 1
print ("Enabling test signal on channel 0.")
print ("")
tagger.setTestSignal(0, True)
sleep(.5)
print ("Enabling test signal on channel 1.")
print ("")
tagger.setTestSignal(1, True)
sleep(.5)

# wait until the 1000 values should be filled
# we should see the calibration signal turning on in the time trace