Time Average

Description

Compute a basic time average of the base on a characteristic integration time using an online algorithm.

The treatment stores the number of accumulated iterations and the averaged base so it can be called many times to perform the averaging.

Parameters

  • base: Base

    The input base to be averaged.

  • nb_ite_averaging: int or in_attr, default= ‘in_attr’

    Number of iterations over which averaging is done. If in_attr, then each zone of the base must have an attribute nb_ite_averaging. This is the number of iterations performed by the solver, which ends up with the base. In particular, it may be different from the number of instants.

  • extracts_step: int, default= 1

    The number of time iterations between two instants of the base. For example, if the number of physical iterations is 10, maybe you could have sampled the signal every 2 iterations so you get 5 instants in the base.

  • memory_mode: bool, default= False

    If True, the initial base is deleted on the fly to limit memory usage.

Preconditions

Zones may contain multiple instants and shared variables.

The extract timestep is assumed constant.

Postconditions

The output base contains one instant named ‘average’ and the shared instant from the input base.

Example

The following example shows a time averaging on the first 1000 iterations with an extraction step of 10.

import antares
myt = antares.Treatment('onlinetimeaveraging')
myt['base'] = base
myt['nb_ite_averaging'] = 1000
myt['extracts_step'] = 10
myt['memory_mode'] = False
base_avg = myt.execute()

Main functions

class antares.treatment.TreatmentOnlineTimeAveraging.TreatmentOnlineTimeAveraging
execute()

Average variables.

Example

import numpy as np

import antares

b = antares.Base()
b['0000'] = antares.Zone()
x, y, z = np.meshgrid(np.linspace(0.0, 1.0, 3),
                      np.linspace(0.0, 1.0, 3),
                      np.linspace(0.0, 1.0, 3))
b[0].shared['x'] = x
b[0].shared['y'] = y
b[0].shared['z'] = z

for i in range(10):
    b[0]['%d'%i] = antares.Instant()
    b[0][i]['v'] = np.ones(x.shape) * (i+1) * 2

myt = antares.Treatment('onlinetimeaveraging')
myt['base'] = b
myt['nb_ite_averaging'] = 20
myt['extracts_step'] = 2
base_avg = myt.execute()

print(base_avg[0]['average']['v'])