Guest User

Untitled

a guest
Apr 26th, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. from scipy.interpolate import interp1d
  2. import numpy as np
  3.  
  4. old_time = np.linspace(0, 10, num=11, endpoint=True)
  5. old_vals = np.sin(old_time)
  6. f = interp1d(old_time, old_vals)
  7. f2 = interp1d(old_time, old_vals, kind='cubic')
  8.  
  9. new_time = np.linspace(0, 10, num=1000, endpoint=True)
  10.  
  11. new_vals = f(new_time)
  12.  
  13.  
  14. print(np.array([new_time, new_vals]).shape)
  15. print(new_vals)
  16. import matplotlib.pyplot as plt
  17. plt.plot(old_time, old_vals, 'o', new_time, new_vals, '-', new_time, f2(new_time), '--')
  18. plt.legend(['data', 'linear', 'cubic'], loc='best')
  19. plt.show()
Add Comment
Please, Sign In to add comment