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 to self._recorder using its record_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 using report_chunk().

The process() method is supposed return self and to be implemented in a way, that the result is independent of the sample chunksize, so dtor.process(signal) should be equivalent to dtor.process(signal[:n]).process(signal[n:]) for any 0 < n < signal length.

Should usually only be instantiated by a sublacsse’s __init__() using super().__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 process is called instead of flush, the last value of a load sequence is cached for a subsequent call to process, because it may or may not be a turning point of the sequence.

Using flush forces 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 self object so that processing can be chained

Return type:

AbstractDetector

Notes

This method is equivalent to process(samples, flush=True).

abstractmethod process(samples, flush=False)[source]

Process a sample chunk.

Parameters:
  • samples (array_like, shape (N, )) – The samples to be processed

  • flush (bool) –

    Whether to flush the cached values at the end.

    For explanations see process()

Returns:

self – The self object so that processing can be chained

Return type:

instance of the subclass

Notes

Must be implemented by subclasses.

See also

flush()

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.