# Scipy position dependent interpolation as a source term

**URL:** <https://fenicsproject.discourse.group/t/scipy-position-dependent-interpolation-as-a-source-term/283>\
**Category:** Uncategorized\
**Created:** [February 25, 2019, 6:39pm UTC](https://fenicsproject.discourse.group/t/scipy-position-dependent-interpolation-as-a-source-term/283 "2019-02-25T18:39:28Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anton](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Anton](https://fenicsproject.discourse.group/u/Anton)\
**Post date:** [February 25, 2019, 6:39pm UTC](https://fenicsproject.discourse.group/t/scipy-position-dependent-interpolation-as-a-source-term/283/1 "2019-02-25T18:39:28Z")

</div>

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.
