From 7ea9250b31dfa9afa23c4572ff6e56060f5c9407 Mon Sep 17 00:00:00 2001 From: Robert Jordens Date: Sun, 5 Apr 2015 04:42:28 -0600 Subject: [PATCH] wavesynth: interpolate->coefficients --- artiq/devices/pdq2/driver.py | 2 +- artiq/wavesynth/{interpolate.py => coefficients.py} | 11 +++++++---- artiq/wavesynth/compute_samples.py | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) rename artiq/wavesynth/{interpolate.py => coefficients.py} (90%) diff --git a/artiq/devices/pdq2/driver.py b/artiq/devices/pdq2/driver.py index 851adb5c8..aa8b8ae31 100644 --- a/artiq/devices/pdq2/driver.py +++ b/artiq/devices/pdq2/driver.py @@ -6,7 +6,7 @@ import struct import serial -from artiq.wavesynth.interpolate import discrete_compensate +from artiq.wavesynth.coefficients import discrete_compensate logger = logging.getLogger(__name__) diff --git a/artiq/wavesynth/interpolate.py b/artiq/wavesynth/coefficients.py similarity index 90% rename from artiq/wavesynth/interpolate.py rename to artiq/wavesynth/coefficients.py index 8e133c1c7..c19c4f7a5 100644 --- a/artiq/wavesynth/interpolate.py +++ b/artiq/wavesynth/coefficients.py @@ -24,11 +24,14 @@ def _interpolate(time, data, sample_times, order=3): def discrete_compensate(c): - if len(c) > 2: - c[1] += c[2]/2 - if len(c) > 3: - c[1] += c[3]/6 + l = len(c) + if l > 2: + c[1] += c[2]/2. + if l > 3: + c[1] += c[3]/6. c[2] += c[3] + if l > 4: + raise ValueError("only third-order splines supported") def _zip_program(times, channels, target): diff --git a/artiq/wavesynth/compute_samples.py b/artiq/wavesynth/compute_samples.py index 76841c35e..c615c9dd1 100644 --- a/artiq/wavesynth/compute_samples.py +++ b/artiq/wavesynth/compute_samples.py @@ -1,7 +1,7 @@ from copy import copy from math import cos, pi -from artiq.wavesynth.interpolate import discrete_compensate +from artiq.wavesynth.coefficients import discrete_compensate class Spline: