mirror of https://github.com/m-labs/artiq.git
examples/flopping_f_simulation: use numpy array in scipy curve_fit
Python lists cause problems with certain Scipy versions
This commit is contained in:
parent
3a2bd02efd
commit
47f1e3d7be
|
@ -16,6 +16,13 @@ def model(x, F0):
|
||||||
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)))
|
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)))
|
||||||
|
|
||||||
|
|
||||||
|
def model_numpy(xdata, F0):
|
||||||
|
r = np.zeros(len(xdata))
|
||||||
|
for i, x in enumerate(xdata):
|
||||||
|
r[i] = model(x, F0)
|
||||||
|
return r
|
||||||
|
|
||||||
|
|
||||||
class FloppingF(AutoDB):
|
class FloppingF(AutoDB):
|
||||||
class DBKeys:
|
class DBKeys:
|
||||||
implicit_core = False
|
implicit_core = False
|
||||||
|
@ -48,7 +55,7 @@ class FloppingF(AutoDB):
|
||||||
self.analyze()
|
self.analyze()
|
||||||
|
|
||||||
def analyze(self):
|
def analyze(self):
|
||||||
popt, pcov = curve_fit(lambda xdata, F0: [model(x, F0) for x in xdata],
|
popt, pcov = curve_fit(model_numpy,
|
||||||
self.frequency.read, self.brightness.read,
|
self.frequency.read, self.brightness.read,
|
||||||
p0=[self.flopping_freq])
|
p0=[self.flopping_freq])
|
||||||
perr = np.sqrt(np.diag(pcov))
|
perr = np.sqrt(np.diag(pcov))
|
||||||
|
|
Loading…
Reference in New Issue