12. Data Analysis http://www.scipy.org http://numpy.scipy.org
13. SciPy & NumPyExample importscipy.optimize #Define the model to befitted fitfunc= lambda p, x: p[0]+p[1]* exp(-x*abs(p[2]))*cos(p[3]+p[4]*x) #Define the errorfunction errfunc = lambda p, x, y: fitfunc(p, x)– y #Make a fit by minimizing the errorfunction p1 = scipy.optimize.fmin(lambdap,x,y: norm(errfunc(p,x,y)), p0, args=(data [:,0], data[:,1])) #Print the returnedparameters print p1 #Plot the data and the fit… plot(data[:,0], data[:,1], "ro", data[:,0], fitfunc(p1, data[:,0]), "b-") #Add a legend legend(("data","fit")) #Add a title title("Ramsey - $V_{fluxline}= %d mV$, $T_2 = %d$ ns, $A = %f$ " % (int(voltage) , abs(int(1.0/p1[2])),p1[1]))