Python Scipy interpolation error warning
I am trying to fit a spline surface to some 2D data using scipy interpolation
from scipy import interpolate
Using
# fit spline to surface
xnew, ynew = np.mgrid[x[0]:x[-1]:100j, y[0]:y[-1]:100j]
tck = interpolate.bisplrep(X, Z, array)
znew = interpolate.bisplev(xnew[:,0], ynew[0,:], tck)
But I am getting the following warning messages:
C: \ Users ... \ AppData \ Local \ Continuum \ Anaconda3 \ Lib \ site-packages \ SciPy \ interpolate_fitpack_impl.py: 975: RuntimeWarning: Theoretically impossible result when searching for a smoothing spline with fp = s. Probable reasons: too small or poorly chosen eps. (Abs (FP-s) / s> 0.001) kx, ky = 3.3 nx, ny = 16.18 m = 610 fp = 18417275715.663498 s = 575.071502 warnings.warn (RuntimeWarning (_iermess2 [ierm] [0] + _mess )) C: \ Users ... \ AppData \ Local \ Continuum \ Anaconda3 \ Lib \ site-packages \ SciPy \ interpolate_fitpack_impl.py: 975: RuntimeWarning: Required storage space exceeds available storage space. Likely reasons: nxest or nyest is too small or s is too small. (FP> s) kx, ky = 3.3 nx, ny = 20.20 m = 610 fp = 661.198585 s = 575.071502 warnings.warn (RuntimeWarning (_iermess2 [ierm] [0] + _mess)) C: \ Users. ..\ AppData \ Local \ Continuum \ Anaconda3 \ Lib \ site-packages \ SciPy \ interpolate_fitpack_impl.py: 975: RuntimeWarning: Required storage space exceeds available storage space. Likely reasons: nxest or nyest is too small or s is too small. (FP> s) kx, ky = 3.3 nx, ny = 20.20 m = 610 fp = 1013.605606 s = 575.071502 warnings.warn (RuntimeWarning (_iermess2 [ierm] [0] + _mess))
And instead of getting something similar to my data:
I admit I don't know what the warning messages mean and haven't found anything on the internet.
source to share
It looks like your input contains too little data? Another problem might be that your axes x
and y
are of a very different order of magnitude. I don't know if this is a problem for bisplrep
, but other interpolation algorithms don't like it.
I've had more success with this scipy.interpolate.Rbf
, which also gives a very smooth result.
source to share