Cycle counting matrix
[1]:
# Import auxiliary libraries for demonstration
import matplotlib as mpl
import matplotlib.pyplot as plt
import numpy as np
import warnings
plt.rcParams[ "figure.figsize" ] = [ 5, 4 ]
plt.rcParams[ "figure.dpi" ] = 80
plt.rcParams[ "font.family" ] = "Times New Roman"
plt.rcParams[ "font.size" ] = '14'
# Filter the plot warning
warnings.filterwarnings( "ignore" )
ASTM simple range counting matrix
Function help
[2]:
from ffpack.lsm import astmSimpleRangeCountingMatrix
help( astmSimpleRangeCountingMatrix )
Help on function astmSimpleRangeCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
astmSimpleRangeCountingMatrix(data, resolution=0.5)
Calculate ASTM simple range counting matrix.
Parameters
----------
data: 1d array
Sequence data to calculate range counting matrix.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0.
Examples
--------
>>> from ffpack.lsm import astmSimpleRangeCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = astmSimpleRangeCountingMatrix( data )
Example with default values
[3]:
asrcmData = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
asrcmMat, asrcmIndex = astmSimpleRangeCountingMatrix( asrcmData )
asrcmMat = np.array( asrcmMat )
asrcmIndex = np.array( asrcmIndex ).astype( float )
[4]:
print( "ASTM simple range counting matrix" )
print( asrcmMat )
print()
print( "Matrix index" )
print( asrcmIndex )
ASTM simple range counting matrix
[[0. 0. 0. 0. 0. 0. 0.5 0. ]
[0. 0. 0. 0. 0. 0. 0. 0.5]
[0. 0. 0. 0. 0.5 0. 0. 0. ]
[0. 0. 0. 0. 0. 0.5 0. 0. ]
[0. 0.5 0. 0. 0. 0. 0. 0. ]
[0.5 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0.5 0. 0. 0. 0. 0. ]
[0. 0. 0. 0.5 0. 0. 0. 0. ]]
Matrix index
[-4. -3. -2. -1. 1. 3. 4. 5.]
[5]:
plt.set_cmap( "viridis_r" )
fig, ax = plt.subplots()
cax = ax.matshow( asrcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + asrcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + asrcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( asrcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( asrcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "ASTM simple range counting matrix", y=-0.15 )
fig.colorbar(cax)
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>
ASTM range pair counting matrix
Function help
[6]:
from ffpack.lsm import astmRangePairCountingMatrix
help( astmRangePairCountingMatrix )
Help on function astmRangePairCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
astmRangePairCountingMatrix(data, resolution=0.5)
Calculate ASTM range pair counting matrix.
Parameters
----------
data: 1d array
Sequence data to calculate range pair counting matrix.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0:
Examples
--------
>>> from ffpack.lsm import astmRangePairCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = astmRangePairCountingMatrix( data )
Example with default values
[7]:
arpcmData = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
arpcmMat, arpcmIndex = astmRangePairCountingMatrix( arpcmData )
arpcmMat = np.array( arpcmMat )
arpcmIndex = np.array( arpcmIndex ).astype( float )
[8]:
print( "ASTM range pair counting matrix" )
print( arpcmMat )
print()
print( "Matrix index" )
print( arpcmIndex )
ASTM range pair counting matrix
[[0. 0. 0. 0. 0. 0. 1.]
[0. 0. 0. 1. 0. 0. 0.]
[0. 0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0.]]
Matrix index
[-3. -2. -1. 1. 3. 4. 5.]
[9]:
plt.set_cmap( "viridis_r" )
fig, ax = plt.subplots()
cax = ax.matshow( arpcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + arpcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + arpcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( arpcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( arpcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "ASTM range pair counting matrix", y=-0.15 )
fig.colorbar(cax)
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>
ASTM rainflow counting matrix
Function help
[10]:
from ffpack.lsm import astmRainflowCountingMatrix
help( astmRainflowCountingMatrix )
Help on function astmRainflowCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
astmRainflowCountingMatrix(data, resolution=0.5)
Calculate ASTM rainflow counting matrix.
Parameters
----------
data: 1d array
Sequence data to calculate rainflow counting matrix.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0:
Examples
--------
>>> from ffpack.lsm import astmRainflowCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = astmRainflowCountingMatrix( data )
Example with default values
[11]:
arcmData = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
arcmMat, arcmIndex = astmRainflowCountingMatrix( arcmData )
arcmMat = np.array( arcmMat )
arcmIndex = np.array( arcmIndex ).astype( float )
[12]:
print( "ASTM rainflow counting matrix" )
print( arcmMat )
print()
print( "Matrix index" )
print( arcmIndex )
ASTM rainflow counting matrix
[[0. 0. 0. 0. 0. 0. 0.5 0. ]
[0. 0. 0. 0. 0. 0. 0. 0.5]
[0. 0. 0. 0. 0.5 0. 0. 0. ]
[0. 0. 0. 0. 0. 1. 0. 0. ]
[0. 0.5 0. 0. 0. 0. 0. 0. ]
[0. 0. 0. 0. 0. 0. 0. 0. ]
[0. 0. 0.5 0. 0. 0. 0. 0. ]
[0.5 0. 0. 0. 0. 0. 0. 0. ]]
Matrix index
[-4. -3. -2. -1. 1. 3. 4. 5.]
[13]:
plt.set_cmap( "viridis_r")
fig, ax = plt.subplots()
cax = ax.matshow( arcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + arcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + arcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( arcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( arcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "ASTM rainflow counting matrix", y=-0.15 )
fig.colorbar( cax )
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>
ASTM rainflow counting matrix for repeating histories
Function help
[14]:
from ffpack.lsm import astmRainflowRepeatHistoryCountingMatrix
help( astmRainflowRepeatHistoryCountingMatrix )
Help on function astmRainflowRepeatHistoryCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
astmRainflowRepeatHistoryCountingMatrix(data, resolution=0.5)
Calculate ASTM simplified rainflow counting matrix for repeating histories.
Parameters
----------
data: 1d array
Sequence data to calculate simplified rainflow counting matrix
for repeating histories.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0:
Examples
--------
>>> from ffpack.lsm import astmRainflowRepeatHistoryCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = astmRainflowRepeatHistoryCountingMatrix( data )
Example with default values
[15]:
arrhcmData = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
arrhcmMat, arrhcmIndex = astmRainflowRepeatHistoryCountingMatrix( arrhcmData )
arrhcmMat = np.array( arrhcmMat )
arrhcmIndex = np.array( arrhcmIndex ).astype( float )
[16]:
print( "ASTM rainflow counting matrix for repeating histories" )
print( arrhcmMat )
print()
print( "Matrix index" )
print( arrhcmIndex )
ASTM rainflow counting matrix for repeating histories
[[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 1. 0. 0. 0.]
[0. 0. 0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]
[0. 1. 0. 0. 0. 0. 0. 0.]
[1. 0. 0. 0. 0. 0. 0. 0.]]
Matrix index
[-4. -3. -2. -1. 1. 3. 4. 5.]
[17]:
plt.set_cmap( "viridis_r")
fig, ax = plt.subplots()
cax = ax.matshow( arrhcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + arrhcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + arrhcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( arrhcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( arrhcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "ASTM rainflow counting matrix for repeating histories", y=-0.15 )
fig.colorbar( cax )
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>
Johannesson min max counting matrix
Function help
[18]:
from ffpack.lsm import johannessonMinMaxCountingMatrix
help( johannessonMinMaxCountingMatrix )
Help on function johannessonMinMaxCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
johannessonMinMaxCountingMatrix(data, resolution=0.5)
Calculate Johannesson minMax cycle counting matrix.
Parameters
----------
data: 1d array
Sequence data to calculate rainflow counting matrix.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0:
Examples
--------
>>> from ffpack.lsm import johannessonMinMaxCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = johannessonMinMaxCountingMatrix( data )
Example with default values
[19]:
jmmcmData = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
jmmcmMat, jmmcmIndex = johannessonMinMaxCountingMatrix( jmmcmData )
jmmcmMat = np.array( jmmcmMat )
jmmcmIndex = np.array( jmmcmIndex ).astype( float )
[20]:
print( "Rychlik rainflow counting matrix" )
print( jmmcmMat )
print()
print( "Matrix index" )
print( jmmcmIndex )
Rychlik rainflow counting matrix
[[0. 0. 0. 0. 0. 0. 1. 0.]
[0. 0. 0. 0. 0. 0. 0. 1.]
[0. 0. 0. 0. 1. 0. 0. 0.]
[0. 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. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0. 0. 0.]]
Matrix index
[-4. -3. -2. -1. 1. 3. 4. 5.]
[21]:
plt.set_cmap( "viridis_r" )
fig, ax = plt.subplots()
cax = ax.matshow( jmmcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + jmmcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + jmmcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( jmmcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( jmmcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "Johannesson min max counting matrix", y=-0.15 )
fig.colorbar( cax )
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>
Rychlik rainflow counting matrix
Function help
[22]:
from ffpack.lsm import rychlikRainflowCountingMatrix
help( rychlikRainflowCountingMatrix )
Help on function rychlikRainflowCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
rychlikRainflowCountingMatrix(data, resolution=0.5)
Calculate Rychlik rainflow counting matrix.
Parameters
----------
data: 1d array
Sequence data to calculate rainflow counting matrix.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0:
Examples
--------
>>> from ffpack.lsm import rychlikRainflowCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = rychlikRainflowCountingMatrix( data )
Example with default values
[23]:
rrcmData = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
rrcmMat, rrcmIndex = rychlikRainflowCountingMatrix( rrcmData )
rrcmMat = np.array( rrcmMat )
rrcmIndex = np.array( rrcmIndex ).astype( float )
[24]:
print( "Rychlik rainflow counting matrix" )
print( rrcmMat )
print()
print( "Matrix index" )
print( rrcmIndex )
Rychlik rainflow counting matrix
[[0. 0. 0. 0. 0. 0. 1.]
[0. 0. 0. 1. 0. 1. 0.]
[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. 0.]
[0. 0. 0. 0. 0. 0. 0.]]
Matrix index
[-3. -2. -1. 1. 3. 4. 5.]
[25]:
plt.set_cmap( "viridis_r" )
fig, ax = plt.subplots()
cax = ax.matshow( rrcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + rrcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + rrcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( rrcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( rrcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "Rychlik rainflow counting matrix", y=-0.15 )
fig.colorbar( cax )
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>
Four point counting matrix
Function help
[26]:
from ffpack.lsm import fourPointCountingMatrix
help( fourPointCountingMatrix )
Help on function fourPointCountingMatrix in module ffpack.lsm.cycleCountingMatrix:
fourPointCountingMatrix(data, resolution=0.5)
Calculate Four point cycle counting matrix.
Parameters
----------
data: 1d array
Sequence data to calculate rainflow counting matrix.
resolution: bool, optional
The desired resolution to round the data points.
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 1.
If the data length is less than 2.
Notes
-----
The default round function will round half to even: 1.5, 2.5 => 2.0:
Examples
--------
>>> from ffpack.lsm import fourPointCountingMatrix
>>> data = [ -2.0, 1.0, -3.0, 5.0, -1.0, 3.0, -4.0, 4.0, -2.0 ]
>>> rst, matrixIndexKey = fourPointCountingMatrix( data )
Example with default values
[27]:
fpcmData = [ 2, 5, 3, 6, 2, 4, 1, 6, 1, 4, 1, 5, 3, 6, 3, 6, 1, 5, 2 ]
fpcmMat, fpcmIndex = fourPointCountingMatrix( fpcmData )
fpcmMat = np.array( fpcmMat )
fpcmIndex = np.array( fpcmIndex ).astype( float )
[28]:
print( "Four point counting matrix" )
print( fpcmMat )
print()
print( "Matrix index" )
print( fpcmIndex )
Four point counting matrix
[[0. 0. 0. 1. 0. 2.]
[0. 0. 0. 1. 0. 0.]
[0. 0. 0. 0. 0. 0.]
[0. 0. 0. 0. 0. 0.]
[0. 0. 2. 0. 0. 0.]
[0. 0. 1. 0. 0. 0.]]
Matrix index
[1. 2. 3. 4. 5. 6.]
[29]:
plt.set_cmap( "viridis_r" )
fig, ax = plt.subplots()
cax = ax.matshow( fpcmMat )
ax.tick_params( axis='x', direction="in", length=5, top=False, bottom=False )
ax.tick_params( axis='y', direction="in", length=5, left=False, right=False )
ax.tick_params( axis='x', which="minor", top=False, bottom=False )
ax.tick_params( axis='y', which="minor", left=False, right=False )
ax.set_xticklabels( [ '' ] + fpcmIndex.tolist() )
ax.set_yticklabels( [ '' ] + fpcmIndex.tolist() )
ax.set_xticks( np.arange( -.5, len( fpcmIndex ), 1 ), minor=True )
ax.set_yticks( np.arange( -.5, len( fpcmIndex ), 1 ), minor=True )
ax.grid( which="minor", color='w', linestyle='-', linewidth=2 )
ax.set_ylabel( "From" )
ax.set_xlabel( "To" )
ax.xaxis.set_label_position( "top" )
ax.set_title( "Four point counting matrix", y=-0.15 )
fig.colorbar( cax )
plt.tight_layout()
plt.show()
<Figure size 400x320 with 0 Axes>