pyyeti.rainflow package¶
Module contents¶
Provides C and straight Python modules for rainflow cycle counting.
A higher level interface (which uses the fast C version if available)
is provided in module pyyeti.cyclecount.
Submodules¶
pyyeti.rainflow.c_rain module¶
This module provides an interface for rainflow counting in C.
- pyyeti.rainflow.c_rain.rainflow()¶
Rainflow cycle counting, compiled C version.
Usage:
rf = rainflow(peaks, getoffsets=False)
- Parameters:
peaks (1d array_like) – Vector of alternating peaks (as returned by
pyyeti.cyclecount.findap(), for example)getoffsets (bool; optional) – If True, the tuple
(rf, os)is returned; otherwise, only rf is returned.
- Returns:
rf (2d ndarray) – n x 3 matrix with the rainflow cycle count information
[amp, mean, count]:amp is the cycle amplitude (half the peak-to-peak range)
mean is mean of the cycle
count is either 0.5 or 1.0 depending on whether it’s half or full cycle
os (2d ndarray; optional) – n x 2 matrix of cycle offsets
[start, stop]. Only returned if getoffsets is True. The start and stop values are:start is the offset into peaks for start of cycle
stop is the offset into peaks for end of cycle
Notes
This algorithm is derived from reference [1] and is very fast. The plain Python version uses the same logic.
References
Examples
Run the example from the ASTM paper:
>>> from pyyeti.rainflow.c_rain import rainflow >>> rainflow([-2, 1, -3, 5, -1, 3, -4, 4, -2]) array([[ 1.5, -0.5, 0.5], [ 2. , -1. , 0.5], [ 2. , 1. , 1. ], [ 4. , 1. , 0.5], [ 4.5, 0.5, 0.5], [ 4. , 0. , 0.5], [ 3. , 1. , 0.5]])
With offsets:
>>> rf, os = rainflow([-2, 1, -3, 5, -1, 3, -4, 4, -2], ... getoffsets=True) >>> rf array([[ 1.5, -0.5, 0.5], [ 2. , -1. , 0.5], [ 2. , 1. , 1. ], [ 4. , 1. , 0.5], [ 4.5, 0.5, 0.5], [ 4. , 0. , 0.5], [ 3. , 1. , 0.5]]) >>> os array([[0, 1], [1, 2], [4, 5], [2, 3], [3, 6], [6, 7], [7, 8]]...)
pyyeti.rainflow.py_rain module¶
Plain Python version of the rainflow algorithm. Numba
(numba.jit(nopython=True)) is used if available to achieve speeds
comparable to the compiled-c version.
- pyyeti.rainflow.py_rain.rainflow(peaks, getoffsets=False)[source]¶
Rainflow cycle counting in plain Python (slow).
- Parameters:
peaks (1d array-like) – Vector of alternating peaks (as returned by
pyyeti.cyclecount.findap(), for example)getoffsets (bool; optional) – If True, the tuple
(rf, os)is returned; otherwise, only rf is returned.
- Returns:
rf (2d ndarray) – n x 3 matrix with the rainflow cycle count information
[amp, mean, count]:amp is the cycle amplitude (half the peak-to-peak range)
mean is mean of the cycle
count is either 0.5 or 1.0 depending on whether it’s half or full cycle
os (2d ndarray; optional) – n x 2 matrix of cycle offsets
[start, stop]. Only returned if getoffsets is True. The start and stop values are:start is the offset into peaks for start of cycle
stop is the offset into peaks for end of cycle
Notes
This algorithm is derived from reference [2]. The compiled C version is preferred over this one and is very fast (the logic is the same).
References
[2] “Standard Practices for Cycle Counting in Fatigue Analysis”, ASTM E 1049 - 85 (Reapproved 2005).
Examples
Run the example from the ASTM paper:
>>> from pyyeti.rainflow.py_rain import rainflow >>> rainflow([-2, 1, -3, 5, -1, 3, -4, 4, -2]) array([[ 1.5, -0.5, 0.5], [ 2. , -1. , 0.5], [ 2. , 1. , 1. ], [ 4. , 1. , 0.5], [ 4.5, 0.5, 0.5], [ 4. , 0. , 0.5], [ 3. , 1. , 0.5]])
With offsets:
>>> rf, os = rainflow([-2, 1, -3, 5, -1, 3, -4, 4, -2], ... getoffsets=True) >>> rf array([[ 1.5, -0.5, 0.5], [ 2. , -1. , 0.5], [ 2. , 1. , 1. ], [ 4. , 1. , 0.5], [ 4.5, 0.5, 0.5], [ 4. , 0. , 0.5], [ 3. , 1. , 0.5]]) >>> os array([[0, 1], [1, 2], [4, 5], [2, 3], [3, 6], [6, 7], [7, 8]]...)