84 lines
3.3 KiB
Python
84 lines
3.3 KiB
Python
import matplotlib.pyplot as plt
|
|
import matplotlib as cm
|
|
from matplotlib.colors import ListedColormap, LinearSegmentedColormap
|
|
from matplotlib.mlab import specgram
|
|
import os
|
|
import glob
|
|
import IPython
|
|
import numpy as np
|
|
import DataLoader as dl
|
|
from IPython import embed
|
|
from scipy.optimize import curve_fit
|
|
from jar_functions import parse_dataset
|
|
from jar_functions import parse_infodataset
|
|
from jar_functions import mean_traces
|
|
from jar_functions import mean_noise_cut
|
|
from jar_functions import norm_function
|
|
from jar_functions import step_response
|
|
from jar_functions import sort_values
|
|
from jar_functions import average
|
|
|
|
base_path = 'D:\\jar_project\\JAR'
|
|
|
|
#nicht: -5Hz delta f, 19-aa, 22-ae, 22-ad (?)
|
|
datasets = [#'2020-06-19-aa', #-5Hz delta f, horrible fit
|
|
#'2020-06-19-ab', #-5Hz delta f, bad fit
|
|
#'2020-06-22-aa', #-5Hz delta f, bad fit
|
|
#'2020-06-22-ab', #-5Hz delta f, bad fit
|
|
'2020-06-22-ac', #-15Hz delta f, good fit
|
|
#'2020-06-22-ad', #-15Hz delta f, horrible fit
|
|
#'2020-06-22-ae', #-15Hz delta f, horrible fit
|
|
#'2020-06-22-af' #-15Hz delta f, good fit
|
|
]
|
|
|
|
#dat = glob.glob('D:\\jar_project\\JAR\\2020*\\beats-eod.dat')
|
|
#infodat = glob.glob('D:\\jar_project\\JAR\\2020*\\info.dat')
|
|
|
|
time_all = []
|
|
freq_all = []
|
|
|
|
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]
|
|
ID.append(identifier)
|
|
|
|
|
|
for idx, dataset in enumerate(datasets):
|
|
datapath = os.path.join(base_path, dataset)
|
|
for info, key, time, data in dl.iload_traces(datapath, repro='Beats', before=0.0, after=0.0):
|
|
print( info[1]['RePro'] )
|
|
print(data.shape)
|
|
#plt.plot(time, data[0]) # V(t)
|
|
#plt.show()
|
|
nfft = 50000
|
|
nfft1 = 5000
|
|
spec, freqs, times = specgram(data[0], Fs=1.0/(time[1]-time[0]), detrend='mean', NFFT=nfft, noverlap=nfft//2)
|
|
spec1, freqs1, times1 = specgram(data[0], Fs=1.0 / (time[1] - time[0]), detrend='mean', NFFT=nfft1, noverlap=nfft1 //2)
|
|
|
|
dbspec = 10.0*np.log10(spec) # in dB
|
|
dbspec1 = 10.0 * np.log10(spec1) # in dB
|
|
print(np.min(dbspec), np.max(dbspec))
|
|
#plt.imshow(dbspec, cmap='jet', origin='lower', extent=(times[0], times[-1], freqs[0], freqs[-1]), aspect='auto', vmin=-80, vmax=-30)
|
|
plt.imshow(dbspec1, cmap='jet', origin='lower', extent=(times1[0], times1[-1], freqs1[0], freqs1[-1]), aspect='auto', vmin=-80, vmax=-30 )
|
|
# interpolation, vmin, vmax
|
|
# plot decibel as function of frequency for one time slot: wieso auflösung von frequenzen schlechter wenn nfft hoch?
|
|
# wird frequenzauflösung besser bei höherem nfft, auch da bei nfft hoch df klein und somit hohe auflösung?
|
|
# zeitliche auflösung schlechter mit größerem nfft
|
|
|
|
#for k in range(len(times)):
|
|
#plt.plot(freqs, dbspec[:,100], label = '0')
|
|
#plt.plot(freqs1, dbspec1[:, 100], label = '1')
|
|
df = freqs[1] - freqs[0]
|
|
df1 = freqs1[1] - freqs1[0]
|
|
print(df)
|
|
print(df1)
|
|
plt.legend()
|
|
plt.show()
|
|
embed()
|
|
|