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 -0.586713 3.549904
1 6.772226 1.763071
2 3.418900 3.739750
3 -5.229096 3.944239
4 6.254093 -0.332176
... ... ...
1298 11.332635 -8.117715
1299 13.344291 -8.737224
1300 3.368547 4.886267
1301 -1.616053 1.905559
1302 -3.356402 4.521986

1303 rows × 2 columns

Alternatively you can ask the recorder for a histogram matrix:

rfc.recorder.histogram(bins=16)
from                                        to                                        
(-15.901632780948134, -13.714092673884647]  (-15.662280067971121, -13.394891726841783]    0.0
                                            (-13.394891726841783, -11.127503385712444]    0.0
                                            (-11.127503385712444, -8.860115044583106]     0.0
                                            (-8.860115044583106, -6.592726703453767]      0.0
                                            (-6.592726703453767, -4.325338362324429]      0.0
                                                                                         ... 
(16.911468825004164, 19.09900893206765]     (9.2789916844516, 11.546380025580941]         0.0
                                            (11.546380025580941, 13.813768366710281]      0.0
                                            (13.813768366710281, 16.081156707839618]      0.0
                                            (16.081156707839618, 18.348545048968955]      0.0
                                            (18.348545048968955, 20.615933390098295]      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