photon_histogram: add features

* support executing it (python3 repository/photon_histogram.py)
* show of parameters and results
This commit is contained in:
Robert Jördens 2015-04-04 20:48:21 -06:00
parent 1a1afd5410
commit c98e24abd4
1 changed files with 22 additions and 4 deletions

26
examples/master/repository/photon_histogram.py Normal file → Executable file
View File

@ -13,15 +13,24 @@ class PhotonHistogram(Experiment, AutoDB):
nbins = Argument(100) nbins = Argument(100)
repeats = Argument(100) repeats = Argument(100)
cool_f = Parameter(230)
detect_f = Parameter(220)
detect_t = Parameter(100)
ion_present = Parameter(True)
hist = Result()
total = Result()
@kernel @kernel
def cool_detect(self): def cool_detect(self):
with parallel: with parallel:
self.bd.pulse(200*MHz, 1*ms) self.bd.pulse(200*MHz, 1*ms)
self.bdd.pulse(300*MHz, 1*ms) self.bdd.pulse(300*MHz, 1*ms)
self.bd.pulse(210*MHz, 100*us) self.bd.pulse(self.cool_f*MHz, 100*us)
with parallel: with parallel:
self.bd.pulse(220*MHz, 100*us) self.bd.pulse(self.detect_f*MHz, self.detect_t*us)
self.pmt.gate_rising(100*us) self.pmt.gate_rising(self.detect_t*us)
self.bd.on(200*MHz) self.bd.on(200*MHz)
self.bdd.on(300*MHz) self.bdd.on(300*MHz)
return self.pmt.count() return self.pmt.count()
@ -29,11 +38,20 @@ class PhotonHistogram(Experiment, AutoDB):
@kernel @kernel
def run(self): def run(self):
hist = [0 for _ in range(self.nbins)] hist = [0 for _ in range(self.nbins)]
total = 0
for i in range(self.repeats): for i in range(self.repeats):
n = self.cool_detect() n = self.cool_detect()
if n >= self.nbins: if n >= self.nbins:
n = self.nbins - 1 n = self.nbins - 1
hist[n] += 1 hist[n] += 1
total += n
print(hist) self.hist = hist
self.total = total
self.ion_present = total > 5*self.repeats
if __name__ == "__main__":
from artiq.frontend.artiq_run import run
run()