I'm trying to find if there's a convenient equivalent to mapslices function from the Julia language to Python. Here's the line I'm trying to convert:
line_center = float64(mapslices(x->sum(x.^4.*[1:length(x)])./sum(x.^4),no_background,1)[:])
For anyone wondering, here's an answer.
def exp_func(x):
return np.dot(np.arange(len(x)), np.power(x, 4))/(np.sum(np.power(x, 4)))
result = np.apply_along_axis(exp_func,axis = 0,array)
exp_func takes 1-D arrays.