def interpolate(x,y,z, gridsize,mode='thin_plate',rbfmode=True,shape=None):

		mode=str(mode)
		grids=gridsize


		dx=np.max(x)-np.min(x)
		dy=np.max(y)-np.min(y)

		if dx>dy:
			gridx=grids
			gridy=int(round(dy/dx*grids))
		else:
			gridy=grids
			gridx=int(round(dx/dy*grids))

		if shape != None:
			(gridy,gridx)=shape

		xi, yi = np.linspace(np.min(x), np.max(x), gridx), np.linspace(np.min(y), np.max(y), gridy)
		xi, yi = np.meshgrid(xi, yi)


		if rbfmode:
			rbf = scipy.interpolate.Rbf(x, y, z, function=mode)
			rbf2 = scipy.interpolate.Rbf( y,x, z, function=mode)
		else:
			sayErr("interp2d nicht implementiert")
			x=np.array(x)
			y=np.array(y)
			z=np.array(z)
			xi, yi = np.linspace(np.min(x), np.max(x), gridx), np.linspace(np.min(y), np.max(y), gridy)

			rbf = scipy.interpolate.interp2d(x, y, z, kind=mode)
			rbf2 = scipy.interpolate.interp2d(y, x, z, kind=mode)

		zi=rbf2(yi,xi)
		return [rbf,xi,yi,zi]