pyyeti.cyclecount.sigcount¶
- pyyeti.cyclecount.sigcount(sig, ampbins=10, meanbins=1, right=True, precision=3, retbins=False, use_pandas=True)[source]¶
Do rainflow cycle counting on a signal.
- Parameters:
sig (1d array_like) – Signal (vector) to do cycle counting on.
ampbins (scalar or 1d array_like) – Defines the cycle amplitude bins; see
getbins()for more complete description on how bins are defined.ampbins type
Brief description (see also
getbins())scalar
Defines number of bins to use
vector
Defines lower bin boundaries
meanbins (scalar or 1d array_like) – Defines the cycle mean-value bins; see ampbins description and
getbins()for more complete description on how bins are defined.right (bool; optional) – Indicates whether the bins include the rightmost edge or the leftmost edge. If right == True (the default), then the bins [1,2,3,4] indicate (1,2], (2,3], (3,4].
precision (integer; optional) – Precision to use for DataFrame labels.
retbins (bool; optional) – If True, return the ampbins and meanbins vectors.
use_pandas (bool; optional) – If True, this routine will return table as a pandas DataFrame.
- Returns:
table (pandas DataFrame or 2d ndarray) – A cycle count table (len(meanbins) x len(ampbins)). Each value in table entry is the number of cycles in the bin (see below).
ampbins (1d ndarray) – Boundaries of amplitude bins used; length = # of bins + 1. Only returned if retbins is True.
meanbins (1d ndarray) – Boundaries of mean-value bins used; length = # of bins + 1. Only returned if retbins is True.
Notes
- Steps:
Calls
findap()to find all local minima and maxima:peaks = sig[findap(sig)]Calls
rainflow()to do the cycle counting:rf = rainflow(peaks)Summarizes the rainflow counting by putting the counts in bins. For each mean value bin (i’th):
rf is filtered down to only those rows where the mean value falls in the mean-bin (call this subset of rf rffilt).
For each amplitude bin (j’th): count number of cycles in rffilt with amplitude that falls in the amp-bin and store in
table[i, j]
A value falls in bin i if:
bin[i] < value <= bin[i+1] } if right is True bin[i] <= value < bin[i+1] } if right is not True
Examples
>>> from pyyeti import cyclecount >>> import numpy as np >>> sig = np.arange(100) >>> sig[::2] *= -1 # [0, 1, -2, 3, -4, ..., 99] >>> # `sig` has 99 half-cycles; amplitude grows from 0.5 up to >>> # 98.5; mean of each is either 0.5 or -0.5 >>> table = cyclecount.sigcount(sig, 2, 2) >>> table Amp (0.402, 49.500] (49.500, 98.500] Mean... (-0.501, 0.000] 12.5 12.0 (0.000, 0.500] 12.5 12.5
We can focus on amplitudes only (ignoring the mean value bins):
>>> table.sum(axis=0) Amp (0.402, 49.500] 25.0 (49.500, 98.500] 24.5 dtype: float64
Focus on only the mean value bins:
>>> table.sum(axis=1) Mean (-0.501, 0.000] 24.5 (0.000, 0.500] 25.0 dtype: float64
If not using pandas:
>>> cyclecount.sigcount(sig, 2, 2, use_pandas=False) array([[ 12.5, 12. ], [ 12.5, 12.5]])