89 lines
2.2 KiB
Python
89 lines
2.2 KiB
Python
import matplotlib.pyplot as plt
|
|
import os
|
|
import glob
|
|
import IPython
|
|
import numpy as np
|
|
from IPython import embed
|
|
from jar_functions import parse_dataset
|
|
from jar_functions import mean_noise_cut
|
|
from jar_functions import step_response
|
|
|
|
|
|
datasets = [(os.path.join('D:\\jar_project\\JAR\\2020-06-22-ac\\beats-eod.dat'))]
|
|
|
|
eodf = []
|
|
deltaf = []
|
|
stimulusf = []
|
|
|
|
time = []
|
|
frequency_mean= []
|
|
amplitude = []
|
|
|
|
start = -10
|
|
stop = 200
|
|
timespan = 210
|
|
|
|
for dataset in datasets:
|
|
#input of the function
|
|
t, f, a, e, d, s= parse_dataset(dataset)
|
|
|
|
minimumt = min(len(t[0]), len(t[1]))
|
|
# new time with wished timespan because it varies for different loops
|
|
tnew = np.arange(start, stop, timespan / minimumt) # 3rd input is stepspacing:
|
|
# in case complete measuring time devided by total number of datapoints
|
|
# interpolation
|
|
f0 = np.interp(tnew, t[0], f[0])
|
|
f1 = np.interp(tnew, t[1], f[1])
|
|
|
|
#new array with frequencies of both loops as two lists put together
|
|
frequency = np.array([f0, f1])
|
|
|
|
#making a mean over both loops with the axis 0 (=averaged in y direction, axis=1 would be over x axis)
|
|
mf = np.mean(frequency, axis=0)
|
|
|
|
#appending data
|
|
eodf.append(e)
|
|
deltaf.append(d)
|
|
stimulusf.append(s)
|
|
amplitude.append(a)
|
|
frequency_mean.append(mf)
|
|
time.append(tnew)
|
|
|
|
for i in range(len(frequency_mean)):
|
|
for n in [10, 50, 100, 1000, 10000, 20000, 30000]:
|
|
cf, ct = mean_noise_cut(frequency_mean[i], time[i], n=n)
|
|
#plt.plot(ct, cf, label='n=%d' % n)
|
|
|
|
ct_array = np.array(ct) +10
|
|
|
|
r_step = step_response(t=ct_array, a1=0.58, a2=0, tau1=100, tau2=100)
|
|
|
|
#plt.plot(r_step)
|
|
|
|
|
|
for a in [0, 1, 2]:
|
|
for b in [0, 1, 2]:
|
|
r_step = step_response(t = ct_array, a1 = a, a2 = b, tau1 = 30, tau2 = 60)
|
|
|
|
|
|
plt.plot(time[0], frequency_mean[0])
|
|
plt.show()
|
|
embed()
|
|
|
|
|
|
'plotting'
|
|
plt.xlim([-10,200])
|
|
#plt.ylim([400, 1000])
|
|
plt.xlabel('time [s]')
|
|
#plt.ylabel('rel. JAR magnitude')
|
|
#plt.title('fit_function(a1=0)')
|
|
#plt.savefig('fit_function(a1=0)')
|
|
plt.legend()
|
|
plt.show()
|
|
|
|
|
|
|
|
# normiert darstellen (frequency / mean von baseline frequency?)?
|
|
# Zeitkonstante: von sec. 0 bis 63%? relative JAR
|
|
|