artiq/examples/photon_histogram.py

35 lines
833 B
Python
Raw Normal View History

2014-09-30 17:38:02 +08:00
from artiq import *
2014-09-13 19:38:15 +08:00
class PhotonHistogram(AutoContext):
bd = Device("dds")
bdd = Device("dds")
pmt = Device("ttl_in")
2014-12-03 18:20:30 +08:00
repeats = Parameter(100)
nbins = Parameter(100)
2014-09-13 19:38:15 +08:00
@kernel
def cool_detect(self):
with parallel:
self.bd.pulse(200*MHz, 1*ms)
self.bdd.pulse(300*MHz, 1*ms)
self.bd.pulse(210*MHz, 100*us)
with parallel:
self.bd.pulse(220*MHz, 100*us)
self.pmt.gate_rising(100*us)
2014-09-13 19:38:15 +08:00
self.bd.on(200*MHz)
self.bdd.on(300*MHz)
return self.pmt.count()
2014-09-13 19:38:15 +08:00
@kernel
def run(self):
2014-12-17 21:54:10 +08:00
hist = [0 for _ in range (self.nbins)]
2014-09-13 19:38:15 +08:00
for i in range(self.repeats):
n = self.cool_detect()
if n >= self.nbins:
n = self.nbins-1
hist[n] += 1
2014-12-19 15:20:19 +08:00
print(hist)