I have some fairly spaced measured data that I make a contour plot using numpy's Griddata. Griddata correlates fairly well to the actual measured parts. I am looking to extrapolate the griddata a little further beyond the measurement points. I have looked at using RBF and interp2D, however, these two methods radically change the contour profile.
Is there a way to extract the griddata (x,y,z) coordinates and feed them into the RBF function so that the contour extends and, to a degree, maintain the griddata interpolation? Or is there a different/better way?
I have tried different methods to get the griddata out, mainly from this answer, but to no success. http:// stackoverflow.com/questions/34489039/ retrieving-data-points-from-scipy-interpolate-griddata
Here is my code (Python 3.4.3):
from matplotlib.mlab import griddata
import matplotlib.pyplot as plt
import numpy as np
import scipy.interpolate as interp
#data points
x=[20,20,20,20,20,20,0,0,0,0,0,0,-20,-20,-20,-20,-20,-20]
y=[59,27,16,-16,-27,-59,59,27,16,-16,-27,-59,59,27,16,-16,-27,-59]
z=[0.212,0.2099,0.2097,0.2099,0.21,0.213,0.2117,0.209,0.2084,0.2085,0.2086,0.2113,0.2128,0.21,0.2098,0.2094,0.21,0.2114]
# define grid.
xi = np.linspace(-25, 25, 100)
yi = np.linspace(-65, 65, 100)
# grid the data.
zi = griddata(x, y, z, xi, yi, interp='linear')
#RBF Method
##xi,yi=np.meshgrid(xi, yi)
##RBFi = interp.Rbf(x, y, z, function='linear', smooth=0)
### grid the data.
##zi = RBFi(xi, yi)
#interp2D
#xi,yi=np.meshgrid(xi, yi)
##zfun_smooth_interp2d = interp.interp2d(x, y, z, kind='cubic')
##xvec = xi[0,:]
##yvec = yi[:,0]
##zi = zfun_smooth_interp2d(xvec,yvec)
plt.figure(num=None, figsize=(9.95, 16.712), dpi=80, facecolor='w', edgecolor='k')
# contour the gridded data, plotting dots at the nonuniform data points.
CS = plt.contour(xi, yi, zi, 30, linewidths=0.5, colors='k')
CS = plt.contourf(xi, yi, zi, 50, cmap=plt.cm.rainbow)
plt.colorbar() # draw colorbar
# plot data points.
plt.scatter(x, y, marker='o', c='b', s=5, zorder=10)
plt.xlim(-25, 25)
plt.ylim(-65, 65)
plt.show()
Below are the Griddata and RBF graphs that result. Griddata RBF