I encountered a python issue, I tried various ways but I could not fix it. Would you offer me some hint?
sp_step = np.linspace(0.0,2.0,41) #### bin size is 50 Kpc
for jj in range(len(sp_step) -1):
if sp > sp_step[jj] and sp <= sp_step[jj+1]:
stack_num[jj] += 1
stack[jj] = map(add,stack[jj],flux_inteplt)
I define a numpy array called sp_step, what I want to do is use the variable sp to find which segment of the data is in, then I will stack the corresponding data.
But it says
if sp > sp_step[jj] and sp <= sp_step[jj+1]:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
I googled this error, tried np.logical_and, but not work.
Thanks.