The rainflow module#

Count rainflow cycles from load-time signals.

The rainflow package separates hysteresis-loop detection from recording. A detector implements a counting rule, for example pylife.stress.rainflow.FourPointDetector, pylife.stress.rainflow.ThreePointDetector, or pylife.stress.rainflow.FKMDetector. A recorder stores the detected loops, for example pylife.stress.rainflow.LoopValueRecorder for loop loads or pylife.stress.rainflow.FullRecorder for loop loads and sample indices.

The user-facing workflow is:

  • Create a detector, for example ThreePointDetector(). By default the detector creates its own pylife.stress.rainflow.LoopValueRecorder; pass an explicit recorder, for example pylife.stress.rainflow.FullRecorder, when sample indices or other additional data are needed.

  • Call detector.process(samples) once or repeatedly for streamed chunks.

  • Read detector.recorder.collective and pass the resulting load collective to fatigue-strength routines such as those in pylife.strength.fatigue.

This separation lets engineers combine different counting standards with the amount of recorded data they need. Detectors report closed hysteresis loops to their recorder. All detectors report load values; detectors that retain sample indices also call record_index() and report_chunk() so additional time series information can be recovered from the original signal.

Warning

Remove NaN values before rainflow counting. find_turns() drops NaN values to avoid missing loops and issues a warning, but dropping them can make reported sample indices differ from the original input.

Notes

The available detectors cover common three-point and four-point rainflow counting variants and the FKM detector after Clormann and Seeger. Repeated calls to process() continue a count, so large signals can be processed in chunks without changing the final result.

API Documentation#

Detectors#

Recorders#

Utility functions#

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

Find turning points in a sample chunk.

Parameters:

samples (numpy.ndarray) – One-dimensional sample chunk containing load values, typically in MPa.

Returns:

  • index (numpy.ndarray) – Indices where samples has a turning point.

  • turns (numpy.ndarray) – Load values at the turning points.

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.

Notes

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

Compatibility#

Provide backward-compatible shims for the pyLife 1.x rainflow API.

The classes in this module wrap the detector/recorder API introduced in pyLife 2.0. They remain available so existing code keeps working, but new code should instantiate a detector such as pylife.stress.rainflow.ThreePointDetector or pylife.stress.rainflow.FKMDetector together with a recorder such as pylife.stress.rainflow.FullRecorder.