Vetor_nascer=[]
Vetor_ocasso=[]
cos=ang_zenital_cos(lat, long, dj, horas)
cos=cos[indices_hora_i]
for i in range(len(indices_hora_i)):
if cos[i]<0 and cos[i+1]>0:
Vetor_nascer=np.append(Vetor_nascer,indices_hora_i[i])
elif cos[i]>0 and cos[i+1]<0:
Vetor_ocasso=np.append(Vetor_ocasso,indices_hora_i[i])
Hey guys how can I make this not return the error out of boundI'm trying make vector so I can index a specific set of data I I need to make mark when cos(1)=- and cos(2)=+How can I do to so it does not give me a error?
你的循环试图访问数组的边界外,你可以少循环一次。
for i in range(len(indices_hora_i)-1):
if cos[i]<0 and cos[i+1]>0:
Vetor_nascer=np.append(Vetor_nascer,indices_hora_i[i])
elif cos[i]>0 and cos[i+1]<0:
Vetor_ocasso=np.append(Vetor_ocasso,indices_hora_i[i])
我是用反向索引来解决的
所以我知道我的数据有29760的大小,所以我只是写而不是它的工作。(我只是不知道是否有一个更快的解决方案的整体周期)
cos[i]<0 and cos[i-29759]>0: