I would like to create a 2D (x,y) array from a 5d function, say some kernel KMID:
import numpy as np
def KMID(x,y,mumid,delta,cmid):
rsq=(x-float(len(x))/2.+0.5)**2+(y-float(len(y))/2.+0.5)**2
return cmid*np.exp(-mumid*np.sqrt(rsq))/(rsq+delta**2)
by something like this:
shape=256,256
midscatterkernel=np.fromfunction(KMID(:,:,0.1,0.2,0.3),shape)
This gives:
SyntaxError: invalid syntax
i.e. I want to make a 2D array by iterating over just the first two indices. What is the most elegant way to do this?