from scipy import signal import matplotlib.pyplot as plt import numpy as np from IPython import embed from scipy.optimize import curve_fit from jar_functions import sin_response data = np.load('files.npy') for d in data: dd = list(d) jar = np.load('%s.npy' %dd) time = np.load('time: %s.npy' %dd) b, a = signal.butter(4, (float(d[1]) / 2) / 10000, 'high', analog=True) y = signal.filtfilt(b, a, jar - np.mean(jar)) plt.plot(time, y) #plt.plot(time, jar) sinv, sinc = curve_fit(sin_response, time, y, [float(d[1]), 2, 0.5]) print('frequency, phaseshift, amplitude:', sinv) plt.plot(time, sin_response(time, *sinv), label='fit: f=%f, p=%.2f, A=%.2f' % tuple(sinv)) # plt.legend() plt.show() embed() #betrag von A