Scipy position dependent interpolation as a source term

Hello,

I am trying to solve Poisson’s equation with a source term, scr, that ought to take as arguments (u,x[0],x[1]), and return interpolate.splev(1.0+2*x[0], tck_max)*function(value of u at (x[0],x[1]), where tck_max is the result of interpolate.bisplrep(x, y, z, s=0.1) for some x,y,z that I get from data files. u is the TrialFunction I’m using.

I am not quite sure how to implement this in FEniCS however. A naive approach of

def src(u,x):
return interpolate.splev(theta_min+(theta_max-theta_min)*((x[0]+Lx/2)/Lx), tck_max)*f(u)

Returns the error

TypeError: cannot unpack non-iterable interp1d object

Any idea on how to implement this? Thanks.