The rainflow module

A module performing rainflow counting

Overview over pyLife’s rainflow counting module

From pyLife-2.0.0 on rainflow counting has been split into two different subtasks:

  • hysteresis loop detection, done by a subclass of AbstractDetector.

  • hysteresis loop recording, done by a subclass of AbstractRecorder.

That means you can combine detectors and recorders freely. You can choose recorders and detectors that come with pyLife but also write your own custom detectors and custom recorders.

Detectors

Detectors process a one dimensional time signal and detect hysteresis loops in them. A hysteresis loop consists of the sample point where the hysteresis starts, and the sample of the turning point where the hysteresis loop starts to turn back towards the load level of the starting point.

Once the detector has detected such a sample pair that makes a closed hysteresis loop it reports it to the recorder. All detectors report the load levels, some detectors also the index to the samples defining the loop limits.

pyLife’s detectors are implemented in a way that the samples are chunkable. That means that you don’t need to feed them the complete signal at once, but you can resume the rainflow analysis later when you have the next sample chunk.

As of now, pyLife comes with the following detectors:

  • ThreePointDetector, classic three point algorithm, reports sample index

  • FourPointDetector, recent four point algorithm, reports sample index

  • FKMDetector, algorithm described by Clormann & Seeger, recommended by FKM, does not report sample index.

Warning

Make sure you don’t have any NaN values in your input signal. They are dropped in order to make sure not to miss any hysteresis loops and thus will render the index invalid. A warning is issued by find_turns() if NaN values are dropped.

Recorders

Recorders are notified by detectors about loops and will process the loop information as they wish.

As of now, pyLife comes with the following recorders:

  • LoopValueRecorder, only records the from and to values of all the closed hysteresis loops.`

  • FullRecorder, records additionally to the from and to values also the indices of the loop turning points in the original time series, so that additional data like temperature during the loop or dwell times can be looked up in the original time series data.

API Documentation

Detectors

Recorders

Utility functions

pylife.stress.rainflow.find_turns(samples)[source]

Find the turning points in a sample chunk.

Parameters:

samples (1D numpy.ndarray) – the sample chunk

Returns:

  • index (1D numpy.ndarray) – the indices where sample has a turning point

  • turns (1D numpy.ndarray) – the values of the turning points

Notes

In case of plateaus i.e. multiple directly neighbored samples with exactly the same values, building a turning point together, the first sample of the plateau is indexed.

Warning

Any NaN values are dropped from the input signal before processing it and will thus also not appear in the turns. In those cases a warning is issued. The reason for this is, that if the NaN appears next to an actual turning point the turning point is no longer detected which will lead to an underestimation of the damage sum later in the damage calculation. Generally you should not have NaN values in your signal. If you do, it would be a good idea to clean them out before the rainflow detection.

Compatibility

The old pylife-1.x rainflow counting API

In order to not to break existing code, the old pylife-1.x API is still in place as wrappers around the new API. Using it is strongly discouraged. It will be deprecated and eventually removed.