Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: m-labs/artiq
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 6973a9471bb0
Choose a base ref
...
head repository: m-labs/artiq
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1891725e12e2
Choose a head ref
  • 5 commits
  • 4 files changed
  • 1 contributor

Commits on Feb 18, 2016

  1. master: inform when running

    jordens committed Feb 18, 2016
    2
    Copy the full SHA
    0edde9f View commit details
  2. coefficients: cleanup

    jordens committed Feb 18, 2016
    Copy the full SHA
    65824fc View commit details
  3. Copy the full SHA
    d162b2c View commit details
  4. Copy the full SHA
    b4ea318 View commit details
  5. wavesynth: cleanup

    jordens committed Feb 18, 2016
    Copy the full SHA
    1891725 View commit details
Showing with 23 additions and 56 deletions.
  1. +6 −1 artiq/frontend/artiq_master.py
  2. +10 −1 artiq/test/test_coefficients.py
  3. +6 −51 artiq/wavesynth/coefficients.py
  4. +1 −3 examples/master/repository/coredevice_examples/transport.py
7 changes: 6 additions & 1 deletion artiq/frontend/artiq_master.py
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import argparse
import atexit
import os
import logging

from artiq.tools import *
from artiq.protocols.pc_rpc import Server as RPCServer
@@ -13,7 +14,10 @@
from artiq.master.databases import DeviceDB, DatasetDB
from artiq.master.scheduler import Scheduler
from artiq.master.worker_db import RIDCounter
from artiq.master.experiments import FilesystemBackend, GitBackend, ExperimentDB
from artiq.master.experiments import (FilesystemBackend, GitBackend,
ExperimentDB)

logger = logging.getLogger(__name__)


def get_argparser():
@@ -111,6 +115,7 @@ def main():
bind, args.port_logging))
atexit_register_coroutine(server_logging.stop)

loop.call_soon(logger.info, "running, bound to %s", bind)
loop.run_forever()

if __name__ == "__main__":
11 changes: 10 additions & 1 deletion artiq/test/test_coefficients.py
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@ def setUp(self):
self.s = coefficients.SplineSource(self.x, self.y, order=4)

def test_get_segment(self):
return list(self.s.get_segment_data(start=1.5, stop=3.2, scale=.01))
return list(self.s.get_segment(start=1.5, stop=3.2, scale=.01))

def test_synth(self):
d = self.test_get_segment()
@@ -32,6 +32,15 @@ def drive(self, s):
def test_run(self):
return self.drive(self.test_synth())

def test_compare(self):
scale = 100
d = list(self.s.get_segment(start=0, stop=4, scale=1/scale))
d[0]["trigger"] = True
s = compute_samples.Synthesizer(self.y.shape[0], [d])
s.select(0)
y = s.trigger()[0]
np.testing.assert_almost_equal(y[::scale], self.y[0, :-1])

@unittest.skip("manual/visual test")
def test_plot(self):
import matplotlib.pyplot as plt
57 changes: 6 additions & 51 deletions artiq/wavesynth/coefficients.py
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import numpy as np
from scipy.interpolate import splrep, splev, spalde
from scipy.special import binom


class UnivariateMultiSpline:
@@ -121,9 +120,9 @@ def __call__(self, x, **kwargs):
with `n` being the number of channels."""
raise NotImplementedError

def get_segment_data(self, start, stop, scale, *, cutoff=1e-12,
target="bias", variable="amplitude"):
"""Build wavesynth segment data.
def get_segment(self, start, stop, scale, *, cutoff=1e-12,
target="bias", variable="amplitude"):
"""Build wavesynth segment.
:param start: see `crop_x()`.
:param stop: see `crop_x()`.
@@ -148,7 +147,7 @@ def extend_segment(self, segment, *args, **kwargs):
See `get_segment()` for arguments.
"""
for i, line in enumerate(self.get_segment_data(*args, **kwargs)):
for line in self.get_segment(*args, **kwargs):
segment.add_line(**line)


@@ -180,12 +179,11 @@ def crop_x(self, start, stop):
x = self.x[ia:ib]
return np.r_[start, x, stop]

def scale_x(self, x, scale, min_duration=1, min_length=20):
def scale_x(self, x, scale, min_duration=10, min_length=20):
"""Enforce, round, and scale x to device-dependent values.
Due to minimum duration and/or minimum segment length constraints
this method may drop samples from `x_sample` or adjust `durations` to
comply. But `x_sample` and `durations` should be kept consistent.
this method may drop samples from `x_sample` to comply.
:param min_duration: Minimum duration of a line.
:param min_length: Minimum segment length to space triggers.
@@ -215,49 +213,6 @@ def __call__(self, x):
return self.spline(x)


class ComposingSplineSource(SplineSource):
# TODO: verify, test, document
def __init__(self, x, y, components, order=4, pad_dx=1.):
self.x = np.asanyarray(x)
assert self.x.ndim == 1
self.y = np.asanyarray(y)
assert self.y.ndim == 3

if pad_dx is not None:
a = np.arange(-order, 0)*pad_dx + self.x[0]
b = self.x[-1] + np.arange(1, order + 1)*pad_dx
self.x = np.r_[a, self.x, b]
self.y = pad_const(self.y, order, axis=2)

assert self.y.shape[2] == self.x.shape[0]
self.splines = [UnivariateMultiSpline(self.x, yi, order=order)
for yi in self.y]

# need to resample/upsample the shim splines to the master spline knots
# shim knot spacings can span an master spline knot and thus would
# cross a highest order derivative boundary
y0, x0 = zip(*components)
self.components = UnivariateMultiSpline(self.x, y0, x0=x0, order=order)

def __call__(self, t, gain={}, offset={}):
der = list((set(self.components.n) | set(offset))
& set(range(len(self.splines))))
u = np.zeros((self.splines[0].order, len(self.splines[0].s), len(t)))
# der, order, ele, t
p = np.array([self.splines[i](t) for i in der])
s_gain = np.array([gain.get(_, 1.) for _ in self.components.n])
# order, der, None, t
s = self.components(t)[:, :, None, :]*s_gain[None, :, None, None]
for k, v in offset.items():
if v:
u += v*p[k]
ps = p[self.shims.n]
for i in range(u.shape[1]):
for j in range(i + 1):
u[i] += binom(i, j)*(s[j]*ps[:, i - j]).sum(0)
return u # (order, ele, t)


def discrete_compensate(c):
"""Compensate spline coefficients for discrete accumulators
4 changes: 1 addition & 3 deletions examples/master/repository/coredevice_examples/transport.py
Original file line number Diff line number Diff line change
@@ -60,10 +60,8 @@ def transport(self):

@kernel
def detect(self):
with parallel:
self.bd_sw.pulse(100*us)
self.pmt.gate_rising(100*us)
self.bd_sw.on()
self.pmt.gate_rising(100*us)
return self.pmt.count()

@kernel