artiq/examples/master/repository/photon_histogram.py

76 lines
1.6 KiB
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(Experiment, AutoDB):
"""Photon histogram"""
class DBKeys:
2015-03-08 18:37:53 +08:00
core = Device()
2015-05-08 22:17:06 +08:00
dds_bus = Device()
bd_dds = Device()
bd_sw = Device()
bdd_dds = Device()
bdd_sw = Device()
pmt = Device()
2014-09-13 19:38:15 +08:00
nbins = Argument(100)
repeats = Argument(100)
cool_f = Parameter(230*MHz)
detect_f = Parameter(220*MHz)
detect_t = Parameter(100*us)
ion_present = Parameter(True)
hist = Result()
total = Result()
2015-05-08 22:17:06 +08:00
@kernel
def program_cooling(self):
2015-05-09 14:47:40 +08:00
with self.dds_bus.batch:
self.bd_dds.set(200*MHz)
self.bdd_dds.set(300*MHz)
2015-05-08 22:17:06 +08:00
2014-09-13 19:38:15 +08:00
@kernel
def cool_detect(self):
with parallel:
2015-05-08 22:17:06 +08:00
self.bd_sw.pulse(1*ms)
self.bdd_sw.pulse(1*ms)
self.bd_dds.set(self.cool_f)
self.bd_sw.pulse(100*us)
self.bd_dds.set(self.detect_f)
2014-09-13 19:38:15 +08:00
with parallel:
2015-05-08 22:17:06 +08:00
self.bd_sw.pulse(self.detect_t)
self.pmt.gate_rising(self.detect_t)
2015-05-08 22:17:06 +08:00
self.program_cooling()
self.bd_sw.on()
self.bdd_sw.on()
return self.pmt.count()
2014-09-13 19:38:15 +08:00
@kernel
def run(self):
2015-05-08 22:17:06 +08:00
self.program_cooling()
hist = [0 for _ in range(self.nbins)]
total = 0
2014-09-13 19:38:15 +08:00
for i in range(self.repeats):
2014-09-13 19:38:15 +08:00
n = self.cool_detect()
if n >= self.nbins:
n = self.nbins - 1
2014-09-13 19:38:15 +08:00
hist[n] += 1
total += n
self.hist = hist
self.total = total
self.ion_present = total > 5*self.repeats
2014-09-13 19:38:15 +08:00
if __name__ == "__main__":
from artiq.frontend.artiq_run import run
run()