From ee82fa8490e3105729eaa4ca5549ba0c896abddc Mon Sep 17 00:00:00 2001 From: mer0m Date: Fri, 17 Feb 2017 10:03:53 +0100 Subject: [PATCH] . --- RingDown.py | 45 --------------------------------------------- 1 file changed, 45 deletions(-) delete mode 100644 RingDown.py diff --git a/RingDown.py b/RingDown.py deleted file mode 100644 index 1536196..0000000 --- a/RingDown.py +++ /dev/null @@ -1,45 +0,0 @@ -import matplotlib.pyplot as plt -import numpy as np -import csv, glob, sys -from scipy.optimize import curve_fit - -list_files = (glob.glob(sys.argv[1])) - -data = [] - -for f in list_files: - data_iter = csv.reader(open(f, 'r'), delimiter = ',', quotechar = '"') - for i in range(2): - data_iter.next() - #temp_data = [value for value in data_iter] #if ends with a number - temp_data = [value[:-1] for value in data_iter]#if ends with a comma - data.extend(temp_data) - -data = np.asarray(data, dtype = float) - -del(temp_data, list_files, value, f) - -plt.subplot(111) -plt.clf() - -plt.plot(data[data[:,0]>=0,0], data[data[:,0]>=0,1], label ='mes') - -def func(t, tau, A, w , a, b): - return A * np.exp(-t/tau) * np.sin((w+a*t)*t) + b - -popt, pcov = curve_fit(func, data[data[:,0]>=0,0], data[data[:,0]>=0,1], p0 = [1e-5, 1e-2, 1e5, 1e10, 1e-4], maxfev=10000) -yfit = func(data[data[:,0]>=0,0], *popt) - -tau = float(popt[0]) -Q = np.pi*299792458*tau/(2.*140e-3) - -#print(np.sqrt(np.diag(pcov))) -print(tau, Q) - -plt.plot(data[data[:,0]>=0,0], yfit, label ='fit') - -plt.xlabel('t') -plt.ylabel('Intensity') -plt.grid(which='both') -plt.legend() -plt.show() -- 2.16.4