How can I do a 2D interpolation on a regular grid?
This works (1D):
using PyPlot, Interpolations
TSR = 2.0:1.0:10.0
TSR_fine = 2.0:0.01:10.0
CP1 = sin.(TSR)
plot(TSR, CP1)
itp_cubic1 = cubic_spline_interpolation(TSR, CP1)
Cp1(λ) = itp_cubic1(λ)
plot(TSR_fine, Cp1.(TSR_fine))
Here creating the interpolation object fails:
using PyPlot, Interpolations
TSR = 2.0:0.25:10.0
Pitch = -5.0:0.5:20.0
TSR_fine = 2.0:0.01:10.0
CP = zeros(length(Pitch), length(TSR))
for (i, pitch) in pairs(Pitch), (j, tsr) in pairs(TSR)
println(i, ": ", pitch, ", ", j, ": ", tsr)
CP[i, j] = sin(tsr) + 0.25*cos(pitch)
end
plot_surface(TSR, Pitch, CP)
xlabel("TSR")
ylabel("Pitch angle")
zlabel("Cp")
itp_cubic = cubic_spline_interpolation(TSR, Pitch, CP)
It is not clear to me from the documentation which parameters the function cubic_spline_interpolation() expects.