Advertisement
Guest User

interpolation

a guest
Mar 31st, 2015
227
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.55 KB | None | 0 0
  1. import numpy
  2. import numpy as np
  3. import scipy as sp
  4. import matplotlib.pyplot as plt
  5. from scipy.interpolate import interp1d
  6.  
  7.  
  8. data = numpy.loadtxt('24march2015.txt')
  9.  
  10.  
  11. pres = data[:,0]
  12. temp = data[:,2]
  13. points = zip(pres, temp)
  14. points = sorted(points, key=lambda point: point[0])
  15. pres, temp= zip(*points)
  16. xnew = data[:,0]
  17. ynew = sp.interpolate.interp1d(pres, temp, kind= 'linear')(xnew)
  18. print(ynew)
  19. plt.plot(pres, temp, 'o', label = 'Original_data')
  20. plt.plot(xnew, ynew, '-', label = 'Interpolated_data')
  21. plt.legend()
  22. plt.legend(loc='4')
  23. plt.show()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement