I'm trying to use interp1d() from scipy to interpolate some data, but I keep hitting an out or range error. After hours of Googling, I now know that x values not in increasing order will cause the same error I'm getting but I've already made sure that's not the problem. As far as I can tell, it looks like interp1d() doesn't like decimals in the first value. Am I missing something?
A simplified version of my problem:
The following runs just fine.
import numpy as np
from scipy.interpolate import interp1d
interp1d(np.array([1, 2, 3, 4, 5, 6]),
np.array([2, 4, 6, 8, 10, 12]), kind='cubic')(np.linspace(1, 6, num=40))
But, this:
interp1d(np.array([1.1, 2.2, 3.3, 4.4, 5.5, 6.6]),
np.array([2, 4, 6, 8, 10, 12]), kind='cubic')(np.linspace(1, 6, num=40))
Returns:
ValueError: A value in x_new is below the interpolation range.
But, this works just fine.
interp1d(np.array([1.0, 2.2, 3.3, 4.4, 5.5, 6.6]),
np.array([2, 4, 6, 8, 10, 12]), kind='cubic')(np.linspace(1, 6, num=40))