from read_baseline_data import *
from read_chirp_data import *
from utility import *
import matplotlib.pyplot as plt
import numpy as np


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,axs = plt.subplots(2, 2, sharex = True, sharey = True)

	for idx, k in enumerate(freq):
		ct = times[k]
		e1 = eod[k]
		zeit = e1[0]
		eods = e1[1]
	
		if idx <= 3:
			axs[0, 0].plot(zeit, eods, color= 'blue', linewidth = 0.25)
			axs[0, 0].scatter(np.asarray(ct), np.ones(len(ct))*3, 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))*3, 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))*3, color = 'green', s= 22)
		else: 
			axs[1, 1].plot(zeit, eods, color= 'blue', linewidth = 0.25)
			axs[1, 1].scatter(np.asarray(ct), np.ones(len(ct))*3, color = 'green', s= 22)

fig.suptitle('EOD for chirps', fontsize = 16)
axs[0,0].set_ylabel('Amplitude [mV]') 
axs[0,1].set_xlabel('Amplitude [mV]')
axs[1,0].set_xlabel('Time [ms]')
axs[1,1].set_xlabel('Time [ms]')
plt.show()

