mirror of https://github.com/m-labs/artiq.git
examples: use run arguments
This commit is contained in:
parent
be9f7550b5
commit
1407a48836
|
@ -5,8 +5,6 @@ class PhotonHistogram(AutoContext):
|
||||||
bd = Device("dds")
|
bd = Device("dds")
|
||||||
bdd = Device("dds")
|
bdd = Device("dds")
|
||||||
pmt = Device("ttl_in")
|
pmt = Device("ttl_in")
|
||||||
repeats = Parameter(100)
|
|
||||||
nbins = Parameter(100)
|
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def cool_detect(self):
|
def cool_detect(self):
|
||||||
|
@ -22,13 +20,13 @@ class PhotonHistogram(AutoContext):
|
||||||
return self.pmt.count()
|
return self.pmt.count()
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def run(self):
|
def run(self, nbins=100, repeats=100):
|
||||||
hist = [0 for _ in range (self.nbins)]
|
hist = [0 for _ in range (nbins)]
|
||||||
|
|
||||||
for i in range(self.repeats):
|
for i in range(repeats):
|
||||||
n = self.cool_detect()
|
n = self.cool_detect()
|
||||||
if n >= self.nbins:
|
if n >= nbins:
|
||||||
n = self.nbins-1
|
n = nbins - 1
|
||||||
hist[n] += 1
|
hist[n] += 1
|
||||||
|
|
||||||
print(hist)
|
print(hist)
|
||||||
|
|
|
@ -16,8 +16,6 @@ class Transport(AutoContext):
|
||||||
pmt = Device("ttl_in")
|
pmt = Device("ttl_in")
|
||||||
electrodes = Device("pdq")
|
electrodes = Device("pdq")
|
||||||
|
|
||||||
repeats = Parameter(100)
|
|
||||||
nbins = Parameter(100)
|
|
||||||
wait_at_stop = Parameter(100*us)
|
wait_at_stop = Parameter(100*us)
|
||||||
speed = Parameter(1.5)
|
speed = Parameter(1.5)
|
||||||
|
|
||||||
|
@ -93,27 +91,27 @@ class Transport(AutoContext):
|
||||||
return self.detect()
|
return self.detect()
|
||||||
|
|
||||||
@kernel
|
@kernel
|
||||||
def repeat(self):
|
def repeat(self, repeats, nbins):
|
||||||
self.histogram = [0 for _ in range(self.nbins)]
|
self.histogram = [0 for _ in range(nbins)]
|
||||||
|
|
||||||
for i in range(self.repeats):
|
for i in range(repeats):
|
||||||
n = self.one()
|
n = self.one()
|
||||||
if n >= self.nbins:
|
if n >= nbins:
|
||||||
n = self.nbins-1
|
n = nbins - 1
|
||||||
self.histogram[n] += 1
|
self.histogram[n] += 1
|
||||||
|
|
||||||
def scan(self, stops):
|
def scan(self, repeats, nbins, stops):
|
||||||
for s in stops:
|
for s in stops:
|
||||||
self.histogram = []
|
self.histogram = []
|
||||||
# non-kernel, calculate waveforms, build frames
|
# non-kernel, calculate waveforms, build frames
|
||||||
# could also be rpc'ed from repeat()
|
# could also be rpc'ed from repeat()
|
||||||
self.prepare(s)
|
self.prepare(s)
|
||||||
# kernel part
|
# kernel part
|
||||||
self.repeat()
|
self.repeat(repeats, nbins)
|
||||||
# live update 2d plot with current self.histogram
|
# live update 2d plot with current self.histogram
|
||||||
# broadcast(s, self.histogram)
|
# broadcast(s, self.histogram)
|
||||||
|
|
||||||
def run(self):
|
def run(self, repeats=100, nbins=100):
|
||||||
# scan transport endpoint
|
# scan transport endpoint
|
||||||
stops = range(10, len(transport_data["t"]), 10)
|
stops = range(10, len(transport_data["t"]), 10)
|
||||||
self.scan(stops)
|
self.scan(repeats, nbins, stops)
|
||||||
|
|
Loading…
Reference in New Issue