def decimate2(x,dec=2):
Nout = int(math.floor(len(x)/dec))
idx = numpy.arange(Nout,dtype=numpy.int)*int(dec)
res = x[idx]*0.0
count = numpy.copy(x[idx])
count[:]=1.0
count_vector = numpy.negative(numpy.isnan(x))*1.0
x[numpy.where(numpy.isnan(x))] = 0.0
for i in numpy.arange(dec):
res = res + x[idx+i]
count += count_vector[idx+i]
count[numpy.where(count == 0.0)] = 1.0
return(res/count)
评论列表
文章目录