artiq/artiq/examples/kc705_nist_clock/repository/photon_histogram.py

73 lines
1.9 KiB
Python
Raw Normal View History

2016-01-26 07:03:01 +08:00
from artiq.experiment import *
2014-09-13 19:38:15 +08:00
2015-07-14 04:08:20 +08:00
class PhotonHistogram(EnvExperiment):
"""Photon histogram"""
2015-07-14 04:08:20 +08:00
def build(self):
2015-10-04 00:18:21 +08:00
self.setattr_device("core")
self.setattr_device("bd_dds")
self.setattr_device("bd_sw")
self.setattr_device("bdd_dds")
self.setattr_device("bdd_sw")
self.setattr_device("pmt")
2014-09-13 19:38:15 +08:00
2016-05-07 17:40:44 +08:00
self.setattr_argument("nbins", NumberValue(100, ndecimals=0, step=1))
self.setattr_argument("repeats", NumberValue(100, ndecimals=0, step=1))
self.setattr_dataset("cool_f", 230*MHz)
self.setattr_dataset("detect_f", 220*MHz)
self.setattr_dataset("detect_t", 100*us)
2015-05-08 22:17:06 +08:00
@kernel
def program_cooling(self):
delay_mu(-self.bd_dds.set_duration_mu)
self.bd_dds.set(200*MHz)
delay_mu(self.bd_dds.set_duration_mu)
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)
with parallel:
2015-05-08 22:17:06 +08:00
self.bd_sw.pulse(self.detect_t)
gate_end_mu = 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(gate_end_mu)
2014-09-13 19:38:15 +08:00
@kernel
def run(self):
2016-06-29 02:37:39 +08:00
self.core.reset()
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):
delay(0.5*ms)
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.set_dataset("cooling_photon_histogram", hist)
self.set_dataset("ion_present", total > 5*self.repeats,
broadcast=True)
2014-09-13 19:38:15 +08:00
if __name__ == "__main__":
from artiq.frontend.artiq_run import run
run()