Counting matrix
[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.style.use( "default" )
plt.rcParams[ "figure.dpi" ] = 80
plt.rcParams[ "font.family" ] = "Times New Roman"
plt.rcParams[ "font.size" ] = '14'
Counting results to counting matrix
Function countingRstToCountingMatrix
returns the cycle counting matrix and corresponding index from the cycle counting results.
Function help
[2]:
from ffpack.utils import countingRstToCountingMatrix
help( countingRstToCountingMatrix )
Help on function countingRstToCountingMatrix in module ffpack.utils.lsmUtils:
countingRstToCountingMatrix(countingRst)
Calculate counting matrix from rainflow counting result.
Parameters
----------
countingRst: 2d array
Cycle counting result in form of [ [ rangeStart1, rangeEnd1, count1 ],
[ rangeStart2, rangeEnd2, count2 ], ... ].
Returns
-------
rst: 2d array
A matrix contains the counting results.
matrixIndexKey: 1d array
A sorted array contains the index keys for the counting matrix.
Raises
------
ValueError
If the data dimension is not 2.
If the data is not empty and not in dimension of n by 3.
Examples
--------
>>> from ffpack.lsm import countingRstToCountingMatrix
>>> countingRst = [ [ -2.0, 1.0, 1.0 ], [ 5.0, -1.0, 3.0 ], [ -4.0, 4.0, 0.5 ] ]
>>> rst, matrixIndexKey = countingRstToCountingMatrix( countingRst )
Example with default values
[3]:
cctcmRst = [ [ -2.0, 1.0, 1.0 ], [ 5.0, -1.0, 3.0 ], [ -4.0, 4.0, 0.5 ] ]
cctcmMat, cctcmMatIndexKey = countingRstToCountingMatrix( cctcmRst )
cctcmMat = np.array( cctcmMat )
cctcmMatIndex = np.array( cctcmMatIndexKey ).astype( float )
[4]:
print( "Cycle counting matrix" )
print( cctcmMat )
print()
print( "Matrix index" )
print( cctcmMatIndex )
Cycle counting matrix
[[0. 0. 0. 0. 0.5 0. ]
[0. 0. 0. 1. 0. 0. ]
[0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. ]
[0. 0. 3. 0. 0. 0. ]]
Matrix index
[-4. -2. -1. 1. 4. 5.]