#-----------------------------------------------------------
# Lecture 13 -- Practice 3 -- Interpolation (Key)
#-----------------------------------------------------------

import numpy as np
from scipy.interpolate import interp1d

# Load the data in the file 'Lec_13-Prac_3-data.dat'. Use a cubic spline 
# interpolation to get a value at x = 2.5

x_data, y_data = np.loadtxt('Lec_13-Prac_3-data.dat', unpack=True)

f_cubic = interp1d(x_data, y_data, kind='cubic')

x = 2.5
print('x = ', x, ', y = ', f_cubic(x))
