The AbstractDetector class#
- class pylife.stress.rainflow.AbstractDetector(recorder=None)[source]#
Define the common base class for streaming rainflow detectors.
Subclasses implement a concrete rainflow counting rule, such as three-point or four-point counting. A detector receives load samples and reports closed hysteresis loops to its recorder through
record_values(). Detectors that know the source sample indices also callrecord_index()andreport_chunk().- Parameters:
recorder (AbstractRecorder, optional) – Recorder that receives the detected rainflow loops. If
None(the default), a newpylife.stress.rainflow.LoopValueRecorderis created for this detector.
Notes
Implement
process()so processing is independent of chunk size:detector.process(signal)should be equivalent todetector.process(signal[:n]).process(signal[n:])for any split point0 < n < len(signal). This enables streamed rainflow counting for large signals.Rainflow counting in pyLife is based on common three-point and four-point algorithms, including the DIN 45667 / ASTM E1049 family of rainflow counting methods.
- __init__(recorder=None)[source]#
Instantiate a detector base.
- Parameters:
recorder (AbstractRecorder, optional) – Recorder that receives detected rainflow loops. If
None(the default), a newpylife.stress.rainflow.LoopValueRecorderis created for this detector.
- flush(samples=[])[source]#
Flush cached values after processing an optional final sample chunk.
If
processis called instead offlush, the last value of a load sequence is cached for a subsequent call toprocess, because it may or may not be a turning point of the sequence.Using
flushforces processing of the last value. This may not be the desired effect as multiple increasing or decreasing values in a row could occur, instead of processing only turning points.- Parameters:
samples (array_like, optional) – Final load samples to process, typically in MPa. Default is
[].- Returns:
The detector itself so processing can be chained.
- Return type:
See also
processProcess samples without forcing cached values to be emitted.
Notes
This method is equivalent to
process(samples, flush=True).
- abstractmethod process(samples, flush=False)[source]#
Process a sample chunk.
- Parameters:
samples (array_like) – Load samples to process, typically in MPa.
flush (bool, optional) – Whether to flush cached values at the end. See
pylife.stress.rainflow.FourPointDetector.process()for the user-facing behavior. Default isFalse.
- Returns:
The detector itself so processing can be chained.
- Return type:
See also
flushProcess samples and force cached values to be emitted.
Notes
Must be implemented by subclasses.
- property recorder#
Return the recorder that receives detected loops.
- Returns:
Recorder instance passed at construction time.
- Return type:
- property residual_index#
Return the sample indices of residual turning points.
- Returns:
Global sample indices of residual turning points.
- Return type:
- property residuals#
Return the residual turning points of the signal processed so far.
- Returns:
Load values of turning points that have not yet formed closed hysteresis loops.
- Return type: