from funclib.variables import *


def sigma(s):
    return (sqrt(1- 4*M_pi**2 / s))

def jBarFunc(s):
    return np.real(1/(16*np.pi**2) * (2 + sigma(s)*np.log((sigma(s) -1)/(sigma(s) +1))))

def jBarFuncImag(s):
    return np.imag(1/(16*np.pi**2) * (2 + sigma(s)*np.log((sigma(s) -1)/(sigma(s) +1))))

energie = np.loadtxt("funclib/hodnotytus.txt")
size = len(energie) 
jBarReal = [0]*size
jBarImag = [0]*size

for i in range(size):
    jBarReal[i] = jBarFunc(energie[i])  
  
for i in range(size):
    jBarImag[i] = jBarFuncImag(energie[i])  

JBarReal = scipy.interpolate.interp1d(energie, jBarReal, fill_value='extrapolate')
JBarImag = scipy.interpolate.interp1d(energie, jBarImag, fill_value='extrapolate')

