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: f94aa4927600
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: ef32e7aa7a44
Choose a head ref
  • 2 commits
  • 3 files changed
  • 1 contributor

Commits on Jan 21, 2015

  1. Copy the full SHA
    0983862 View commit details
  2. Copy the full SHA
    ef32e7a View commit details
Showing with 21 additions and 9 deletions.
  1. +1 −0 artiq/protocols/pyon.py
  2. +19 −8 examples/flopping_f_simulation.py
  3. +1 −1 examples/pdb.pyon
1 change: 1 addition & 0 deletions artiq/protocols/pyon.py
Original file line number Diff line number Diff line change
@@ -159,6 +159,7 @@ def store_file(filename, x):
contents = encode(x, True)
with open(filename, "w") as f:
f.write(contents)
f.write("\n")


def load_file(filename):
27 changes: 19 additions & 8 deletions examples/flopping_f_simulation.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
from math import sqrt, cos, pi
import time
import random

import numpy as np
from scipy.optimize import curve_fit

from artiq import *


def model(x, F0=1500, A=80, B=40, t=0.02, tpi=0.03):
def model(x, F0):
t = 0.02
tpi = 0.03
A = 80
B = 40
return A+(B-A)/2/(4*tpi**2*(x-F0)**2+1)*(1-cos(pi*t/tpi*sqrt(4*tpi**2*(x-F0)**2+1)))


@@ -16,6 +24,9 @@ class DBKeys:
min_freq = Argument(1000)
max_freq = Argument(2000)

F0 = Argument(1500)
noise_amplitude = Argument(0.1)

frequency = Result()
brightness = Result()

@@ -30,16 +41,16 @@ def realtime_results():
def run(self):
for i in range(self.npoints):
frequency = (self.max_freq-self.min_freq)*i/(self.npoints - 1) + self.min_freq
brightness = model(frequency)
brightness = model(frequency, self.F0) + self.noise_amplitude*random.random()
self.frequency.append(frequency)
self.brightness.append(brightness)
time.sleep(0.1)
self.analyze()

def analyze(self):
min_f = self.frequency.read[0]
min_b = self.brightness.read[0]
for f, b in zip(self.frequency.read, self.brightness.read):
if b < min_b:
min_f, min_b = f, b
self.flopping_freq = min_f
popt, pcov = curve_fit(lambda xdata, F0: [model(x, F0) for x in xdata],
self.frequency.read, self.brightness.read,
p0=[self.flopping_freq])
perr = np.sqrt(np.diag(pcov))
if perr < 0.1:
self.flopping_freq = float(popt)
2 changes: 1 addition & 1 deletion examples/pdb.pyon
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{}
{"flopping_freq": 1500.0294421161527}