The AbstractDetector class
- class pylife.stress.rainflow.AbstractDetector(recorder)[source]
The common base class for rainflow detectors.
Subclasses implementing a specific rainflow counting algorithm are supposed to implement a method
process()that takes the signal samples as a parameter, and reports all the hysteresis loop limits toself._recorderusing itsrecord_values()method of.Some detectors also report the index of the loop limiting samples to the recorder using its
record_index()method. Those detectors should also report the size of each processed sample chunk to the recorder usingreport_chunk().The
process()method is supposed returnselfand to be implemented in a way, that the result is independent of the sample chunksize, sodtor.process(signal)should be equivalent todtor.process(signal[:n]).process(signal[n:])for any 0 < n < signal length.Should usually only be instantiated by a sublacsse’s
__init__()usingsuper().__init__().- __init__(recorder)[source]
Instantiate an AbstractDetector.
- Parameters:
recorder (subclass of
AbstractRecorder) – The recorder that the detector will report to.
- flush(samples=[])[source]
Flush all remaining cached values from previous calls of
process. Process all the given values until the end, leaving no cached values.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.For examples see
process()- Parameters:
samples (array_like, shape (N, )) – The samples to be processed
- Returns:
self – The
selfobject so that processing can be chained- Return type:
Notes
This method is equivalent to
process(samples, flush=True).
- abstractmethod process(samples, flush=False)[source]
Process a sample chunk.
- Parameters:
- Returns:
self – The
selfobject so that processing can be chained- Return type:
instance of the subclass
Notes
Must be implemented by subclasses.
See also
- property recorder
The recorder instance the detector is reporting to.
- property residual_index
The index of the residual turning points of the time signal so far.
- property residuals
The residual turning points of the time signal so far.
The residuals are the loops not (yet) closed.