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 5.874740 -9.179378
1 6.203362 6.090421
2 5.326259 7.747397
3 10.618540 -3.924925
4 1.014282 3.204964
... ... ...
1433 0.121752 7.884685
1434 -0.607835 3.584166
1435 -1.909704 9.221190
1436 11.914471 -2.636707
1437 3.103095 3.260220

1438 rows × 2 columns

Alternatively you can ask the recorder for a histogram matrix:

rfc.recorder.histogram(bins=16)
from                                       to                                       
(-12.171900537478548, -10.14264490749108]  (-10.656109724093943, -8.800311668512272]    0.0
                                           (-8.800311668512272, -6.944513612930602]     0.0
                                           (-6.944513612930602, -5.088715557348932]     0.0
                                           (-5.088715557348932, -3.232917501767261]     0.0
                                           (-3.232917501767261, -1.3771194461855902]    0.0
                                                                                       ... 
(18.266933912333464, 20.29618954232093]    (9.757668887304431, 11.6134669428861]        0.0
                                           (11.6134669428861, 13.469264998467773]       0.0
                                           (13.469264998467773, 15.325063054049442]     0.0
                                           (15.325063054049442, 17.180861109631117]     0.0
                                           (17.180861109631117, 19.036659165212782]     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, flush=False)[source]

Process a sample chunk.

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

  • flush (bool) –

    Whether to flush the cached values at the end.

    For explanations see process()

Returns:

self – The self object so that processing can be chained

Return type:

ThreePointDetector