This commit is contained in:
xaver 2020-08-05 17:16:49 +02:00
parent 47e386000f
commit 183c95cb8b
3 changed files with 57 additions and 34 deletions

View File

@ -44,5 +44,5 @@ for d in range(int(len(data)/10)):
g = [1.2917623576698833, -5.479055166593157, -2.689492238578325, -0.11604244418416806, -0.05353823781665627]
a = [0.2, 0.002, 0.02, 0.5, 1.0]
plt.plot(a, g)
plt.show()
np.save('g.npy', g)
print(np.load('g.npy'))

View File

@ -0,0 +1,28 @@
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

View File

@ -47,19 +47,13 @@ freq_all = []
amfrequencies = []
gains = []
files = []
ID = []
col = ['dimgrey', 'grey', 'darkgrey', 'silver', 'lightgrey', 'gainsboro', 'whitesmoke']
labels = zip(ID, datasets)
for infodataset in datasets:
infodataset = os.path.join(base_path, infodataset, 'info.dat')
i = parse_infodataset(infodataset)
identifier = i[0]
if not identifier[1:-2] in ID:
ID.append(identifier[1:-2])
for idx, dataset in enumerate(datasets):
datapath = os.path.join(base_path, dataset, '%s.nix' % dataset)
@ -71,16 +65,26 @@ for idx, dataset in enumerate(datasets):
nfft = 2**17
for d, dat in enumerate(data):
amfreq = float(import_amfreq(datapath))
file_name = []
for infodataset in datasets:
infodataset = os.path.join(base_path, infodataset, 'info.dat')
i = parse_infodataset(infodataset)
identifier = i[0]
if not identifier[1:-2] in ID:
ID.append(identifier[1:-2])
file_name.append(ID[0])
amfreq = import_amfreq(datapath)
print(amfreq)
amfrequencies.append(amfreq)
file_name.append(str(amfreq))
file_name = []
file_name.append(ID)
file_name.append(amfreq)
file_name.append(d)
file_name.append(str(d))
files.append(file_name)
spec, freqs, times = specgram(dat, Fs=1/dt, detrend='mean', NFFT=nfft, noverlap=nfft*0.6)
spec, freqs, times = specgram(dat, Fs=1/dt, detrend='mean', NFFT=nfft, noverlap=nfft*0.95)
dbspec = 10.0*np.log10(spec) # in dB
power = dbspec[:, 50]
@ -106,30 +110,21 @@ for idx, dataset in enumerate(datasets):
jm = jar4 - np.mean(jar4)
cut_times = times[:len(jar4)]
#np.save('%s.npy' % file_name, jar4)
np.save('time: %s.npy' % file_name, cut_times)
np.save('%s.npy' % file_name, jar4)
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.imshow(spec4, cmap='jet', origin='lower', extent=(times[0], times[-1], lim0, lim1), aspect='auto', vmin=-80, vmax=-10)
#np.save( , spec4)
embed()
b, a = signal.butter(4, 0.01 / 10000, 'high', analog=True)
y = signal.filtfilt(b, a, jm)
sinv, sinc = curve_fit(sin_response, cut_times, jm, [amfreq, 2, 0.5])
print('frequency, phaseshift, amplitude:', sinv)
gains.append(sinv[2])
plt.plot(cut_times, sin_response(cut_times, *sinv), label='fit: f=%f, p=%.2f, A=%.2f' % tuple(sinv))
#plt.legend()
#plt.ylim(lim0, lim1)
plt.legend()
plt.show()
#plt.legend()
#plt.show()
np.save('files.npy', files)
#embed()
#print(np.load('%s.npy' % file_name))
embed()
# running average over on AM-period?