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 1.381179 1.768519
1 -2.215542 4.682198
2 0.120604 6.653684
3 6.431858 6.925821
4 10.179380 4.726965
... ... ...
1112 4.739724 10.360041
1113 3.763215 8.234502
1114 -0.373044 15.018183
1115 7.502908 -0.267378
1116 15.494997 -1.327840

1117 rows × 2 columns

Alternatively you can ask the recorder for a histogram matrix:

rfc.recorder.histogram(bins=16)
from                                       to                                       
(-12.51003243914582, -10.352995439232288]  (-13.17952936749884, -10.945447132584722]    0.0
                                           (-10.945447132584722, -8.711364897670602]    0.0
                                           (-8.711364897670602, -6.4772826627564815]    0.0
                                           (-6.4772826627564815, -4.243200427842362]    0.0
                                           (-4.243200427842362, -2.009118192928243]     0.0
                                                                                       ... 
(19.845522559557185, 22.00255955947072]    (11.395375216556474, 13.629457451470596]     0.0
                                           (13.629457451470596, 15.863539686384716]     0.0
                                           (15.863539686384716, 18.097621921298835]     0.0
                                           (18.097621921298835, 20.331704156212954]     0.0
                                           (20.331704156212954, 22.565786391127073]     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