# spectral function = imaginary part of G:
epsilon = eps_inf
# Which mode are we interested in?
for s_mode in (3, 4):
# angular frequency:
ws = df_intensity.frequency.iloc[s_mode]
Z = df_intensity.Z_x.iloc[s_mode]
S = Z ** 2 * df_intensity.prefactor.iloc[s_mode]
G_imag = np.pi * ds.spectralfunction_per_mode[s_mode]
# KK to get real
G_real = get_kk_real(xs=ds.frequency, ys=G_imag)
# the full G
G = G_real + 1.0j * G_imag
pref = ws / 2 # makes G(0) -> ~1
# full dielectric function
epsilon += S * pref * G
https://github.com/tdep-developers/tdep-tutorials/blob/5cb55c44c622c32e7f6e638fd9b3ed75fec7a6e9/06_Infrared/example_MgO/IR/notebook_get_ir.ipynb#L66