I have a set of data that is not smooth. Hence I'm trying to interpolate it with the generated mesh.
import numpy as np
data=np.loadtxt('test.txt')
x=data[:,0] #len(x) = 730
y=data[:,1]
Nx= len(x)
Ny=len(y)
del_x= 0.5
xn = np.linspace(0,Nx,2000)
yn = np.linspace(0,Ny,2000)
#loop
for i in range(0,Nx-1):
if x[i] > xn[i] and x[i] < xn[i+1]:
new_x= (i + (xn[i] - x[i])/(xn[i]-xn[i+1]))*del_x
print new_x
I would like to perform the loop that basically does the operation i.e : if my original data x[i] is in between the two grid points xn[i],xn[i+1], then compute new_x.
But I get the following error
Traceback (most recent call last):
File "new.py", line 27, in <module>
if x[i] > xn[i] and x[i] < xn[i+1]:
IndexError: index out of bound
Can someone help me out ?