Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from scipy.interpolate import interp1d
- import numpy as np
- old_time = np.linspace(0, 10, num=11, endpoint=True)
- old_vals = np.sin(old_time)
- f = interp1d(old_time, old_vals)
- f2 = interp1d(old_time, old_vals, kind='cubic')
- new_time = np.linspace(0, 10, num=1000, endpoint=True)
- new_vals = f(new_time)
- print(np.array([new_time, new_vals]).shape)
- print(new_vals)
- import matplotlib.pyplot as plt
- plt.plot(old_time, old_vals, 'o', new_time, new_vals, '-', new_time, f2(new_time), '--')
- plt.legend(['data', 'linear', 'cubic'], loc='best')
- plt.show()
Add Comment
Please, Sign In to add comment