The ThreePointDetector class

class pylife.stress.rainflow.ThreePointDetector(recorder)[source]

Classic three point rainflow counting algorithm.

from pylife.stress.timesignal import TimeSignalGenerator
import pylife.stress.rainflow as RF

ts = TimeSignalGenerator(10, {
    'number': 50,
    'amplitude_median': 1.0, 'amplitude_std_dev': 0.5,
    'frequency_median': 4, 'frequency_std_dev': 3,
    'offset_median': 0, 'offset_std_dev': 0.4}, None, None).query(10000)

rfc = RF.ThreePointDetector(recorder=RF.LoopValueRecorder())
rfc.process(ts)

rfc.recorder.collective
from to
0 -2.682097 -0.991469
1 -5.558997 -3.742136
2 -5.742759 -3.662943
3 -2.403318 2.294099
4 -7.305269 -6.659921
... ... ...
1466 -20.567914 10.383529
1467 -11.100755 -11.782014
1468 -9.456125 -13.035078
1469 -4.537755 -4.415172
1470 -1.792905 -11.458148

1471 rows × 2 columns

Alternatively you can ask the recorder for a histogram matrix:

rfc.recorder.histogram(bins=16)
from                                        to                                       
(-21.201485823542242, -19.114026452831492]  (-23.58765909361489, -21.279300567736016]    0.0
                                            (-21.279300567736016, -18.97094204185714]    0.0
                                            (-18.97094204185714, -16.662583515978262]    0.0
                                            (-16.662583515978262, -14.35422499009939]    0.0
                                            (-14.35422499009939, -12.045866464220515]    0.0
                                                                                        ... 
(10.110404737119023, 12.197864107829776]    (1.804284691052736, 4.112643216931609]       0.0
                                            (4.112643216931609, 6.421001742810482]       0.0
                                            (6.421001742810482, 8.729360268689362]       0.0
                                            (8.729360268689362, 11.037718794568235]      0.0
                                            (11.037718794568235, 13.346077320447108]     0.0
Length: 256, dtype: float64

We take three turning points into account to detect closed hysteresis loops.

  • start: the point where the loop is starting from

  • front: the turning point after the start

  • back: the turning point after the front

A loop is considered closed if following conditions are met:

  • the load difference between front and back is bigger than or equal the one between start and front. In other words: if the back goes beyond the starting point. For example (A-B-C) and (B-C-D) not closed, whereas (C-D-E) is.

  • the loop init has not been a loop front in a prior closed loop. For example F would close the loops (D-E-F) but D is already front of the closed loop (C-D-E).

  • the load level of the front has already been covered by a prior turning point. Otherwise it is considered part of the front residuum.

When a loop is closed it is possible that the loop back also closes unclosed loops of the past by acting as loop back for an unclosed start/front pair. For example E closes the loop (C-D-E) and then also (A-B-E).

Load -----------------------------
|        x B               F x
--------/-\-----------------/-----
|      /   \   x D         /
------/-----\-/-\---------/-------
|    /     C x   \       /
--\-/-------------\-----/---------
|  x A             \   /
--------------------\-/-----------
|                    x E
----------------------------------
|              Time
__init__(recorder)[source]

Instantiate a ThreePointDetector.

Parameters:

recorder (subclass of AbstractRecorder) – The recorder that the detector will report to.

process(samples)[source]

Process a sample chunk.

Parameters:

samples (array_like, shape (N, )) – The samples to be processed

Returns:

self – The self object so that processing can be chained

Return type:

ThreePointDetector