11.08
This commit is contained in:
parent
7174b03963
commit
2841457261
@ -163,7 +163,7 @@ def average(freq_all, time_all, start, stop, timespan, dm):
|
|||||||
|
|
||||||
values_all = sort_values(sv_all)
|
values_all = sort_values(sv_all)
|
||||||
|
|
||||||
plt.plot(tnew_all[tnew_all < 100], step_response(tnew_all, *sv_all)[tnew_all < 100], color = 'g',
|
plt.plot(tnew_all[tnew_all < dm], step_response(tnew_all, *sv_all)[tnew_all < dm], color = 'g', lw = 2,
|
||||||
label='average_fit: a1=%.2f, a2=%.2f, tau1=%.2f, tau2=%.2f' % tuple(values_all))
|
label='average_fit: a1=%.2f, a2=%.2f, tau1=%.2f, tau2=%.2f' % tuple(values_all))
|
||||||
|
|
||||||
print('average: a1, a2, tau1, tau2', values_all)
|
print('average: a1, a2, tau1, tau2', values_all)
|
||||||
|
@ -9,6 +9,7 @@ from jar_functions import sin_response
|
|||||||
def take_second(elem):
|
def take_second(elem):
|
||||||
return elem[1]
|
return elem[1]
|
||||||
|
|
||||||
|
predict = []
|
||||||
|
|
||||||
gain = []
|
gain = []
|
||||||
mgain = []
|
mgain = []
|
||||||
@ -25,12 +26,13 @@ data = sorted(np.load('files.npy'), key = take_second)
|
|||||||
for i, d in enumerate(data):
|
for i, d in enumerate(data):
|
||||||
dd = list(d)
|
dd = list(d)
|
||||||
jar = np.load('%s.npy' %dd)
|
jar = np.load('%s.npy' %dd)
|
||||||
|
jm = jar - np.mean(jar)
|
||||||
print(dd)
|
print(dd)
|
||||||
|
|
||||||
time = np.load('time: %s.npy' %dd)
|
time = np.load('time: %s.npy' %dd)
|
||||||
|
|
||||||
b, a = signal.butter(4, (float(d[1]) / 2) / 10000, 'high', analog=True)
|
b, a = signal.butter(4, (float(d[1]) / 2) / 10000, 'high', analog=True)
|
||||||
y = signal.filtfilt(b, a, jar - np.mean(jar))
|
y = signal.filtfilt(b, a, jm)
|
||||||
#plt.plot(time, y)
|
#plt.plot(time, y)
|
||||||
#plt.plot(time, jar)
|
#plt.plot(time, jar)
|
||||||
|
|
||||||
@ -41,12 +43,16 @@ for i, d in enumerate(data):
|
|||||||
gain.append(np.sqrt(sinv[2]**2))
|
gain.append(np.sqrt(sinv[2]**2))
|
||||||
amfreq.append(d[1])
|
amfreq.append(d[1])
|
||||||
|
|
||||||
|
Rs = []
|
||||||
|
for ix, t in enumerate(time):
|
||||||
|
R = (jm[ix] - sin_response(t, float(d[1]), np.sqrt(sinv[1]**2), np.sqrt(sinv[2]**2)))**2
|
||||||
|
Rs.append(R)
|
||||||
|
|
||||||
|
sigma = sum(Rs)
|
||||||
|
rms = np.sqrt((1/len(time)) * sigma)
|
||||||
#plt.plot(time, sin_response(time, *sinv), label='fit: f=%f, p=%.2f, A=%.2f' % tuple(sinv))
|
#plt.plot(time, sin_response(time, *sinv), label='fit: f=%f, p=%.2f, A=%.2f' % tuple(sinv))
|
||||||
|
|
||||||
# plt.legend()
|
#mean over same amfreqs for phase and gain
|
||||||
#plt.show()
|
|
||||||
|
|
||||||
if currf is None or currf == d[1]:
|
if currf is None or currf == d[1]:
|
||||||
currf = d[1]
|
currf = d[1]
|
||||||
idxlist.append(i)
|
idxlist.append(i)
|
||||||
@ -74,10 +80,25 @@ meanedp = np.mean(meanp)
|
|||||||
mgain.append(meanedf)
|
mgain.append(meanedf)
|
||||||
mphaseshift.append(meanedp)
|
mphaseshift.append(meanedp)
|
||||||
|
|
||||||
|
for f in amf:
|
||||||
|
G = np.max(mgain) / np.sqrt(1 + (2*((np.pi*f*3.14)**2)))
|
||||||
|
predict.append(G)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
fig = plt.figure()
|
fig = plt.figure()
|
||||||
ax = fig.add_subplot(1, 1, 1)
|
ax = fig.add_subplot(1, 1, 1)
|
||||||
ax.plot(amf, mgain, 'o')
|
ax.plot(amf, mgain, 'o')
|
||||||
|
ax.plot(amf, predict)
|
||||||
ax.set_yscale('log')
|
ax.set_yscale('log')
|
||||||
|
ax.set_xscale('log')
|
||||||
|
ax.set_title('2018lepto98')
|
||||||
|
ax.set_ylabel('gain [Hz/(mV/cm)]')
|
||||||
|
ax.set_xlabel('AM-frequency [Hz]')
|
||||||
|
#plt.savefig('2018lepto98_gain')
|
||||||
pylab.show()
|
pylab.show()
|
||||||
|
embed()
|
||||||
|
|
||||||
#betrag von A
|
#phase in degree
|
||||||
|
# Q10 / conductivity
|
||||||
|
# AM-frequency / envelope-frequency scale title?
|
@ -27,24 +27,16 @@ base_path = 'D:\\jar_project\\JAR\\sin\\2018lepto98'
|
|||||||
|
|
||||||
#dat = glob.glob('D:\\jar_project\\JAR\\2020*\\beats-eod.dat')
|
#dat = glob.glob('D:\\jar_project\\JAR\\2020*\\beats-eod.dat')
|
||||||
#infodat = glob.glob('D:\\jar_project\\JAR\\2020*\\info.dat')
|
#infodat = glob.glob('D:\\jar_project\\JAR\\2020*\\info.dat')
|
||||||
datasets = [#'2020-06-19-aa', #-5Hz delta f, horrible fit
|
datasets = ['2020-07-21-ak',
|
||||||
#'2020-06-19-ab', #-5Hz delta f, bad fit
|
'2020-07-21-al',
|
||||||
#'2020-06-22-aa', #-5Hz delta f, bad fit
|
'2020-07-21-am',
|
||||||
#'2020-06-22-ab', #-5Hz delta f, bad fit
|
'2020-07-21-an',
|
||||||
#'2020-06-22-ac', #-15Hz delta f, good fit
|
'2020-07-21-ao',
|
||||||
#'2020-06-22-ad', #-15Hz delta f, horrible fit
|
'2020-07-22-ai',
|
||||||
#'2020-06-22-ae', #-15Hz delta f, horrible fit
|
'2020-07-22-aj',
|
||||||
#'2020-06-22-af', #-15Hz delta f, good fit
|
'2020-07-22-ak',
|
||||||
'2020-07-21-al', #sin
|
'2020-07-22-al',
|
||||||
'2020-07-21-am',
|
'2020-07-22-am',
|
||||||
'2020-07-21-ak',
|
|
||||||
'2020-07-21-an',
|
|
||||||
'2020-07-21-ao',
|
|
||||||
'2020-07-22-ai',
|
|
||||||
'2020-07-22-aj',
|
|
||||||
'2020-07-22-ak',
|
|
||||||
'2020-07-22-al',
|
|
||||||
'2020-07-22-am',
|
|
||||||
]
|
]
|
||||||
|
|
||||||
time_all = []
|
time_all = []
|
||||||
@ -79,7 +71,7 @@ for idx, dataset in enumerate(datasets):
|
|||||||
i = parse_infodataset(infodataset)
|
i = parse_infodataset(infodataset)
|
||||||
identifier = i[0]
|
identifier = i[0]
|
||||||
if not identifier[1:-2] in ID:
|
if not identifier[1:-2] in ID:
|
||||||
ID.append(identifier[1:-2])
|
ID.append(identifier[1:-1])
|
||||||
file_name.append(ID[0])
|
file_name.append(ID[0])
|
||||||
|
|
||||||
amfreq = import_amfreq(datapath)
|
amfreq = import_amfreq(datapath)
|
||||||
@ -120,7 +112,7 @@ for idx, dataset in enumerate(datasets):
|
|||||||
np.save('time: %s.npy' % file_name, cut_times)
|
np.save('time: %s.npy' % file_name, cut_times)
|
||||||
np.save('%s.npy' % file_name, jar4)
|
np.save('%s.npy' % file_name, jar4)
|
||||||
|
|
||||||
plt.plot(cut_times, jm, '-k')
|
#plt.plot(cut_times, jm, '-k')
|
||||||
|
|
||||||
#cf, ct = mean_noise_cut(jar4, cut_times, n = int(round(len(jar4)/((times[-1] - times [0]) * amfreq))))
|
#cf, ct = mean_noise_cut(jar4, cut_times, n = int(round(len(jar4)/((times[-1] - times [0]) * amfreq))))
|
||||||
#plt.plot(ct, cf, '-k')
|
#plt.plot(ct, cf, '-k')
|
||||||
|
@ -16,7 +16,7 @@ from jar_functions import step_response
|
|||||||
from jar_functions import sort_values
|
from jar_functions import sort_values
|
||||||
from jar_functions import average
|
from jar_functions import average
|
||||||
|
|
||||||
base_path = 'D:\\jar_project\\JAR'
|
base_path = 'D:\\jar_project\\JAR\\step\\step_2018lepto98'
|
||||||
|
|
||||||
#nicht: -5Hz delta f, 19-aa, 22-ae, 22-ad (?)
|
#nicht: -5Hz delta f, 19-aa, 22-ae, 22-ad (?)
|
||||||
datasets = [#'2020-06-19-aa', #-5Hz delta f, horrible fit
|
datasets = [#'2020-06-19-aa', #-5Hz delta f, horrible fit
|
||||||
@ -26,8 +26,20 @@ datasets = [#'2020-06-19-aa', #-5Hz delta f, horrible fit
|
|||||||
#'2020-06-22-ac', #-15Hz delta f, good fit
|
#'2020-06-22-ac', #-15Hz delta f, good fit
|
||||||
#'2020-06-22-ad', #-15Hz delta f, horrible fit
|
#'2020-06-22-ad', #-15Hz delta f, horrible fit
|
||||||
#'2020-06-22-ae', #-15Hz delta f, horrible fit
|
#'2020-06-22-ae', #-15Hz delta f, horrible fit
|
||||||
'2020-06-22-af' #-15Hz delta f, good fit
|
#'2020-06-22-af', #-15Hz delta f, good fit
|
||||||
]
|
'2020-07-13-ad',
|
||||||
|
'2020-07-13-ae',
|
||||||
|
'2020-07-13-af',
|
||||||
|
'2020-07-13-ag',
|
||||||
|
'2020-07-13-ah',
|
||||||
|
'2020-07-13-ai',
|
||||||
|
'2020-07-13-aj',
|
||||||
|
#'2020-07-13-ak',
|
||||||
|
#'2020-07-13-al',
|
||||||
|
'2020-07-13-am',
|
||||||
|
#'2020-07-13-an',
|
||||||
|
#'2020-07-13-ao'
|
||||||
|
]
|
||||||
|
|
||||||
#dat = glob.glob('D:\\jar_project\\JAR\\2020*\\beats-eod.dat')
|
#dat = glob.glob('D:\\jar_project\\JAR\\2020*\\beats-eod.dat')
|
||||||
#infodat = glob.glob('D:\\jar_project\\JAR\\2020*\\info.dat')
|
#infodat = glob.glob('D:\\jar_project\\JAR\\2020*\\info.dat')
|
||||||
@ -68,7 +80,7 @@ for idx, dataset in enumerate(datasets):
|
|||||||
freq_all.append(cf_arr)
|
freq_all.append(cf_arr)
|
||||||
time_all.append(ct_arr)
|
time_all.append(ct_arr)
|
||||||
|
|
||||||
plt.plot(ct_arr, cf_arr, color = col[idx], label='fish=%s' % datasets[idx])
|
plt.plot(ct_arr, cf_arr, label='fish=%s' % datasets[idx]) #, color = col[idx]
|
||||||
|
|
||||||
sv, sc = curve_fit(step_response, ct_arr[ct_arr < dm], cf_arr[ct_arr < dm], [1.0, 1.0, 5.0, 50.0], bounds=(0.0, np.inf)) # step_values and step_cov
|
sv, sc = curve_fit(step_response, ct_arr[ct_arr < dm], cf_arr[ct_arr < dm], [1.0, 1.0, 5.0, 50.0], bounds=(0.0, np.inf)) # step_values and step_cov
|
||||||
|
|
||||||
@ -76,17 +88,17 @@ for idx, dataset in enumerate(datasets):
|
|||||||
values = sort_values(sv)
|
values = sort_values(sv)
|
||||||
|
|
||||||
# fit for each trace
|
# fit for each trace
|
||||||
plt.plot(ct_arr[ct_arr < dm], step_response(ct_arr[ct_arr < dm], *sv), label='fit: a1=%.2f, a2=%.2f, tau1=%.2f, tau2=%.2f' % tuple(values))
|
#plt.plot(ct_arr[ct_arr < dm], step_response(ct_arr[ct_arr < dm], *sv), label='fit: a1=%.2f, a2=%.2f, tau1=%.2f, tau2=%.2f' % tuple(values))
|
||||||
#plt.plot(ft, step_response(ft, *sv), color='orange', label='fit: a1=%.2f, a2=%.2f, tau1=%.2f, tau2=%.2f' % tuple(values))
|
#plt.plot(ft, step_response(ft, *sv), color='orange', label='fit: a1=%.2f, a2=%.2f, tau1=%.2f, tau2=%.2f' % tuple(values))
|
||||||
|
|
||||||
print('fish: a1, a2, tau1, tau2', values)
|
print('fish: a1, a2, tau1, tau2', values)
|
||||||
|
|
||||||
|
|
||||||
'''# average over all fish
|
# average over all fish
|
||||||
mf_all, tnew_all, values_all = average(freq_all, time_all, start, stop, timespan, dm)
|
mf_all, tnew_all, values_all = average(freq_all, time_all, start, stop, timespan, dm)
|
||||||
'''
|
|
||||||
|
|
||||||
const_line = plt.axhline(y = 0.632)
|
|
||||||
|
#const_line = plt.axhline(y = 0.632)
|
||||||
stimulus_duration = plt.hlines(y = -0.25, xmin = 0, xmax = 100, color = 'r', label = 'stimulus_duration')
|
stimulus_duration = plt.hlines(y = -0.25, xmin = 0, xmax = 100, color = 'r', label = 'stimulus_duration')
|
||||||
base_line = plt.axhline(y = 0, color = 'black', ls = 'dotted', linewidth = '1')
|
base_line = plt.axhline(y = 0, color = 'black', ls = 'dotted', linewidth = '1')
|
||||||
|
|
||||||
@ -99,14 +111,5 @@ plt.legend(loc = 'lower right')
|
|||||||
plt.show()
|
plt.show()
|
||||||
embed()
|
embed()
|
||||||
|
|
||||||
# norm vor mean_traces damit cutoff von -5
|
|
||||||
# average über alle fische eigentlich mal nicht nötig, auslagern
|
|
||||||
# nur bei -15 Hz messen
|
|
||||||
# bei verschiedenen amplituden messen (siehe Tim)
|
|
||||||
# natalie fragen ob sie bei verschiedenen Amplituden messen kann (siehe tim)
|
|
||||||
|
|
||||||
# Fragen:
|
# natalie fragen ob sie bei verschiedenen Amplituden messen kann (siehe tim)
|
||||||
# wie offset point wenn nicht start bei 0 sec? über zeitdatenpunkt? oder einfach immer bei 0 onset..?
|
|
||||||
# wie zip ich ID liste mit plot (für eine for schleife) zusammen?
|
|
||||||
# welche Stimulusintesität?
|
|
||||||
# start/stop/timespan ok?
|
|
||||||
|
Loading…
Reference in New Issue
Block a user