I´m trying to interpolate data from a 2D array in python using scipy.interpolate.interp2d. However, I don´t think I fully understand what it is doing ,so any help is appreciated. I am trying to do something similar to what is suggested here Link.
My code is below:
%matplotlib inline
import matplotlib.pyplot as plt
import numpy as np
from scipy import interpolate
from scipy.interpolate import griddata
p = np.array([[1,2,3,4,5,6,7,8,9,1],[1,2,3,4,5,6,7,8,9,1],
[1,6,3,4,8,6,7,8,9,1],[1,2,3,4,5,6,7,89,9,1],
[1,56,3,4,5,6,7,67,6,1],[1,2,3,4,7,6,7,8,9,1],
[1,2,3,5,5,6,7,6,9,1],[1,2,3,6,5,6,7,45,9,1],
[9,2,3,4,21,6,7,8,9,1],[1,8,3,3,5,6,7,5,9,1]])
print(pf)
mymin, mymax = 0, 9
X = np.linspace(mymin,mymax,10)
Y = np.linspace(mymin,mymax,10)
Xnew = np.linspace(mymin,mymax,20)
Ynew = np.linspace(mymin,mymax,20)
f = interpolate.interp2d(x,y,p,kind='cubic')
Po = f(Xnew,Ynew)
print(Po)
When I run it, the following error message is displayed:
ValueError: Invalid length for input z for non rectangular grid