2
0
mirror of https://github.com/m-labs/artiq.git synced 2024-12-25 03:08:27 +08:00

examples: use run arguments

This commit is contained in:
Sebastien Bourdeauducq 2015-01-07 21:41:31 +08:00
parent be9f7550b5
commit 1407a48836
2 changed files with 14 additions and 18 deletions

View File

@ -5,8 +5,6 @@ class PhotonHistogram(AutoContext):
bd = Device("dds")
bdd = Device("dds")
pmt = Device("ttl_in")
repeats = Parameter(100)
nbins = Parameter(100)
@kernel
def cool_detect(self):
@ -22,13 +20,13 @@ class PhotonHistogram(AutoContext):
return self.pmt.count()
@kernel
def run(self):
hist = [0 for _ in range (self.nbins)]
def run(self, nbins=100, repeats=100):
hist = [0 for _ in range (nbins)]
for i in range(self.repeats):
for i in range(repeats):
n = self.cool_detect()
if n >= self.nbins:
n = self.nbins-1
if n >= nbins:
n = nbins - 1
hist[n] += 1
print(hist)

View File

@ -16,8 +16,6 @@ class Transport(AutoContext):
pmt = Device("ttl_in")
electrodes = Device("pdq")
repeats = Parameter(100)
nbins = Parameter(100)
wait_at_stop = Parameter(100*us)
speed = Parameter(1.5)
@ -93,27 +91,27 @@ class Transport(AutoContext):
return self.detect()
@kernel
def repeat(self):
self.histogram = [0 for _ in range(self.nbins)]
def repeat(self, repeats, nbins):
self.histogram = [0 for _ in range(nbins)]
for i in range(self.repeats):
for i in range(repeats):
n = self.one()
if n >= self.nbins:
n = self.nbins-1
if n >= nbins:
n = nbins - 1
self.histogram[n] += 1
def scan(self, stops):
def scan(self, repeats, nbins, stops):
for s in stops:
self.histogram = []
# non-kernel, calculate waveforms, build frames
# could also be rpc'ed from repeat()
self.prepare(s)
# kernel part
self.repeat()
self.repeat(repeats, nbins)
# live update 2d plot with current self.histogram
# broadcast(s, self.histogram)
def run(self):
def run(self, repeats=100, nbins=100):
# scan transport endpoint
stops = range(10, len(transport_data["t"]), 10)
self.scan(stops)
self.scan(repeats, nbins, stops)