# [SciPy-User] ndimage.convolve

Ranjit Chacko rjchacko@gmail....
Thu Dec 10 11:48:09 CST 2009

```I want to take the laplacian of a 2-d field which has periodic boundary
conditions. I tried doing this using ndimage.convolve, but when I test this
on a simple function I don't get the result I expect. Why aren't the
boundary elements going to zero as well in the following example?

A= np.array([[x + y for x in np.arange(0,10)] for y in np.arange(0,10)])
stencil=[[0,0,-1,0,0],[0,0,16,0,0],[-1,16,-60,16,-1],[0,0,16,0,0],[0,0,-1,0,0]]
ndimage.convolve(A,stencil,mode='wrap')

array([[ 300,  140,  150,  150,  150,  150,  150,  150,  160,    0],
[ 140,  -20,  -10,  -10,  -10,  -10,  -10,  -10,    0, -160],
[ 150,  -10,    0,    0,    0,    0,    0,    0,   10, -150],
[ 150,  -10,    0,    0,    0,    0,    0,    0,   10, -150],
[ 150,  -10,    0,    0,    0,    0,    0,    0,   10, -150],
[ 150,  -10,    0,    0,    0,    0,    0,    0,   10, -150],
[ 150,  -10,    0,    0,    0,    0,    0,    0,   10, -150],
[ 150,  -10,    0,    0,    0,    0,    0,    0,   10, -150],
[ 160,    0,   10,   10,   10,   10,   10,   10,   20, -140],
[   0, -160, -150, -150, -150, -150, -150, -150, -140, -300]])

Thanks,

-Ranjit
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/scipy-user/attachments/20091210/e14e8c1d/attachment.html
```