103 lines
3.1 KiB
Python
103 lines
3.1 KiB
Python
from read_baseline_data import *
|
|
from read_chirp_data import *
|
|
from utility import *
|
|
import matplotlib.pyplot as plt
|
|
import math
|
|
import numpy as np
|
|
|
|
inch_factor = 2.54
|
|
|
|
def chirp_eod_plot(df_map, eod, times):
|
|
#die äußere Schleife geht für alle Keys durch und somit durch alle dfs
|
|
#die innnere Schleife bildet die 16 Wiederholungen einer Frequenz ab
|
|
|
|
for i in df_map.keys():
|
|
freq = list(df_map[i])
|
|
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
|
|
|
|
for idx, k in enumerate(freq):
|
|
ct = times[k]
|
|
e1 = eod[k]
|
|
zeit = e1[0]
|
|
eods = e1[1]
|
|
|
|
if idx <= 1:
|
|
ax.plot(zeit, eods, color= 'darkblue')
|
|
ax.scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
|
|
#elif 4<= idx <= 7:
|
|
# axs[0, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
|
|
# axs[0, 1].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
|
|
#elif 8<= idx <= 11:
|
|
# axs[1, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25)
|
|
# axs[1, 0].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
|
|
else:
|
|
continue
|
|
#axs[1, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
|
|
#axs[1, 1].scatter(np.asarray(ct), np.ones(len(ct))*np.mean(eods), color = 'green', s= 22)
|
|
|
|
ax.set_ylabel('Amplitude [mV]', fontsize = 22)
|
|
ax.set_xlabel('Time [ms]', fontsize = 22)
|
|
ax.tick_params(axis='both', which='major', labelsize = 18)
|
|
ax.spines['right'].set_visible(False)
|
|
ax.spines['top'].set_visible(False)
|
|
fig.suptitle('EOD for chirps', fontsize = 24)
|
|
fig.tight_layout()
|
|
|
|
|
|
|
|
|
|
|
|
def cut_chirps(freq, eod, times):
|
|
ls_mod = []
|
|
ls_beat = []
|
|
for k in freq:
|
|
e1 = eod[k]
|
|
zeit = np.asarray(e1[0])
|
|
ampl = np.asarray(e1[1])
|
|
|
|
ct = times[k]
|
|
for chirp in ct:
|
|
time_cut = zeit[(zeit > chirp-10) & (zeit < chirp+10)]
|
|
eods_cut = ampl[(zeit > chirp-10) & (zeit < chirp+10)]
|
|
beat_cut = ampl[(zeit > chirp-55) & (zeit < chirp-10)]
|
|
|
|
chirp_mod = np.std(eods_cut) #Std vom Bereich um den Chirp
|
|
ls_mod.append(chirp_mod)
|
|
ls_beat.extend(beat_cut)
|
|
|
|
beat_mod = np.std(ls_beat) #Std vom Bereich vor dem Chirp
|
|
#plt.figure()
|
|
#plt.scatter(np.arange(0,len(ls_mod),1), ls_mod)
|
|
#plt.scatter(np.arange(0,len(ls_mod),1), np.ones(len(ls_mod))*beat_mod, color = 'violet')
|
|
return(ls_mod, beat_mod)
|
|
|
|
|
|
|
|
|
|
|
|
def plot_std_chirp(sort_df, df_map, chirp_spikes, chirp_mods):
|
|
|
|
fig, ax = plt.subplots(figsize=(20/inch_factor, 10/inch_factor))
|
|
dct_phase = {}
|
|
num_bin = 12
|
|
phase_vec = np.arange(0, 1+1/num_bin, 1/num_bin)
|
|
|
|
for i in sort_df:
|
|
freq = list(df_map[i])
|
|
dct_phase[i] = []
|
|
for k in freq:
|
|
for phase in chirp_spikes[k]:
|
|
dct_phase[i].append(phase[1])
|
|
|
|
for i in sort_df:
|
|
norm = np.asarray(dct_phase[i]) *2*math.pi
|
|
plt.scatter(norm, chirp_mods[i], label = i, s = 22)
|
|
plt.title('Change of std depending on the phase where the chirp occured', fontsize = 24)
|
|
plt.xlabel('Phase', fontsize = 22)
|
|
plt.ylabel('Standard deviation of the amplitude modulation', fontsize = 22)
|
|
plt.xticks([0, math.pi/2, math.pi, math.pi*1.5, math.pi*2], ('0', '$\pi$ /2', '$\pi$', '1.5 $\pi$', '2$\pi$'))
|
|
plt.tick_params(axis='both', which='major', labelsize = 18)
|
|
plt.legend()
|
|
return(dct_phase)
|
|
|