0

With other words I got a set of data-points (x,y,z) associated to a value b and I would like to interpolate this data as accurate as possible. Scipy.interpolate.griddata only can do a linear interpolation, what are the other options?

Odile
  • 33
  • 1
  • 10

1 Answers1

0

How about interpolating x, y, z separatly? I modified this tutorial example and added interpolation to it:

import matplotlib as mpl
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
import matplotlib.pyplot as plt
from scipy.interpolate import InterpolatedUnivariateSpline

mpl.rcParams['legend.fontsize'] = 10

# let's take only 20 points for original data:
n = 20

fig = plt.figure()
ax = fig.gca(projection='3d')
theta = np.linspace(-4 * np.pi, 4 * np.pi, n)
z = np.linspace(-2, 2, n)
r = z**2 + 1
x = r * np.sin(theta)
y = r * np.cos(theta)
ax.plot(x, y, z, label='rough curve')

# this variable represents distance along the curve:
t = np.arange(n)

# now let's refine it to 100 points:
t2 = np.linspace(t.min(), t.max(), 100)

# interpolate vector components separately:
x2 = InterpolatedUnivariateSpline(t, x)(t2)
y2 = InterpolatedUnivariateSpline(t, y)(t2)
z2 = InterpolatedUnivariateSpline(t, z)(t2)

ax.plot(x2, y2, z2, label='interpolated curve')

ax.legend()
plt.show()

The result looks like this: 3d line plot

UPDATE

Didn't understand the question at the first time, sorry.

You are probably looking for tricubic interpolation. Try this.

koxy
  • 139
  • 8
  • Thank you for the reply. Making use of parametrization isn't an option in my case because I don't know what the parametrization would be... – Odile Jul 28 '16 at 00:07
  • Yeah, i thought you need to interpolate a line. See updated answer. – koxy Jul 28 '16 at 08:03
  • Tricubic interpolation is for equally spaced coordinates, mine are scattered. Anyway, I went through a lot of different methods, and I think my only option is to do a linear interpolation and hence use scipy.interpolate.griddata(). – Odile Jul 29 '16 at 03:05