Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Scipy interpolate warning message

Tags:

python

scipy

I am trying to fit a spline surface to some 2D data using scipy interpolate

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'm getting the following warning messages:

C:\Users...\AppData\Local\Continuum\Anaconda3\lib\site-packages\scipy\interpolate_fitpack_impl.py:975: RuntimeWarning: A theoretically impossible result when finding a smoothing spline with fp = s. Probable causes: s too small or badly 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: The required storage space exceeds the available storage space. Probable causes: nxest or nyest 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: The required storage space exceeds the available storage space. Probable causes: nxest or nyest 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: sample data

I'm getting this:spline output

I admit I don't know what the warning messages mean and haven't found anything on the internet.

like image 200
jlt199 Avatar asked Oct 15 '25 16:10

jlt199


1 Answers

Seems like your input data contains too few data points? Another issue might be that your x and y axes have very different order of magnitude. I don't know if that is a problem for bisplrep, but other interpolation algorithms do not like that.

I had more success with scipy.interpolate.Rbf, which also gives a very smooth result.

like image 55
j08lue Avatar answered Oct 18 '25 06:10

j08lue



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!