Aggregation

[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'

Cycle counting aggregation

After the cycle counting, we usually obtain a 2D matrix with the format: [ [ value, count ],[ value, count ], ... ]. However, the counting results are very noisy if no preprocessing procedure is applied to the load sequence. For example, we might count two cycles with a range of 0.96, a half cycle with a range of 0.98, etc. Then, the resutls will be [ [ 0.96, 2 ],[ 0.98, 0.5 ], ... ]. We expected the counting results to be aggregated as [ [ 1, 2.5 ], ... ]. This function can aggregate based on the bin size and generate the cleaned counting results.

Function help

[2]:
from ffpack.utils import cycleCountingAggregation
help( cycleCountingAggregation )
Help on function cycleCountingAggregation in module ffpack.utils.lccUtils:

cycleCountingAggregation(data, binSize=1.0)
    Count the number of occurrences of each cycle digitized to the nearest bin.

    Parameters
    ----------
    data: 2d array
        Input cycle counting data [ [ value, count ], ... ] for bin collection

    binSize: scalar, optional
        bin size is the difference between each level,
        for example, binSize=1.0, the levels will be 0.0, 1.0, 2.0, 3.0 ...

    Returns
    -------
    rst: 2d array
        Aggregated [ [ aggregatedValue, count ] ] by the binSize


    Raises
    ------
    ValueError
        If the data dimension is not 2.
        If the data is empty

    Notes
    -----
    When a value is in the middle, it will be counted downward
    for example, 0.5 when binSize=1.0, the count will be counted to 0.0

    Examples
    --------
    >>> from ffpack.utils import cycleCountingAggregation
    >>> data = [ [ 1.7, 2.0 ], [ 2.2, 2.0 ] ]
    >>> rst = cycleCountingAggregation( data )

Example with default values

[3]:
ccaLccData = [ [ 1.7, 2.0 ], [ 2.2, 2.0 ] ]
ccaResults = cycleCountingAggregation( ccaLccData )
[4]:
print( ccaResults )
[[2.0, 4.0]]