I am trying to relate the python/numpy indices of two arrays with different sizes, but I cannot pass index one from the small array to the large array through a subroutine.
For example, I have two numpy arrays: a1
and a2
. a1.shape = (240,33,258)
and a2.shape = (240,40,33,258)
. I am finding indices in a1 and relating these indices to a2
. ie., index1 = numpy.where(a > n)
. I can grab the data that I an interested in using
dat1 = a1[index]
dat2 = a2[index[0],:,index[1],index[2]]
with the resulting dat shapes as dat1.shape = (n)
and dat2.shape = (n, 40)
. To speed up the program, I want to pass the index through a subroutine, but I cannot pass [index[0],:,index[1],index[2]]
through a subroutine because I cannot pass the colon ':'.
I believe my solution would be to pass the numerical equivalent to ':' in the subroutine, but I have not found an answer.
Any help?
Thank you very much
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…