我尝试修改rainflow.py以同时输出振幅,平均值和计数。 但是放大器和平均值可以相同,因此我使用以下代码来计数并保存结果。但是,这将花费5倍的时间。 如何改善我的代码并节省时间?
round_ = _get_round_function(ndigits)
am_save = []
count_save = []
for low, high, mult in extract_cycles(series, left=left, right=right):
amplitude = round_(abs(high - low)/2)
mean = round_(0.5 * (high + low))
# code added.
if [amplitude,mean] in am_save:
count_save[am_save.index([amplitude,mean])] += [mult]
else:
am_save.append([amplitude,mean])
count_save.append([mult])