TimeCumAverage#

class acoular.tprocess.TimeCumAverage

Bases: TimeOut

Calculates the cumulative average of the signal.

This class computes the cumulative average of the input signal over time, which is useful for metrics like the Equivalent Continuous Sound Level (Leq). It processes the signal in blocks, maintaining a running average of the samples. The result is yielded in blocks, allowing for memory-efficient processing of large datasets.

source = Instance(SamplesGenerator)

The input data source. It must be an instance of a SamplesGenerator-derived class.

result(num)

Generate the cumulative average of the input signal in blocks.

This method iterates through the signal samples provided by the source, and for each block, it computes the cumulative average of the samples up to that point. The result is yielded in blocks, with each block containing the cumulative average of the signal up to that sample.

Parameters:
numint

Number of samples per block.

Yields:
numpy.ndarray

An array containing the cumulative average of the samples. Each block will have the shape (num, num_channels), where num_channels is inhereted from the source. The last block may contain fewer samples if the total number of samples is not a multiple of num.

Notes

The cumulative average is updated iteratively by considering the previously accumulated sum and the current block of samples. For each new sample, the cumulative average is recalculated by summing the previous cumulative value and the new samples, then dividing by the total number of samples up to that point.