1

I'm getting this error message:

Traceback (most recent call last):
  File "C:/Python27/test", line 14, in <module>
    tck = interpolate.bisplrep(X,Y,Z)
  File "C:\Python27\lib\site-packages\scipy\interpolate\fitpack.py", line 850, in bisplrep
    raise TypeError('m >= (kx+1)(ky+1) must hold')
TypeError: m >= (kx+1)(ky+1) must hold

The error says that len(X) = m is <=(kx+1)(ky+1). How can I solve this? Here's my program:

import scipy
import math
import numpy
from scipy import interpolate


x= [1000,2000,3000,4000,5000,6000]
y= [1000]

Y = numpy.array([[i]*len(x) for i in y])
X = numpy.array([x for i in y])
Z = numpy.array([[21284473.74,2574509.71,453334.97,95761.64,30580.45,25580.60]]) 

tck = interpolate.bisplrep(x,y,Z)
print interpolate.bisplev(3500,1000,tck) 
1
  • 3
    Um, are you using interpolate.bisplrep(X,Y,Z) (as your traceback says) or interpolate.bisplrep(x,y,Z) (as your code sample says)? Commented Oct 15, 2011 at 7:19

1 Answer 1

5

Have you read the documentation?

If you don't specify kx and ky, default values will be 3:

scipy.interpolate.bisplrep(x, y, z, w=None, xb=None, xe=None, yb=None, ye=None, 
                           kx=3, ky=3, task=0, s=None, eps=1e-16, tx=None, ty=None,
                           full_output=0, nxest=None, nyest=None, quiet=1)

And of course, len(X) = 6 < 16 = (3+1)(3+1).

Even if you give kx=1 and ky=1 explicitly while calling, you have another problem. Your (x,y) values form a line, and you can not define a surface from a line. Therefore it gives you ValueError: Invalid inputs.. First, you should fix your data. If this is your data, as you have no variation in Y, skip it and do a spline in 2D with X and Z.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.