iamlikeme / rainflow

Implementation of the rainflow-counting algorythm in Python
MIT License
105 stars 34 forks source link

Feature: Computing in Chunks #28

Closed alittlesliceoftom closed 4 years ago

alittlesliceoftom commented 4 years ago

It would be useful to have a method for computing rainflow on some timeseries, and then it storing just enough information, for you to be able to append and the computation to be updated. I.e. cycles = rainflow.count_cycles(ts1) cycles = cycles.update_cycle_count(ts2) How hard is this to do within the library?

I'd be happy to work on a PR for it, but I have only just started using this lib and rainflow, so seeking guidance.

iamlikeme commented 4 years ago

Hi, this can be accomplished using standard Python, e.g.:

from collections import defaultdict
cycles = defaultdict(float)

# You can call this multiple times to accumulate counts in the "cycles" dictionary
series = [0, -2, 1, -3, 5, -1, 3, -4, 4, -2, 0]
for rng, n in rainflow.count_cycles(series):
    cycles[rng] += n

Would this work for you?

iamlikeme commented 4 years ago

I am closing this issue due to inactivity.

alittlesliceoftom commented 4 years ago

Thanks iamlikeme. I will trial your suggestion, sorry for the delay, I missed the notification .