import numpy as np
import matplotlib.pyplot as pl
import pandas as pd


from style import  *
from helper import *

import os
from scipy.optimize import curve_fit

path_data_repo = "../data_supplementary"

fig, ax = pl.subplots(nrows=1, ncols=2, figsize = (3.5 * 1.61,3),dpi = 300)
axs = ax.flatten()


data = pd.read_csv(join(path_data_repo, f"Sim_AC_shapiro_curve_f_90Hz_Im_0.7.csv"))

current = data["current"]  # in I/I_c
mu = data["mu"] / 90  # normalized to 90 Hz

ax[0].axhline(y=1, color='dimgrey', ls='--')
ax[0].axhline(y=2, color='dimgrey', ls='--')
ax[0].axhline(y=3, color='dimgrey', ls='--')



ax[0].errorbar(current,mu,**get_style(RPTU_COLORS['himbeere'],ls="--"),label=r"$I_\mathrm{m}/I_\mathrm{c}=0.7$")
ax[0].set_xlabel(r"$I/I_\mathrm{c}$")
ax[0].set_ylabel(fr"$\Delta \mu$/$h$ [Hz]")
ax[0].legend()





##########################################################

data = pd.read_csv(join(path_data_repo, f"number_excitations.csv"))
current = data["current"]  # in I/I_c
N = data["N"]


ax[1].axhline(y=1, color='dimgrey', ls='--')
ax[1].axhline(y=2, color='dimgrey', ls='--')
ax[1].axhline(y=3, color='dimgrey', ls='--')



ax[1].errorbar(current,N,**get_style(RPTU_COLORS['tag'],ls="--"),label=r"$I_\mathrm{m}/I_\mathrm{c}=0.7$")
ax[1].set_xlabel(r"$I/I_\mathrm{c}$")
ax[1].set_ylabel(fr"$N_e$")
ax[1].legend()





pl.tight_layout()
pl.show()