Search code examples
python-3.xinterpolationcurve-fittingcurvelinear-interpolation

Python interpolation and extracting value of z for x and y?


Would you please help I have this data where z is a function for specific x and y

xs = [0.15, 0.35, 0.5, 0.67, 0.8]
ys = [0.01,0.01, 0.01, 0.01, 0.01]
z = [0.75, 0.83, 1.00, 0.92, 0.91]

I arranged the values in this shape How can I do interpolation for the points so I can call z value later different than the the one I have?


Solution

  • tck = interpolate.bisplrep(x, y, z, s=0)
    def givemeZ(x,y):
        return interpolate.bisplev(x,y,tck)
    

    Now by running the code, it will give z for specific x and y. This can be used without plot. just put it under the values and make sure that the values are arranged in the same way