Four pointing counting method

[1]:
# Import auxiliary libraries for demonstration

import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np

plt.rcParams[ "figure.figsize" ] = [ 5, 4 ]

plt.rcParams[ "figure.dpi" ] = 80
plt.rcParams[ "font.family" ] = "Times New Roman"
plt.rcParams[ "font.size" ] = '14'

Four pointing rainflow counting

Function fourPointRainflowCounting implements the four pointing counting method in the book by Lee et al.

Reference:

  • Lee, Y.L., Barkey, M.E. and Kang, H.T., 2011. Metal fatigue analysis handbook: practical problem-solving techniques for computer-aided engineering. Elsevier.

Function help

[2]:
from ffpack.lcc import fourPointRainflowCounting
help( fourPointRainflowCounting )
Help on function fourPointRainflowCounting in module ffpack.lcc.fourPointCounting:

fourPointRainflowCounting(data, aggregate=True)
    Four point rainflow counting in [Lee2011]_.

    Parameters
    ----------
    data: 1d array
        Load sequence data for counting.
    aggragate: bool, optional
        If aggregate is set to False, the original sequence for internal counting,
        e.g., [ [ rangeStart1, rangeEnd1, count1 ],
        [ rangeStart2, rangeEnd2, count2 ], ... ], will be returned.

    Returns
    -------
    rst: 2d array
        Sorted counting results.

    Raises
    ------
    ValueError
        If the data length is less than 4 or the data dimension is not 1.

    Examples
    --------
    >>> from ffpack.lcc import fourPointRainflowCounting
    >>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
    >>> rst = fourPointRainflowCounting( data )

    References
    ----------
    .. [Lee2011] Lee, Y.L., Barkey, M.E. and Kang, H.T., 2011. Metal fatigue analysis
       handbook: practical problem-solving techniques for computer-aided engineering.
       Elsevier.

Example with default values

[3]:
fpcSequenceData = [ -0.8, 1.3, 0.7, 3.4, 0.7, 2.5, -1.4, -0.5, -2.3,
                   -2.2, -2.6, -2.4, -3.3, 1.5, 0.6, 3.4, -0.5 ]

fpcResults = fourPointRainflowCounting( fpcSequenceData )
[4]:
print( fpcResults )
[[0.1, 1.0], [0.2, 1.0], [0.6, 1.0], [0.9, 2.0], [1.8, 1.0]]
[5]:
fig, ( ax1, ax2 ) = plt.subplots( 1, 2, figsize=( 10, 4 ) )

ax1.plot( fpcSequenceData, "o-" )

ax1.tick_params( axis='x', direction="in", length=5 )
ax1.tick_params( axis='y', direction="in", length=5 )
ax1.set_ylabel( "Load units" )
ax1.set_xlabel( "Data points" )
ax1.set_title( "Sequence data" )

ax2.barh( np.array( fpcResults )[ :, 0 ],
          np.array( fpcResults )[ :, 1 ] )

ax2.tick_params( axis='x', direction="in", length=5 )
ax2.tick_params( axis='y', direction="in", length=5 )
ax2.set_ylabel( "Load range units" )
ax2.set_xlabel( "Counts" )
ax2.set_title( "Four point rainflow counting" )

plt.tight_layout()
plt.show()
../_images/moduleCookbook_lccFourPointingCountingMethod_9_0.png