使用步骤时索引错误

时间:2017-04-06 08:16:57

标签: python

import numpy as np
import os
read_path = "/home/tanvir/test/"

startFile = 1   #first file in the folder
endFile = 1000  #last file considered
freqMeas = 0.5
step = 1 if endFile <= 500 else 8
time = [freqMeas * (x + 1) for x in range(startFile, endFile + 1, step)]
Nt = np.size(time)
execfile(read_path + str(startFile) + ".py")
ndimz = np.size(phiPart)
phiPart_t = np.zeros((ndimz, Nt))

k = startFile
for k in range(startFile, endFile + 1, step):
    execfile(read_path + str(k) + ".py")
    phiPart_t[:,k] = phiPart2[:] / (phiPart[:] + 1e-6)

当我的步骤为1时,此代码运行正常,但当我的步骤为8时,它给出了IndexError:索引128超出了轴1的大小为126.我需要每隔10个而不是每个文件读取我的endfile大于500.

0 个答案:

没有答案