Time Tagger provides a Countrate measurement class that allows for the measurement of average count rate. The averaging can be done over infinite time (as long as measurement runs) and over precisely defined averaging duration.
Below is the Python code that shows how to perform average countrate measurement over infinite and well-defined durations.
from time import sleep
import TimeTagger
# Create a TimeTagger instance to control your hardware
tagger = TimeTagger.createTimeTagger()
channels = [1, 2]
# This enables internal test signals for demo purposes.
# Comment the following line if you want to try this with an external signals
tagger.setTestSignal(channels, True)
Measure the Countrate over the whole run time:
# We create a Countrate instance, it will acquire data immediately
countrate = TimeTagger.Countrate(tagger=tagger, channels=channels)
# Periodically read and print the average countrate measured since measurement creation.
print('Average countrate values since the measurement creation.')
for i in range(10):
# Wait for some time (software controlled)
sleep(0.5)
# Read countrate averaged over the run duration
rate = countrate.getData()
# Read time since measurement start
duration_of_measurement = countrate.getCaptureDuration()
print(
f'Average countrate: CH{channels[0]}: {rate[0]:10.6f} cps, '
f'CH{channels[1]}:{rate[1]:10.6f} cps '
f'@ averaged over: {duration_of_measurement*1e-12:0.3f} s'
)
Measure the count rate periodically over a well-defined duration. The duration of averaging is hardware-controlled and is picoseconds precise:
# We create a Countrate instance, it will acquire data immediately
countrate = TimeTagger.Countrate(tagger=tagger, channels=channels)
# Periodically measure average countrate over well defined period of time.
average_time = 0.5 # seconds
print('EXAMPLE 2. Average over defined time.')
print('Average countrate values measured periodically over the defined time.')
for i in range(10):
# Start the measurement for defined duration. It will stop automtically.
countrate.startFor(average_time*1e12, clear=True)
# Wait until the measurement averaged over the requested duration.
countrate.waitUntilFinished()
# Read countrate averaged over the run duration
rate = countrate.getData()
# Read time since measurement start
duration_of_measurement = countrate.getCaptureDuration()
print(
f'Average countrate: CH{channels[0]}: {rate[0]:10.6f} cps, '
f'CH{channels[1]}:{rate[1]:10.6f} cps '
f'@ averaged over: {duration_of_measurement*1e-12:0.3f} s'
)