The FourPointDetector class

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

Implements four 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.FourPointDetector(recorder=RF.LoopValueRecorder())
rfc.process(ts)

rfc.recorder.collective
from to
0 -3.027155 1.529664
1 6.339682 -3.435317
2 6.759915 4.673201
3 -1.499056 8.590498
4 -2.471319 0.563860
... ... ...
939 -0.822303 11.568156
940 -5.242509 8.854103
941 7.924894 -1.254262
942 13.554216 -5.407613
943 13.603299 -7.993273

944 rows × 2 columns

Alternatively you can ask the recorder for a histogram matrix:

rfc.recorder.histogram(bins=16)
from                                        to                                      
(-16.905043461311244, -14.634937162110969]  (-16.423510005103786, -14.2140721231021]    0.0
                                            (-14.2140721231021, -12.004634241100415]    0.0
                                            (-12.004634241100415, -9.79519635909873]    0.0
                                            (-9.79519635909873, -7.585758477097045]     0.0
                                            (-7.585758477097045, -5.376320595095359]    0.0
                                                                                       ... 
(17.14655102669289, 19.41665732589317]      (7.880306696914751, 10.089744578916438]     0.0
                                            (10.089744578916438, 12.299182460918125]    0.0
                                            (12.299182460918125, 14.508620342919809]    0.0
                                            (14.508620342919809, 16.718058224921492]    0.0
                                            (16.718058224921492, 18.927496106923176]    0.0
Length: 256, dtype: float64

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

Consider four consecutive peak/valley points say, A, B, C, and D If B and C are contained within A and B, then a cycle is counted from B to C; otherwise no cycle is counted.

i.e, If X Y AND Z Y then a cycle exist FROM = B and TO = C where, ranges X = |D–C|, Y = |C–B|, and Z = |B–A|

Load -----------------------------
|        x B               F x
--------/-\-----------------/-----
|      /   \   x D         /
------/-----\-/-\---------/-------
|    /     C x   \       /
--\-/-------------\-----/---------
|  x A             \   /
--------------------\-/-----------
|                    x E
----------------------------------
|              Time

So, if a cycle exsist from B to C then delete these peaks from the turns array and perform next iteration by joining A&D else if no cylce exsists, then B would be the next strarting point.

__init__(recorder)[source]

Instantiate a FourPointDetector.

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

FourPointDetector