tmoving#

swordfish.function.tmoving()#

Apply the function/operator to a sliding window of the given objects.

The tmoving template always returns a vector with the same number of elements as the number of rows in the input arguments.

Each of the built-in tm-functions such as tmsum, tmcount and tmavg is optimized for its specific use case. Therefore, they have much better performance than the tmoving template.

Parameters:
  • func (Constant) – A function.

  • T (Constant) – A non-strictly increasing vector of temporal or integral type. It cannot contain null values.

  • funcArgs (Constant) – The parameters of func. They can be vectors/dictionaries/tables. It is a tuple if there are more than one parameter of func, and all parameters must have the same size.

  • window (Constant) –

    A scalar of positive integer or DURATION type indicating the size of the sliding window.

    For each element Ti in T:

    • When T is an integral value, the range of the corresponding window is (Ti - window, Ti]

    • When T is a temporal value, the range of the corresponding window is (temporalAdd(Ti, -window), Ti]

  • excludedPeriod (Constant, optional) –

    A pair of time values (of TIME, NANOTIME, MINUTE, and SECOND type) representing the start and end time of the period which is excluded from the calculation, by default DFLT.

    When the excludedPeriod is set, the input T cannot contain the time range specified by excludedPeriod and must be of TIMESTAMP, NANOTIMESTAMP, TIME, and NANOTIME types. Note that excludedPeriod must be within a calendar day and cannot be longer than the value of (24 - window).